All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: chandanbabu@kernel.org, djwong@kernel.org
Cc: Allison Henderson <allison.henderson@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	hch@lst.de, allison.henderson@oracle.com,
	catherine.hoang@oracle.com, linux-xfs@vger.kernel.org
Subject: [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5
Date: Mon, 15 Apr 2024 16:57:59 -0700	[thread overview]
Message-ID: <171322386546.92087.1516726756882199391.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs>

From: Allison Henderson <allison.henderson@oracle.com>

With parent pointers enabled, a rename operation can update up to 5
inodes: src_dp, target_dp, src_ip, target_ip and wip.  This causes
their dquots to a be attached to the transaction chain, so we need
to increase XFS_QM_TRANS_MAXDQS.  This patch also add a helper
function xfs_dqlockn to lock an arbitrary number of dquots.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_dquot.c       |   41 +++++++++++++++++++++++++++++++++++++++++
 fs/xfs/xfs_dquot.h       |    1 +
 fs/xfs/xfs_qm.h          |    2 +-
 fs/xfs/xfs_trans_dquot.c |   15 ++++++++++-----
 4 files changed, 53 insertions(+), 6 deletions(-)


diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index c98cb468c357..13aba84bd64a 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1371,6 +1371,47 @@ xfs_dqlock2(
 	}
 }
 
+static int
+xfs_dqtrx_cmp(
+	const void		*a,
+	const void		*b)
+{
+	const struct xfs_dqtrx	*qa = a;
+	const struct xfs_dqtrx	*qb = b;
+
+	if (qa->qt_dquot->q_id > qb->qt_dquot->q_id)
+		return 1;
+	if (qa->qt_dquot->q_id < qb->qt_dquot->q_id)
+		return -1;
+	return 0;
+}
+
+void
+xfs_dqlockn(
+	struct xfs_dqtrx	*q)
+{
+	unsigned int		i;
+
+	BUILD_BUG_ON(XFS_QM_TRANS_MAXDQS > MAX_LOCKDEP_SUBCLASSES);
+
+	/* Sort in order of dquot id, do not allow duplicates */
+	for (i = 0; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++) {
+		unsigned int	j;
+
+		for (j = 0; j < i; j++)
+			ASSERT(q[i].qt_dquot != q[j].qt_dquot);
+	}
+	if (i == 0)
+		return;
+
+	sort(q, i, sizeof(struct xfs_dqtrx), xfs_dqtrx_cmp, NULL);
+
+	mutex_lock(&q[0].qt_dquot->q_qlock);
+	for (i = 1; i < XFS_QM_TRANS_MAXDQS && q[i].qt_dquot != NULL; i++)
+		mutex_lock_nested(&q[i].qt_dquot->q_qlock,
+				XFS_QLOCK_NESTED + i - 1);
+}
+
 int __init
 xfs_qm_init(void)
 {
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index 956272d9b302..677bb2dc9ac9 100644
--- a/fs/xfs/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
@@ -223,6 +223,7 @@ int		xfs_qm_dqget_uncached(struct xfs_mount *mp,
 void		xfs_qm_dqput(struct xfs_dquot *dqp);
 
 void		xfs_dqlock2(struct xfs_dquot *, struct xfs_dquot *);
+void		xfs_dqlockn(struct xfs_dqtrx *q);
 
 void		xfs_dquot_set_prealloc_limits(struct xfs_dquot *);
 
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
index f5993012bf98..6e09dfcd13e2 100644
--- a/fs/xfs/xfs_qm.h
+++ b/fs/xfs/xfs_qm.h
@@ -136,7 +136,7 @@ enum {
 	XFS_QM_TRANS_PRJ,
 	XFS_QM_TRANS_DQTYPES
 };
-#define XFS_QM_TRANS_MAXDQS		2
+#define XFS_QM_TRANS_MAXDQS		5
 struct xfs_dquot_acct {
 	struct xfs_dqtrx	dqs[XFS_QM_TRANS_DQTYPES][XFS_QM_TRANS_MAXDQS];
 };
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 577b535a595c..b368e13424c4 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -379,24 +379,29 @@ xfs_trans_mod_dquot(
 
 /*
  * Given an array of dqtrx structures, lock all the dquots associated and join
- * them to the transaction, provided they have been modified.  We know that the
- * highest number of dquots of one type - usr, grp and prj - involved in a
- * transaction is 3 so we don't need to make this very generic.
+ * them to the transaction, provided they have been modified.
  */
 STATIC void
 xfs_trans_dqlockedjoin(
 	struct xfs_trans	*tp,
 	struct xfs_dqtrx	*q)
 {
+	unsigned int		i;
 	ASSERT(q[0].qt_dquot != NULL);
 	if (q[1].qt_dquot == NULL) {
 		xfs_dqlock(q[0].qt_dquot);
 		xfs_trans_dqjoin(tp, q[0].qt_dquot);
-	} else {
-		ASSERT(XFS_QM_TRANS_MAXDQS == 2);
+	} else if (q[2].qt_dquot == NULL) {
 		xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot);
 		xfs_trans_dqjoin(tp, q[0].qt_dquot);
 		xfs_trans_dqjoin(tp, q[1].qt_dquot);
+	} else {
+		xfs_dqlockn(q);
+		for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
+			if (q[i].qt_dquot == NULL)
+				break;
+			xfs_trans_dqjoin(tp, q[i].qt_dquot);
+		}
 	}
 }
 


  parent reply	other threads:[~2024-04-15 23:58 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 23:28 [PATCHBOMB v30.3] xfs: online repair, part 1 is done Darrick J. Wong
2024-04-15 23:33 ` [PATCHSET v30.3 01/16] xfs: improve log incompat feature handling Darrick J. Wong
2024-04-15 23:37   ` [PATCH 1/5] xfs: pass xfs_buf lookup flags to xfs_*read_agi Darrick J. Wong
2024-04-15 23:38   ` [PATCH 2/5] xfs: fix an AGI lock acquisition ordering problem in xrep_dinode_findmode Darrick J. Wong
2024-04-15 23:38   ` [PATCH 3/5] xfs: fix potential AGI <-> ILOCK ABBA deadlock in xrep_dinode_findmode_walk_directory Darrick J. Wong
2024-04-15 23:38   ` [PATCH 4/5] xfs: fix error bailout in xrep_abt_build_new_trees Darrick J. Wong
2024-04-15 23:38   ` [PATCH 5/5] xfs: only clear log incompat flags at clean unmount Darrick J. Wong
2024-04-15 23:34 ` [PATCHSET v30.3 02/16] xfs: refactorings for atomic file content exchanges Darrick J. Wong
2024-04-15 23:39   ` [PATCH 1/7] xfs: move inode lease breaking functions to xfs_inode.c Darrick J. Wong
2024-04-15 23:39   ` [PATCH 2/7] xfs: move xfs_iops.c declarations out of xfs_inode.h Darrick J. Wong
2024-04-15 23:39   ` [PATCH 3/7] xfs: declare xfs_file.c symbols in xfs_file.h Darrick J. Wong
2024-04-15 23:40   ` [PATCH 4/7] xfs: create a new helper to return a file's allocation unit Darrick J. Wong
2024-04-15 23:40   ` [PATCH 5/7] xfs: hoist multi-fsb allocation unit detection to a helper Darrick J. Wong
2024-04-15 23:40   ` [PATCH 6/7] xfs: refactor non-power-of-two alignment checks Darrick J. Wong
2024-04-15 23:40   ` [PATCH 7/7] xfs: constify xfs_bmap_is_written_extent Darrick J. Wong
2024-04-15 23:34 ` [PATCHSET v30.3 03/16] xfs: atomic file content exchanges Darrick J. Wong
2024-04-15 23:41   ` [PATCH 01/15] vfs: export remap and write check helpers Darrick J. Wong
2024-04-15 23:41   ` [PATCH 02/15] xfs: introduce new file range exchange ioctl Darrick J. Wong
2024-04-15 23:41   ` [PATCH 03/15] xfs: create a incompat flag for atomic file mapping exchanges Darrick J. Wong
2024-04-15 23:41   ` [PATCH 04/15] xfs: introduce a file mapping exchange log intent item Darrick J. Wong
2024-04-15 23:42   ` [PATCH 05/15] xfs: create deferred log items for file mapping exchanges Darrick J. Wong
2024-04-15 23:42   ` [PATCH 06/15] xfs: bind together the front and back ends of the file range exchange code Darrick J. Wong
2024-04-15 23:42   ` [PATCH 07/15] xfs: add error injection to test file mapping exchange recovery Darrick J. Wong
2024-04-15 23:42   ` [PATCH 08/15] xfs: condense extended attributes after a mapping exchange operation Darrick J. Wong
2024-04-15 23:43   ` [PATCH 09/15] xfs: condense directories " Darrick J. Wong
2024-04-15 23:43   ` [PATCH 10/15] xfs: condense symbolic links " Darrick J. Wong
2024-04-15 23:43   ` [PATCH 11/15] xfs: make file range exchange support realtime files Darrick J. Wong
2024-04-15 23:43   ` [PATCH 12/15] xfs: support non-power-of-two rtextsize with exchange-range Darrick J. Wong
2024-04-15 23:44   ` [PATCH 13/15] xfs: capture inode generation numbers in the ondisk exchmaps log item Darrick J. Wong
2024-04-15 23:44   ` [PATCH 14/15] docs: update swapext -> exchmaps language Darrick J. Wong
2024-04-15 23:44   ` [PATCH 15/15] xfs: enable logged file mapping exchange feature Darrick J. Wong
2024-04-15 23:34 ` [PATCHSET v30.3 04/16] xfs: create temporary files for online repair Darrick J. Wong
2024-04-15 23:44   ` [PATCH 1/4] xfs: hide private inodes from bulkstat and handle functions Darrick J. Wong
2024-04-15 23:45   ` [PATCH 2/4] xfs: create temporary files and directories for online repair Darrick J. Wong
2024-04-15 23:45   ` [PATCH 3/4] xfs: refactor live buffer invalidation for repairs Darrick J. Wong
2024-04-15 23:45   ` [PATCH 4/4] xfs: add the ability to reap entire inode forks Darrick J. Wong
2024-04-15 23:34 ` [PATCHSET v30.3 05/16] xfs: online repair of realtime summaries Darrick J. Wong
2024-04-15 23:46   ` [PATCH 1/3] xfs: support preallocating and copying content into temporary files Darrick J. Wong
2024-04-15 23:46   ` [PATCH 2/3] xfs: teach the tempfile to set up atomic file content exchanges Darrick J. Wong
2024-04-15 23:46   ` [PATCH 3/3] xfs: online repair of realtime summaries Darrick J. Wong
2024-04-15 23:35 ` [PATCHSET v30.3 06/16] xfs: set and validate dir/attr block owners Darrick J. Wong
2024-04-15 23:46   ` [PATCH 01/10] xfs: add an explicit owner field to xfs_da_args Darrick J. Wong
2024-04-15 23:47   ` [PATCH 02/10] xfs: use the xfs_da_args owner field to set new dir/attr block owner Darrick J. Wong
2024-04-15 23:47   ` [PATCH 03/10] xfs: reduce indenting in xfs_attr_node_list Darrick J. Wong
2024-04-15 23:47   ` [PATCH 04/10] xfs: validate attr leaf buffer owners Darrick J. Wong
2024-04-15 23:47   ` [PATCH 05/10] xfs: validate attr remote value " Darrick J. Wong
2024-04-15 23:48   ` [PATCH 06/10] xfs: validate dabtree node " Darrick J. Wong
2024-04-15 23:48   ` [PATCH 07/10] xfs: validate directory leaf " Darrick J. Wong
2024-04-15 23:48   ` [PATCH 08/10] xfs: validate explicit directory data " Darrick J. Wong
2024-04-15 23:48   ` [PATCH 09/10] xfs: validate explicit directory block " Darrick J. Wong
2024-04-15 23:49   ` [PATCH 10/10] xfs: validate explicit directory free block owners Darrick J. Wong
2024-04-15 23:35 ` [PATCHSET v30.3 07/16] xfs: online repair of extended attributes Darrick J. Wong
2024-04-15 23:49   ` [PATCH 1/7] xfs: enable discarding of folios backing an xfile Darrick J. Wong
2024-04-15 23:49   ` [PATCH 2/7] xfs: create a blob array data structure Darrick J. Wong
2024-04-15 23:49   ` [PATCH 3/7] xfs: use atomic extent swapping to fix user file fork data Darrick J. Wong
2024-04-15 23:50   ` [PATCH 4/7] xfs: repair extended attributes Darrick J. Wong
2024-04-15 23:50   ` [PATCH 5/7] xfs: scrub should set preen if attr leaf has holes Darrick J. Wong
2024-04-15 23:50   ` [PATCH 6/7] xfs: flag empty xattr leaf blocks for optimization Darrick J. Wong
2024-04-15 23:50   ` [PATCH 7/7] xfs: create an xattr iteration function for scrub Darrick J. Wong
2024-04-15 23:35 ` [PATCHSET v30.3 08/16] xfs: online repair of inode unlinked state Darrick J. Wong
2024-04-15 23:51   ` [PATCH 1/2] xfs: ensure unlinked list state is consistent with nlink during scrub Darrick J. Wong
2024-04-15 23:51   ` [PATCH 2/2] xfs: update the unlinked list when repairing link counts Darrick J. Wong
2024-04-15 23:35 ` [PATCHSET v30.3 09/16] xfs: online repair of directories Darrick J. Wong
2024-04-15 23:51   ` [PATCH 1/5] xfs: inactivate directory data blocks Darrick J. Wong
2024-04-15 23:52   ` [PATCH 2/5] xfs: online repair of directories Darrick J. Wong
2024-04-15 23:52   ` [PATCH 3/5] xfs: scan the filesystem to repair a directory dotdot entry Darrick J. Wong
2024-04-15 23:52   ` [PATCH 4/5] xfs: online repair of parent pointers Darrick J. Wong
2024-04-15 23:52   ` [PATCH 5/5] xfs: ask the dentry cache if it knows the parent of a directory Darrick J. Wong
2024-04-15 23:36 ` [PATCHSET v30.3 10/16] xfs: move orphan files to lost and found Darrick J. Wong
2024-04-15 23:53   ` [PATCH 1/3] xfs: move orphan files to the orphanage Darrick J. Wong
2024-04-15 23:53   ` [PATCH 2/3] xfs: move files to orphanage instead of letting nlinks drop to zero Darrick J. Wong
2024-04-15 23:53   ` [PATCH 3/3] xfs: ensure dentry consistency when the orphanage adopts a file Darrick J. Wong
2024-04-15 23:36 ` [PATCHSET v30.3 11/16] xfs: online repair of symbolic links Darrick J. Wong
2024-04-15 23:53   ` [PATCH 1/3] xfs: expose xfs_bmap_local_to_extents for online repair Darrick J. Wong
2024-04-15 23:54   ` [PATCH 2/3] xfs: pass the owner to xfs_symlink_write_target Darrick J. Wong
2024-04-15 23:54   ` [PATCH 3/3] xfs: online repair of symbolic links Darrick J. Wong
2024-04-15 23:36 ` [PATCHSET v30.3 12/16] xfs: online fsck of iunlink buckets Darrick J. Wong
2024-04-15 23:54   ` [PATCH 1/3] xfs: check AGI unlinked inode buckets Darrick J. Wong
2024-04-15 23:54   ` [PATCH 2/3] xfs: hoist AGI repair context to a heap object Darrick J. Wong
2024-04-15 23:55   ` [PATCH 3/3] xfs: repair AGI unlinked inode bucket lists Darrick J. Wong
2024-04-15 23:36 ` [PATCHSET v30.3 13/16] xfs: inode-related repair fixes Darrick J. Wong
2024-04-15 23:55   ` [PATCH 1/4] xfs: check unused nlink fields in the ondisk inode Darrick J. Wong
2024-04-15 23:55   ` [PATCH 2/4] xfs: try to avoid allocating from sick inode clusters Darrick J. Wong
2024-04-15 23:55   ` [PATCH 3/4] xfs: pin inodes that would otherwise overflow link count Darrick J. Wong
2024-04-15 23:56   ` [PATCH 4/4] xfs: create subordinate scrub contexts for xchk_metadata_inode_subtype Darrick J. Wong
2024-04-15 23:37 ` [PATCHSET v30.3 14/16] xfs: less heavy locks during fstrim Darrick J. Wong
2024-04-15 23:56   ` [PATCH 1/1] xfs: fix performance problems when fstrimming a subset of a fragmented AG Darrick J. Wong
2024-04-15 23:37 ` [PATCHSET v13.2 15/16] xfs: design documentation for online fsck, part 2 Darrick J. Wong
2024-04-15 23:56   ` [PATCH 1/4] docs: update the parent pointers documentation to the final version Darrick J. Wong
2024-04-15 23:56   ` [PATCH 2/4] docs: update online directory and parent pointer repair sections Darrick J. Wong
2024-04-15 23:57   ` [PATCH 3/4] docs: update offline parent pointer repair strategy Darrick J. Wong
2024-04-15 23:57   ` [PATCH 4/4] docs: describe xfs directory tree online fsck Darrick J. Wong
2024-04-15 23:37 ` [PATCHSET v13.2 16/16] xfs: retain ILOCK during directory updates Darrick J. Wong
2024-04-15 23:57   ` [PATCH 1/7] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 Darrick J. Wong
2024-04-15 23:57   ` Darrick J. Wong [this message]
2024-04-15 23:58   ` [PATCH 3/7] xfs: Hold inode locks in xfs_ialloc Darrick J. Wong
2024-04-15 23:58   ` [PATCH 4/7] xfs: Hold inode locks in xfs_trans_alloc_dir Darrick J. Wong
2024-04-15 23:58   ` [PATCH 5/7] xfs: Hold inode locks in xfs_rename Darrick J. Wong
2024-04-15 23:59   ` [PATCH 6/7] xfs: don't pick up IOLOCK during rmapbt repair scan Darrick J. Wong
2024-04-15 23:59   ` [PATCH 7/7] xfs: unlock new repair tempfiles after creation Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2024-04-10  0:44 [PATCHSET v13.1 2/9] xfs: retain ILOCK during directory updates Darrick J. Wong
2024-04-10  0:48 ` [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Darrick J. Wong
2024-04-10  4:41   ` Christoph Hellwig
2023-12-31 19:33 [PATCHSET v13.0 2/7] xfs: retain ILOCK during directory updates Darrick J. Wong
2023-12-31 20:43 ` [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Darrick J. Wong
2023-05-26  2:00 [PATCHSET v12.0 0/7] xfs: retain ILOCK during directory updates Darrick J. Wong
2023-05-26  2:05 ` [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171322386546.92087.1516726756882199391.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=allison.henderson@oracle.com \
    --cc=catherine.hoang@oracle.com \
    --cc=chandanbabu@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.