From patchwork Wed Apr 10 00:47:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623358 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B3C237C for ; Wed, 10 Apr 2024 00:47:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710067; cv=none; b=akoxWmSkM7dJZeD61mKGOSzrJqiM9iQotKhpHQ9LdHGvWprDuFYDB4M3yK2qf7rHGlpf0LGOWGNUxBHDRrWuh9oz00ssWe1lT4qLh1ksrc7kej/l6hx1MZitGaESWyUL9EpFrZwh+2mGO/FetZhANSMxEeyDUc6LW/i93ANQl8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710067; c=relaxed/simple; bh=phK99IXpkZSMy7HkWAf5G44jlrAWRsOSYiW4j/R4D5k=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EnAuEnAY7+Apsok+Z5Y6OYZImT69U5gFBjiFSnthyvRoqPWBMKCUGjI4v+NO7F6fXU8ZSvtALvl9aXlcQ/l+VS7p/KmJN/rMUB82vRJ/DrIbVeq4kMAZWHs4L4Z8JUzzQ/U4Cvh1AaRTTMWqoi0+sUVzLgAKUqHetuCUYKpKaEM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qbVAo1/S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qbVAo1/S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1422BC433F1; Wed, 10 Apr 2024 00:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710067; bh=phK99IXpkZSMy7HkWAf5G44jlrAWRsOSYiW4j/R4D5k=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=qbVAo1/SmA553PAIm2W8p0MjMsr//OoqPGUIwxzOYDJTZIsK6htN7QoL8IbMuqoUs kCkPekudLXFk7FiM3ccqwmnfnZsUPuXMdwZKrLyH6R8FzJDKAfdjSZ4SgiWmCPDRFl RcqnR0ADDZJ5IG2VKrf+wUDoOmOwbvDg/XTWm2qqM19W+RQ2t3N+oywpKZEC2T3EGc h/SeadfHBDmF5CttdAgNFFFzFFCjtb/OJRXKNVGTkT4lH91g474O2lnwdS7B+VTlCq JoobS0hJ/s+zryA7vGJjfhCRtpIXeOCv2ZY17cgJBXfCynPhFK3LsyKCqj7gK3G4Zk OGGiiUmZ0JaOQ== Date: Tue, 09 Apr 2024 17:47:46 -0700 Subject: [PATCH 1/7] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270967922.3631167.6063402039662594735.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson Renames that generate parent pointer updates can join up to 5 inodes locked in sorted order. So we need to increase the number of defer ops inodes and relock them in the same way. Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang [djwong: have one sorting function] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_defer.c | 6 +++++- fs/xfs/libxfs/xfs_defer.h | 8 +++++++- fs/xfs/xfs_inode.c | 27 ++++++++++++++++++--------- fs/xfs/xfs_inode.h | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 061cc01245a91..4a078e07e1a0a 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -1092,7 +1092,11 @@ xfs_defer_ops_continue( ASSERT(!(tp->t_flags & XFS_TRANS_DIRTY)); /* Lock the captured resources to the new transaction. */ - if (dfc->dfc_held.dr_inos == 2) + if (dfc->dfc_held.dr_inos > 2) { + xfs_sort_inodes(dfc->dfc_held.dr_ip, dfc->dfc_held.dr_inos); + xfs_lock_inodes(dfc->dfc_held.dr_ip, dfc->dfc_held.dr_inos, + XFS_ILOCK_EXCL); + } else if (dfc->dfc_held.dr_inos == 2) xfs_lock_two_inodes(dfc->dfc_held.dr_ip[0], XFS_ILOCK_EXCL, dfc->dfc_held.dr_ip[1], XFS_ILOCK_EXCL); else if (dfc->dfc_held.dr_inos == 1) diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h index 81cca60d70a3b..8b338031e487c 100644 --- a/fs/xfs/libxfs/xfs_defer.h +++ b/fs/xfs/libxfs/xfs_defer.h @@ -77,7 +77,13 @@ extern const struct xfs_defer_op_type xfs_exchmaps_defer_type; /* * Deferred operation item relogging limits. */ -#define XFS_DEFER_OPS_NR_INODES 2 /* join up to two inodes */ + +/* + * Rename w/ parent pointers can require up to 5 inodes with deferred ops to + * be joined to the transaction: src_dp, target_dp, src_ip, target_ip, and wip. + * These inodes are locked in sorted order by their inode numbers + */ +#define XFS_DEFER_OPS_NR_INODES 5 #define XFS_DEFER_OPS_NR_BUFS 2 /* join up to two buffers */ /* Resources that must be held across a transaction roll. */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 03dcb4ac04312..efd040094753f 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -418,7 +418,7 @@ xfs_lock_inumorder( * lock more than one at a time, lockdep will report false positives saying we * have violated locking orders. */ -static void +void xfs_lock_inodes( struct xfs_inode **ips, int inodes, @@ -2802,7 +2802,7 @@ xfs_sort_for_rename( struct xfs_inode **i_tab,/* out: sorted array of inodes */ int *num_inodes) /* in/out: inodes in array */ { - int i, j; + int i; ASSERT(*num_inodes == __XFS_SORT_INODES); memset(i_tab, 0, *num_inodes * sizeof(struct xfs_inode *)); @@ -2824,17 +2824,26 @@ xfs_sort_for_rename( i_tab[i++] = wip; *num_inodes = i; + xfs_sort_inodes(i_tab, *num_inodes); +} + +void +xfs_sort_inodes( + struct xfs_inode **i_tab, + unsigned int num_inodes) +{ + int i, j; + + ASSERT(num_inodes <= __XFS_SORT_INODES); + /* * Sort the elements via bubble sort. (Remember, there are at * most 5 elements to sort, so this is adequate.) */ - for (i = 0; i < *num_inodes; i++) { - for (j = 1; j < *num_inodes; j++) { - if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) { - struct xfs_inode *temp = i_tab[j]; - i_tab[j] = i_tab[j-1]; - i_tab[j-1] = temp; - } + for (i = 0; i < num_inodes; i++) { + for (j = 1; j < num_inodes; j++) { + if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) + swap(i_tab[j], i_tab[j - 1]); } } } diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index c74c48bc09453..a6da1ab8ab136 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h @@ -627,6 +627,8 @@ int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2); void xfs_iunlock2_remapping(struct xfs_inode *ip1, struct xfs_inode *ip2); void xfs_bumplink(struct xfs_trans *tp, struct xfs_inode *ip); +void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode); +void xfs_sort_inodes(struct xfs_inode **i_tab, unsigned int num_inodes); static inline bool xfs_inode_unlinked_incomplete( From patchwork Wed Apr 10 00:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623359 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D28C2387 for ; Wed, 10 Apr 2024 00:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710082; cv=none; b=odni2klXien46x+l2+eyZGOofhcQMIR5gzyTZhiKYGTTwV+PQOIKLauYrL2j9NLYQBFU6ESHDdxErJESGnnMXfnYhjZXg2zqORzq6cD5uMQKHcV7blK6eTqQa7kmVrU3YI/OQFfFHCcWMpxLlGZ1HEnkrwE6+4zP2geXV0s1ttM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710082; c=relaxed/simple; bh=IZnjwdsXxnBSwBCn5WS4jHNLm/hcO3SfqkFCvfYc+nk=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cFn6ogGp0NBMeQfbn94rxHjxb3Q8og81ObpKuDpDsoEo9Grfc6hMUcXTsAAFobEKt5faII0tzrF9VQdDpY64Yalytm60k5bGAXUWSvE1HHlkq9+g9wrV8IZVg64RejpOHyEQgp9f5wKWdgh6xsGYhqgq42tZYs+CGP0pQJeW+ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q/uD6wZd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q/uD6wZd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8882C433F1; Wed, 10 Apr 2024 00:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710082; bh=IZnjwdsXxnBSwBCn5WS4jHNLm/hcO3SfqkFCvfYc+nk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=q/uD6wZdBU9mArbqN61/3/gG3C0z3TtIkFi6vv934BSGo1RY285U+geuNIysK3Pnk VIDcx9g8QzmTUpe07OcyxwjwllWUvWUP8V9hgsZXZtFmYdptskC7s8n3i5RnJ+rycm 8mfpVueDzMWUn69D/A7vNARghiPXV7qNNNatdCtMwKYWSmeYOr9a99gP83Zv5mvYRH i6eNMpxx1BlP4uLi7DVpaQJ7oCd6YCW+PTGX7NEC/Y91uwnhiK4K4232+/0SD/bqec xZ6C71OzI3zpQfZecc70Fs9tRFyCWXM61lfeAM93nR+WpdGRcKWjq1nqfaB3IXnrGA HLJ+FWr0MDsKA== Date: Tue, 09 Apr 2024 17:48:02 -0700 Subject: [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270967939.3631167.6157751007952552705.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson 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 Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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 c98cb468c3578..13aba84bd64af 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 956272d9b302f..677bb2dc9ac91 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 f5993012bf98f..6e09dfcd13e25 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 577b535a595cb..b368e13424c4f 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); + } } } From patchwork Wed Apr 10 00:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623360 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73FC237C for ; Wed, 10 Apr 2024 00:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710098; cv=none; b=Hx0Z+3yKSNZZqW43elTVYXa8O6i9wuZDdIs6Ojap+5LM7n43YBTmQoxWO7e3SFRjPw0GW/klqQR1wVD1fKnbfXS3Yo6dA2PnkIuse5SwQwAkGmrAIJ/D+R2ZPDeT5eB3e2gnyO6xsWMlQHrm47wEssJ+7Qs7jRLTA9uTU4QTGNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710098; c=relaxed/simple; bh=9R6yQlLfuCAAAvEDqJSLaF6pr+p8JuCJfxVRx9oUN/g=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TPqRDpuElRuyp616VxBLWB7Khy/loP8GJwk9MQk2YyorH9MMiaeo00v61MqI9QlXyQ5le+IckpVzu1s//7g1LqMwknZ8Jnfvras9ANG12VuJ3MZyyQHxDG46LQjsJSgivJ9LhMLnu0/B0rthY+IAJIsg8YUv+7+L5i+OxczgP44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lPSgqEGt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lPSgqEGt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 497AAC433C7; Wed, 10 Apr 2024 00:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710098; bh=9R6yQlLfuCAAAvEDqJSLaF6pr+p8JuCJfxVRx9oUN/g=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=lPSgqEGte7BBOcAGnjxSzmWgVojpX9+u/WaFTFoTq8LpKtrT0sI7fQy8xZRe77dbV K/kEnxeH6n0gQkEQN4/EwivWJkiytxDHqyOINtIWa5N2EEvQBLvDa8jTF47YkrrdiG eIyG7F5F1WYRr2tnDzmEyN1+u3YF8ffSTt6gyoNX5aAkNsBv7kCq6qA+lDpaOvTUCl uLu6ocbx7GORtLIouiH7Q2YU9XVk2ArVahpa9r93CyKEC2If3NDsZ6XaUvShfWMl+2 VokrnlAdcrTzScsOx9Qun3iGT9lEiOlLn5zd3EOtEfSMPKL5cVT/380ebLl69hfSTm ExIiTc+a/61nA== Date: Tue, 09 Apr 2024 17:48:17 -0700 Subject: [PATCH 3/7] xfs: Hold inode locks in xfs_ialloc From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270967955.3631167.14088032466565972952.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson Modify xfs_ialloc to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang [djwong: hold the parent ilocked across transaction rolls too] Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_inode.c | 12 +++++++++--- fs/xfs/xfs_qm.c | 4 +++- fs/xfs/xfs_symlink.c | 6 ++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index efd040094753f..2ec005e6c1dab 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -747,6 +747,8 @@ xfs_inode_inherit_flags2( /* * Initialise a newly allocated inode and return the in-core inode to the * caller locked exclusively. + * + * Caller is responsible for unlocking the inode manually upon return */ int xfs_init_new_inode( @@ -873,7 +875,7 @@ xfs_init_new_inode( /* * Log the new values stuffed into the inode. */ - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, ip, 0); xfs_trans_log_inode(tp, ip, flags); /* now that we have an i_mode we can setup the inode structure */ @@ -1101,8 +1103,7 @@ xfs_create( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); error = xfs_dir_createname(tp, dp, name, ip->i_ino, resblks - XFS_IALLOC_SPACE_RES(mp)); @@ -1151,6 +1152,8 @@ xfs_create( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1162,6 +1165,7 @@ xfs_create( * transactions and deadlocks from xfs_inactive. */ if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(ip); xfs_irele(ip); } @@ -1247,6 +1251,7 @@ xfs_create_tmpfile( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -1258,6 +1263,7 @@ xfs_create_tmpfile( * transactions and deadlocks from xfs_inactive. */ if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(ip); xfs_irele(ip); } diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 0f4cf4170c357..47120b745c47f 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -836,8 +836,10 @@ xfs_qm_qino_alloc( ASSERT(xfs_is_shutdown(mp)); xfs_alert(mp, "%s failed (error %d)!", __func__, error); } - if (need_alloc) + if (need_alloc) { + xfs_iunlock(*ipp, XFS_ILOCK_EXCL); xfs_finish_inode_setup(*ipp); + } return error; } diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index fb060aaf6d40f..85ef56fdd7dfe 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c @@ -172,8 +172,7 @@ xfs_symlink( * the transaction cancel unlocking dp so don't do it explicitly in the * error path. */ - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - unlock_dp_on_error = false; + xfs_trans_ijoin(tp, dp, 0); /* * Also attach the dquot(s) to it, if applicable. @@ -215,6 +214,8 @@ xfs_symlink( xfs_qm_dqrele(pdqp); *ipp = ip; + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: @@ -226,6 +227,7 @@ xfs_symlink( * transactions and deadlocks from xfs_inactive. */ if (ip) { + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(ip); xfs_irele(ip); } From patchwork Wed Apr 10 00:48:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623361 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10C5937C for ; Wed, 10 Apr 2024 00:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710114; cv=none; b=JZfVlW2op/n4INFfhiafBtpC3d6xzjJSiwrjA8DQUVx6UD5cHPaCVcpFBXmfX5kYLtBBbzVYZMYPMsNSU41Tr5s6DQ2/hW2divZ4jKvLgwAfIIf1E+Hi1TaBuy/92lgkkBSf3KSvl1kQ2S8dAtLcyIHSHpkCNqCRFmdMrU+FK3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710114; c=relaxed/simple; bh=gRLu6dqJiVtyjY+mQm1VBrVZBKzn+bx6pEsVJVj+qrc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZZQAqgCCGvOqCsTsUK5+7cN1KuyZHb9XS7RCR6KhpEz4E+NET/7BWrrd2Rvcny6h7hMwnzJIYwRH95fjYpSMxA2IF631TMmsSc14cGOtfcH173PYv19PcOoG0IWsq6jcNVwW5bt9K+VLqNee6Yg+T73MtD9Kz4zbgV9WcTHQKwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=izPKK10z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="izPKK10z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE1FCC433F1; Wed, 10 Apr 2024 00:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710113; bh=gRLu6dqJiVtyjY+mQm1VBrVZBKzn+bx6pEsVJVj+qrc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=izPKK10zNfANf7IDC4XcPU/lDP4/clW0flOCPNJuAU+7JC2S2gdxX+kyYGDdO02xi aD7ZR9n4DefxNyiWrYhmMh2d11mjIdlev5Ahos1yoANrLgKloOeVSccKsKktUGwryr hXlDK+ZlinXOOjPCT9rX8qY4srkHsrHLgauOTfCin2DwAZ3B7vnCJm2OMPDoenPJ93 oO6xTGwcy8CSmbEHUik0Cgn76AER01TxEF5/uogDNYn5eRzwNMlvM4uaUZpO03dXRP tL/L64ZWhmIGxGx/K6VrIOZuyw2++yemQzea6mHKG0+Ox3c1bW15UJfd8dqUvv79y3 UylMNS2fHNQcA== Date: Tue, 09 Apr 2024 17:48:33 -0700 Subject: [PATCH 4/7] xfs: Hold inode locks in xfs_trans_alloc_dir From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270967972.3631167.11876713799653099191.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson Modify xfs_trans_alloc_dir to hold locks after return. Caller will be responsible for manual unlock. We will need this later to hold locks across parent pointer operations Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_inode.c | 14 ++++++++++++-- fs/xfs/xfs_trans.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 2ec005e6c1dab..36e1012e156a1 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1368,10 +1368,15 @@ xfs_link( if (xfs_has_wsync(mp) || xfs_has_dirsync(mp)) xfs_trans_set_sync(tp); - return xfs_trans_commit(tp); + error = xfs_trans_commit(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); + return error; error_return: xfs_trans_cancel(tp); + xfs_iunlock(tdp, XFS_ILOCK_EXCL); + xfs_iunlock(sip, XFS_ILOCK_EXCL); std_return: if (error == -ENOSPC && nospace_error) error = nospace_error; @@ -2781,15 +2786,20 @@ xfs_remove( error = xfs_trans_commit(tp); if (error) - goto std_return; + goto out_unlock; if (is_dir && xfs_inode_is_filestream(ip)) xfs_filestream_deassociate(ip); + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); return 0; out_trans_cancel: xfs_trans_cancel(tp); + out_unlock: + xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(dp, XFS_ILOCK_EXCL); std_return: return error; } diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 7350640059cc6..50d878d78a5e1 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -1430,6 +1430,8 @@ xfs_trans_alloc_ichange( * The caller must ensure that the on-disk dquots attached to this inode have * already been allocated and initialized. The ILOCKs will be dropped when the * transaction is committed or cancelled. + * + * Caller is responsible for unlocking the inodes manually upon return */ int xfs_trans_alloc_dir( @@ -1460,8 +1462,8 @@ xfs_trans_alloc_dir( xfs_lock_two_inodes(dp, XFS_ILOCK_EXCL, ip, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, dp, 0); + xfs_trans_ijoin(tp, ip, 0); error = xfs_qm_dqattach_locked(dp, false); if (error) { @@ -1484,6 +1486,9 @@ xfs_trans_alloc_dir( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock(dp, XFS_ILOCK_EXCL); + if (dp != ip) + xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_blockgc_free_quota(dp, 0); retried = true; goto retry; From patchwork Wed Apr 10 00:48:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623362 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B37365CBD for ; Wed, 10 Apr 2024 00:48:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710129; cv=none; b=C0TgpkSfMjAEjS6fum+65tlUnwhMdMfVI0w/3Dv98aguLabUfZe7OX4Ou5vmWkR8XshfiWMfKgNWxwV3SqlggZ8woRVdxwhORnQiO6B7Xo5PrjZVV38YiEA3VCw4LYhjjSKPnEcz69KAXtjrgw7dNGXrqppToIF/PBxcdDYQazk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710129; c=relaxed/simple; bh=PRZ8vMEICfJM+Aexj9+ydXhbkREWMF/x/fENOoNSMgg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PraTDZRxeHKziO9ZeYNeqfQ0KTbFUDJhN8oNNZ/n1lzdGl1dDPH3AazVQXOA8w1VLD1mxP8NE25OKfKJgS+SNIaa0ps2OLhut2KYya7PXsrM9+q4+zGQ15K0aWelMRKsnmdEw//xTtPGALNmORCj7JrQE02W64FkexGEQFeOfT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X8Bs+/GB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X8Bs+/GB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B606C43390; Wed, 10 Apr 2024 00:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710129; bh=PRZ8vMEICfJM+Aexj9+ydXhbkREWMF/x/fENOoNSMgg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=X8Bs+/GBpUqVGoWA4l7s8jxe5AsSPrZR2SYoYv5cmFQT19l3mn5bMJK48jjdqCy4M B0RszQVRRTFFSCZ+2RMVDy5RCE7neSKYtUCMI3NUerq1t9dxCTOyVCJAlBCtzwSPMa 09Q7x5zQ+63yZ0CtaDFDpHtmSP4NaeJKtMPp4Ysqpr0bn3VllXqQZEf1EO+hU9GSSQ 7ezVCVmAF6stV7t785I1BXWTc9ht8po9p6o0EZmAj7k4tpui6veXh9uAtzxfmFUw91 JTxcNExk0oa1eJBAZRcighxcReiPPtd//eTCmRqJgs3p5uqtPfdhjWT7XBPIyotr4e l0LT1NtQGgq8A== Date: Tue, 09 Apr 2024 17:48:49 -0700 Subject: [PATCH 5/7] xfs: Hold inode locks in xfs_rename From: "Darrick J. Wong" To: djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270967988.3631167.14801470316616286607.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Allison Henderson Modify xfs_rename to hold all inode locks across a rename operation We will need this later when we add parent pointers Signed-off-by: Allison Henderson Reviewed-by: Darrick J. Wong Reviewed-by: Catherine Hoang Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_inode.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 36e1012e156a1..2aec7ab59aeb7 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2804,6 +2804,21 @@ xfs_remove( return error; } +static inline void +xfs_iunlock_rename( + struct xfs_inode **i_tab, + int num_inodes) +{ + int i; + + for (i = num_inodes - 1; i >= 0; i--) { + /* Skip duplicate inodes if src and target dps are the same */ + if (!i_tab[i] || (i > 0 && i_tab[i] == i_tab[i - 1])) + continue; + xfs_iunlock(i_tab[i], XFS_ILOCK_EXCL); + } +} + /* * Enter all inodes for a rename transaction into a sorted array. */ @@ -3113,8 +3128,10 @@ xfs_rename( * Attach the dquots to the inodes */ error = xfs_qm_vop_rename_dqattach(inodes); - if (error) - goto out_trans_cancel; + if (error) { + xfs_trans_cancel(tp); + goto out_release_wip; + } /* * Lock all the participating inodes. Depending upon whether @@ -3125,18 +3142,16 @@ xfs_rename( xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); /* - * Join all the inodes to the transaction. From this point on, - * we can rely on either trans_commit or trans_cancel to unlock - * them. + * Join all the inodes to the transaction. */ - xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, src_dp, 0); if (new_parent) - xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); - xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_dp, 0); + xfs_trans_ijoin(tp, src_ip, 0); if (target_ip) - xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, target_ip, 0); if (wip) - xfs_trans_ijoin(tp, wip, XFS_ILOCK_EXCL); + xfs_trans_ijoin(tp, wip, 0); /* * If we are using project inheritance, we only allow renames @@ -3150,10 +3165,13 @@ xfs_rename( } /* RENAME_EXCHANGE is unique from here on. */ - if (flags & RENAME_EXCHANGE) - return xfs_cross_rename(tp, src_dp, src_name, src_ip, + if (flags & RENAME_EXCHANGE) { + error = xfs_cross_rename(tp, src_dp, src_name, src_ip, target_dp, target_name, target_ip, spaceres); + xfs_iunlock_rename(inodes, num_inodes); + return error; + } /* * Try to reserve quota to handle an expansion of the target directory. @@ -3167,6 +3185,7 @@ xfs_rename( if (error == -EDQUOT || error == -ENOSPC) { if (!retried) { xfs_trans_cancel(tp); + xfs_iunlock_rename(inodes, num_inodes); xfs_blockgc_free_quota(target_dp, 0); retried = true; goto retry; @@ -3393,12 +3412,14 @@ xfs_rename( xfs_dir_update_hook(src_dp, wip, 1, src_name); error = xfs_finish_rename(tp); + xfs_iunlock_rename(inodes, num_inodes); if (wip) xfs_irele(wip); return error; out_trans_cancel: xfs_trans_cancel(tp); + xfs_iunlock_rename(inodes, num_inodes); out_release_wip: if (wip) xfs_irele(wip); From patchwork Wed Apr 10 00:49:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623363 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CA72387 for ; Wed, 10 Apr 2024 00:49:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710145; cv=none; b=DBAXSq5xQXLaYvjAZcOKuqdRTJKgOnMk8PCaBqMB5rEIFFf8osWqDNujwVNFwtSDPkAgFg+HmiGJ9lwQTdyqZ+cG7kVzyM0vF52GqrV9oaawT6YNe+HhBv3uVSwGiefQbwx37H4Axc7J7dBjDl1CU3c4i2lRaOgRjayCT9TpFvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710145; c=relaxed/simple; bh=sigUxlnLRZoWH130xrizHBILFy++An7UJGlA3H6ESHA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rB9fNFisOjxdiXJZe3rBEX5jYHTUFvPWM5xgt6oPrCmluiHKHPYtaxRlzmBr4TcJPmOcdRLgcEAZN5p04ltTzlhZKQKh5zzXJnIfLklpRC8PXNjPyuMucB7x/xW6EoZPdxHrBvWgquTPKhsrNbMAv8APBAukpIsbvsf1qJ/JhJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PlzBL32h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PlzBL32h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA47C433F1; Wed, 10 Apr 2024 00:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710145; bh=sigUxlnLRZoWH130xrizHBILFy++An7UJGlA3H6ESHA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=PlzBL32ho6YMJrHfJIlAmQn1SZMkZ+UgzLSQxI6V//rH3xehNf9GC1BOURTm0kvJr 06xaKb3BN7O/xx5jr7ZeiG2nSumNq/omRuHvwlOc7mllZO2sCNBVsDsBM3k7LSqE2A //qXooIabOSEjy0m49sDv01k1Jm0r14DAYUK35AHsK91xEoU+QQqo+YpUf59/25RXF i5dB+HDI4cL0LTxxcxX51FYhiwQDKJmf1lwKTyXmGemzr8stsW6e8gtWJ3LqcAFwq8 huB/O7cON9evTsLfV8nmN9uchzK9LdtJnsJlsn+SdvkrrpegwSiV/x6AtsNvfcXCdB SdOuFOD6we53Q== Date: Tue, 09 Apr 2024 17:49:04 -0700 Subject: [PATCH 6/7] xfs: don't pick up IOLOCK during rmapbt repair scan From: "Darrick J. Wong" To: djwong@kernel.org Cc: catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270968005.3631167.11200418428870190784.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Now that we've fixed the directory operations to hold the ILOCK until they're finished with rmapbt updates for directory shape changes, we no longer need to take this lock when scanning directories for rmapbt records. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/scrub/rmap_repair.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/fs/xfs/scrub/rmap_repair.c b/fs/xfs/scrub/rmap_repair.c index e8e07b683eab6..25acd69614c2c 100644 --- a/fs/xfs/scrub/rmap_repair.c +++ b/fs/xfs/scrub/rmap_repair.c @@ -578,23 +578,9 @@ xrep_rmap_scan_inode( struct xrep_rmap *rr, struct xfs_inode *ip) { - unsigned int lock_mode = 0; + unsigned int lock_mode = xrep_rmap_scan_ilock(ip); int error; - /* - * Directory updates (create/link/unlink/rename) drop the directory's - * ILOCK before finishing any rmapbt updates associated with directory - * shape changes. For this scan to coordinate correctly with the live - * update hook, we must take the only lock (i_rwsem) that is held all - * the way to dir op completion. This will get fixed by the parent - * pointer patchset. - */ - if (S_ISDIR(VFS_I(ip)->i_mode)) { - lock_mode = XFS_IOLOCK_SHARED; - xfs_ilock(ip, lock_mode); - } - lock_mode |= xrep_rmap_scan_ilock(ip); - /* Check the data fork. */ error = xrep_rmap_scan_ifork(rr, ip, XFS_DATA_FORK); if (error) From patchwork Wed Apr 10 00:49:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13623364 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 394CF387 for ; Wed, 10 Apr 2024 00:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710161; cv=none; b=MsqjoMNw97LFaL9SNWw8qlcTEX0+FM1J6c/JwUwZgpDiMGhkwjFvNOHb21DXd+qomzbZjNm7ju/NEU+l38Pl5Smi5BRo5d5AXItJRlFJjNlGE4RmhXVY4IjjCurDNKvZ67k0q3AgnofN8Z6v3GVF8SYsXdZJKi08Ym81kE7zRVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712710161; c=relaxed/simple; bh=vWortD+t4VXVCVqICYf6vmcjQ0DzdCMNCNjNcfiZTRs=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LWADjPYgBPOKBHScYRRzyEgl9Qfw95CNOsKslpnOtS2TcwhHU9fK7aagk9kXMhUYsrOtokKqvL1q1VYOj4Vdc0pkyinjotZ6iG0ky6YUl5fWHjuKGR4dNi08W4QsHZs25Wl4c5MZ4nGg3PsHph7KHJjIeuL7q7fPU7bxVAyW4/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j2hfyvDj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j2hfyvDj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6062C433F1; Wed, 10 Apr 2024 00:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712710160; bh=vWortD+t4VXVCVqICYf6vmcjQ0DzdCMNCNjNcfiZTRs=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=j2hfyvDjMnGN+uaUOWmM3MHrFy8uQZ9ZTrywEP4VNoVC9JNJ27+3NLmVFowioYoz2 TZWG9mrpT6acbAtS9SKPuqCtF0JZdLp5ENa+zwa7ihjAmEPbDHoi/KwqabKPT++1zv FYRLNSDTwrj0mT0LBP98zrOl1hQLsJVBW80q6YBQSsrMGFlGtHASQ38PmYwFizaiqe Czz376vL+s2u7BsCiPCVYbzrA/4HTtzR/72WD/ArR/qFkUAkcj/BAur2tzSBeE8Ixp U5dSNgNauN837ZZW3ak8XMGjvaSaHRPeuARy+Y6gDUCZN4mXtmyNVz0hSqFjErf51K 2wU9368hYzxxQ== Date: Tue, 09 Apr 2024 17:49:20 -0700 Subject: [PATCH 7/7] xfs: unlock new repair tempfiles after creation From: "Darrick J. Wong" To: djwong@kernel.org Cc: catherine.hoang@oracle.com, hch@lst.de, allison.henderson@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171270968021.3631167.3162988716447434676.stgit@frogsfrogsfrogs> In-Reply-To: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> References: <171270967888.3631167.1528096915093261854.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong After creation, drop the ILOCK on temporary files that have been created to stage a repair. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/xfs/scrub/tempfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/scrub/tempfile.c b/fs/xfs/scrub/tempfile.c index c72e447eb8ec3..6f39504a216ea 100644 --- a/fs/xfs/scrub/tempfile.c +++ b/fs/xfs/scrub/tempfile.c @@ -153,6 +153,7 @@ xrep_tempfile_create( xfs_qm_dqrele(pdqp); /* Finish setting up the incore / vfs context. */ + xfs_iunlock(sc->tempip, XFS_ILOCK_EXCL); xfs_setup_iops(sc->tempip); xfs_finish_inode_setup(sc->tempip); @@ -168,6 +169,7 @@ xrep_tempfile_create( * transactions and deadlocks from xfs_inactive. */ if (sc->tempip) { + xfs_iunlock(sc->tempip, XFS_ILOCK_EXCL); xfs_finish_inode_setup(sc->tempip); xchk_irele(sc, sc->tempip); }