From patchwork Mon Apr 15 23:57:44 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: 13630903 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 BF5D0158DDC for ; Mon, 15 Apr 2024 23:57:44 +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=1713225464; cv=none; b=KbzPe+rUHu1KphRSyV+RtgHMHCdI1M25Q/PNCn3HIgTHC1Splko7OEUxtX9fda04SSmc14Z9CvxrUGlYmDspkpsXGJxeZWWoIOac4O+Tc1JDz3PCY9723pin8FzqU4ucc/ihJY/mHaaLuhUTEkoFNf1WepUmhdiG2NWqi3VS/oQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225464; c=relaxed/simple; bh=joxbJ8u65PdlkQuUD1DXJrgHz3menZxHPYnZGyGkbuw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P5gxlch2vDo2fCI/EP6OASBpR/kjIN9oKsarkPis8Q4E++KbKM8yqG/mOkZ4I2hpYpfoEiUi8dINUc1hBUlYNIp1TXSMRNyuk3xbKQ09u3bHSnzMYf4+acVToMT++tRDj34le0mFtKBapxOnk9A1qd+URcJclWPyAlWjazxr37c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hq4s5ug9; 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="Hq4s5ug9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C7BEC113CC; Mon, 15 Apr 2024 23:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225464; bh=joxbJ8u65PdlkQuUD1DXJrgHz3menZxHPYnZGyGkbuw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Hq4s5ug95gVaL1dSaxI3d4qC6s+mjhLdXxku0LdIWLqLZSl94G36aJAvIKy5GjsLh tuiai5duSgAsBmkXV96Ios+Aj+8q6/engvak6MZATchZb5qPrMI4URX2a3UtKcZ8Te GSxwndIEpzPeFNq5CO/+VX6KPDpQc7Ud9eaKgowvAmEt+H1huLvijwSxB0SOk+va4Y 1jSIgGJxoeTItsfavYThCGaZpZNBUgi3mh4byg3dbwnpBYGFGzz8lG7S3MHFNLRMTC dZibZyIYoN5YB6NIZ9X4ktjOPTrrUoDNwjca4YEU7uZiunwNTfSM2haCi9VId39DG8 OIn2PQNmCdEAA== Date: Mon, 15 Apr 2024 16:57:44 -0700 Subject: [PATCH 1/7] xfs: Increase XFS_DEFER_OPS_NR_INODES to 5 From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386529.92087.280551541697618783.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 061cc01245a9..4a078e07e1a0 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 81cca60d70a3..8b338031e487 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 03dcb4ac0431..efd040094753 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 c74c48bc0945..a6da1ab8ab13 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 Mon Apr 15 23:57:59 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: 13630904 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 A7E81158DDC for ; Mon, 15 Apr 2024 23:58:00 +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=1713225480; cv=none; b=tz+w3bS2KREpy/FD+HEIZ39pbKDgTjj9TWHGQrIrWNm/bUDj/ZcpFhSG4H2bZpAH9Dn/srmfPvgc2lTdjRRtECTByTvLtHsaiv7zEjit6uDUS29wu0YNcF7F3GB6jobDpAm5efdz0CygQUonjyNVCQtNGO8HH67VjBtU04AgaKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225480; c=relaxed/simple; bh=EeaXkCF3ygJNLc6O8I51LoBFrTjBt4rQWmTnPkOhNr0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mw4DAz91EuxAJ1a/q1+GHYGR5EHUiteccD1MBV0o+YBOJsB0qgxB21TByMBpnOB11J6n3TUJKM4T9+7liQbxc6DOUlU5Yv467IevOdvwSpP0mHU98IDN7dRVqkfHH9CvMQxVaRJNqHyvdwn8w/rqzaSLTpNn4ZDTWW7Cfxra+aQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZKb3nm9e; 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="ZKb3nm9e" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30CB4C113CC; Mon, 15 Apr 2024 23:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225480; bh=EeaXkCF3ygJNLc6O8I51LoBFrTjBt4rQWmTnPkOhNr0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ZKb3nm9ecWCCswG/PxqIOW0VXQCojCFNkL3x5Jsk4fqTlCv+CpT0qSrh/SyqRHZoE SCxWD6v6Y3I23PLTrmYzll/XVhBbhoPPl9sBS7Ur9RG8AvDW4JA4vKIbf6POmMbkx/ ZV5n02yAeF5lqWVOKLaOlOHADg7IcBN4ACzAL0+2LhUdr3MNxpf1W+s56igIJCmt/v HA/TZVKtRRche2x7SZxm6nwE5yniSgHDFy0Swox5sMr2HGocTd7LdUhrf2ujlI56cX kpHS5beBPnxhOGd+USph1Y33IhwILOIupDzhqTXXpb4uzdnlMyi5WM1NEclShmZkJ8 GT45+6lnApNIA== Date: Mon, 15 Apr 2024 16:57:59 -0700 Subject: [PATCH 2/7] xfs: Increase XFS_QM_TRANS_MAXDQS to 5 From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Allison Henderson , Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386546.92087.1516726756882199391.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 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); + } } } From patchwork Mon Apr 15 23:58:15 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: 13630905 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 5E910159567 for ; Mon, 15 Apr 2024 23:58:16 +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=1713225496; cv=none; b=dCKpA5FlFMbgfm/jpuqb+gWB3l4rLttxzlMz9pMljUpu2V169mtmIqQpvcl3cFk1MQajaCvpNo+HYwtuIpv0DDu+y6t0MtIUR6RKmrnTMmOO8MoB56J6MzCzXas6ECHVPv9oBj/KiWApO5nfcSB/86vHHwuANeKSwQ8L7QZEdCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225496; c=relaxed/simple; bh=gy8RZJlhGVv4Voy7qPIsTG1/0xX4Z25dJzqlCwalL+Y=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GsW3UUroldpdQqX3HvJliCGmA+xCZ3Lay+eUTGjHI/0FVvSTGboYRyEj6QNsqFxcPYIK+fJ4Xo0fe5yjq2reQzASvQ11CxMILXwOmcGZE9xjYbNMNF9c1MPMBTEiOP9pD5u2Xq+IyxrkpK//ZQiabVVKOyr4MArjkKDobVxtavQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hxOVwM2V; 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="hxOVwM2V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3990C2BD10; Mon, 15 Apr 2024 23:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225495; bh=gy8RZJlhGVv4Voy7qPIsTG1/0xX4Z25dJzqlCwalL+Y=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=hxOVwM2VxDPVLXFr99+X3MPkqth3YHo9LCaySOwX4Kjvkpz+sSVwczfQ8A/tZ/Lcz NVVrZCuUrcveR5jlj1C+uhvmkSs+r0g8aM0SoJHpTEBhSpgQ+piyl5LoPqlxMDhcDF RFYh2o7DISR+4IkEfv+FGFsWABM/tnf5+Py/7De58YJqiQLlyPQ+oQem3IGYnrf8sf ujTQsXO2lizCIBz6sxGe/Mw2UGlKcnt5P6Z8AH6x0Wv3fz7gS27apJ9NpA/hXpQWMF CchrEeRbpdhWvsSra7/38hPhS7paKgOj/IZj+B5im32FL0dlOSEKvVCb1Ln+QW/Ie6 mVV/PRHQ2dv2A== Date: Mon, 15 Apr 2024 16:58:15 -0700 Subject: [PATCH 3/7] xfs: Hold inode locks in xfs_ialloc From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386563.92087.5298943608727895023.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 efd040094753..2ec005e6c1da 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 0f4cf4170c35..47120b745c47 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 fb060aaf6d40..85ef56fdd7df 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 Mon Apr 15 23:58:31 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: 13630906 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 F0FAE158DDC for ; Mon, 15 Apr 2024 23:58:31 +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=1713225512; cv=none; b=U+WzcDw7WsKreJbJbJHxNI5K+lYumTUIFDTREaEXOj3LV6J9A6g0XIGSBLBGddblAtES667vDbm+GRKIWziVXWBOwbrMiTSAnZOjZGl/lyQGj8/5abrHyl1ENKPc1WJWQFlNUw8UNZfhfpS72lwoR/NZGSaHq4On/MM1n6x/2Lw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225512; c=relaxed/simple; bh=ittKhxK65gm5+Zm6PAntzPx2Q6MIaatukZlwJ2BVHI0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LSjbfVUrtftYw9rbmc3WCLTQHAxrna+eGbLorK0xMKbtNX0r7PtLiZonFsikJ4QQv09tHTF+w/vTHwcw4Qm4/+N97d0xbkQ3Hy3W3dhkSnGQQkxDAqXfhi8f4auXGxVtC9Mv5YFEsYN7WJ/hG1C7VieLArNRFg25edN3bklu0ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RKu4dtWh; 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="RKu4dtWh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 829D0C113CC; Mon, 15 Apr 2024 23:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225511; bh=ittKhxK65gm5+Zm6PAntzPx2Q6MIaatukZlwJ2BVHI0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=RKu4dtWheihAqT5IpFmJGJjB3i8UXWG3jesLRktqbIInBPsJV4e7glb+9gnTLdmA8 7+GYjjUH3Hm16ialfBRA5EWFrgBgvc1ZlNeto5MXAurkAZLWQTPD11RqlXJS91GPeN z0AMY9lLFjGn558h/W0JPcbjwe8POigSHInDO2HTVYtkfAg0UpkhmFUTBP//9XR6Qr XNwoK16AD58vBoHQ0dmqxGDNsowbbOUt4TQQ5nzkVrrewx2sgCTwmEZfloogPSNfM/ sQobk3XL5MBHyiddK3lU6kQIhxQ260TypHDliJQHeWeg/ebkXKvbIpfGVediT4GxtF ILkweHbcVMfTA== Date: Mon, 15 Apr 2024 16:58:31 -0700 Subject: [PATCH 4/7] xfs: Hold inode locks in xfs_trans_alloc_dir From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386580.92087.16345030023047245945.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 2ec005e6c1da..36e1012e156a 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 7350640059cc..50d878d78a5e 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 Mon Apr 15 23:58: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: 13630907 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 A9042159900 for ; Mon, 15 Apr 2024 23:58: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=1713225527; cv=none; b=SicEe7Zl4K6IFgQAaEJDzqTp6Rotp7h+wRwpRNC9M3oJ0QSJ2WqPrcKUjKX+gTk9FIl1K9NJ5F5E8+h07FpV7rGPWNs9G7MvHSAW8pW6ECxW5JoD7W3I63/HEKYynjulzhfyLkXQIeoR9ZxLEdx+As/etdOP5E5/tSLkmfD9Ctg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225527; c=relaxed/simple; bh=QTD9c/J0GO64cyezJ/XsuNtaXneLOG46AQWdB+MiI38=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Oai59ysYQVEB7bBMN2ejgsqQDOMEZsvAiEGn18qJqAO3BoKHi/xOsEoK7CGBKuCOryQNoDt50YuesjMEGqEnwZ7yJSf77EtcCUueGj/tAUUpw24lUnW5MpJ7gL2aHXZRiXQoJrVhPlnn/gp2tslde4VmXgPDndLcElJ51zsA3so= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W6qNyWTR; 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="W6qNyWTR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E674C113CC; Mon, 15 Apr 2024 23:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225527; bh=QTD9c/J0GO64cyezJ/XsuNtaXneLOG46AQWdB+MiI38=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=W6qNyWTRuvABsTTAK9Uf77mIaDG76Wy1+leTP69/wxswWTyx2BZ1ZRaqCCYfwky5o pDAd9MWsV2jepIiQls5mqTQly0+d3ilsEpbBu0v6KeAn+H/d2xiTV92eWswX1bEAfw 9Den1DyJbbTllMLq1eITsalNJiOPwddcvZcVxWHqfUD3nAfdfPb7gAp8VlplHCYGmN D2RFA8aflJYZQ67KLleWZ7dJixraft2tNZ+BJ5JYyxqLVfQl7JdjREohy2JHnNlCzW gbcqoRxaYEzqNlpNEYKDfTCGOFZirDQLHUsumywTiPfq1fhrCzwfMQQdmtn3XXcw2F V/ZPnQctzFysw== Date: Mon, 15 Apr 2024 16:58:46 -0700 Subject: [PATCH 5/7] xfs: Hold inode locks in xfs_rename From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Allison Henderson , Catherine Hoang , Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386597.92087.12011283342897372633.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 36e1012e156a..2aec7ab59aeb 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 Mon Apr 15 23:59: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: 13630908 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 5569C54905 for ; Mon, 15 Apr 2024 23:59: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=1713225543; cv=none; b=CBuzY1zfkfzH+P2g9iDQLCO+dTJRBZWTs20FPyOJlMbJUruu9EaiZV1qh1DS5U5Q1+gLTUAuliLKATQ3/IdZsLDIsiMOIfpZrJmndkhmR9fRc5md2r6511IvWVcKtEOteB52G9rLI9o+c2S+BDUHpF5Se05pXHYiySEmslKDdU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225543; c=relaxed/simple; bh=8qgS8zSfYnOtok0d3oedPPCoHi0ZjBC5pA+pvCEHvRg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QgrrSdG3kawtOCKdXv3UNReijoPUoHaPt1+0Tvac9NgN9FAgPdTB8TBYQFecm2BC8POjTC2EP9XtxQR0/A8fTuZIjPWbK1exYibOpsC/+CamlyJ8dYBn/thCZM8pqOxd8rvOTWSzdZve85rSmWBmobIjselWAxhc/gItnlx/16M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vL7gNPrb; 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="vL7gNPrb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC1FC113CC; Mon, 15 Apr 2024 23:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225542; bh=8qgS8zSfYnOtok0d3oedPPCoHi0ZjBC5pA+pvCEHvRg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=vL7gNPrbaIrvuggnzuU5xvbWD3GnHreK48ENNmm3oXCVSEqV6mbMC1jGeVtqoCYc2 RDYjC2B5qBfJAw2F5Oin/eRfCjIU0W832J4D0Qed1adjKLBs7FZHyar12h4fLBU/T1 6wZnk/YbxSq3SpCBElA+P0AGuMZaeloAz/zA/ZIY5Eie+RzN+B3S00YTJRSFJQGcp8 BZ2oPOC7lLj5cLnMQwID2r9ewDIyITmVOFUveVWG5wwuT7FKxHQBUmfobUJSe6wUet owdyzKLZxv92gf4gIt2lFy0sATd1U+AEpo34Z4z2OGo4zYqpOPHn2BWfYOVfDKUrum RjKLbzgeTwRBQ== Date: Mon, 15 Apr 2024 16:59:02 -0700 Subject: [PATCH 6/7] xfs: don't pick up IOLOCK during rmapbt repair scan From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386613.92087.11496615490291969574.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 e8e07b683eab..25acd69614c2 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 Mon Apr 15 23:59: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: 13630909 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 B7F3D2E852 for ; Mon, 15 Apr 2024 23:59: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=1713225558; cv=none; b=J1cy6UsO8s1XmYfgK4sXmyGQUIqmqe9I1y6Q4KQOsTNK6SycfnRTU1wVS188vcWI/z/2fdTjM4db8Uz6FNd606t5aegQYQxWf8SgQl1Kwj/HlGQDT+ptO4NCMCjvzvxsvVbE+31qSmtH/zLZxwcjtUVxAW85irJSKiSJ6SFfB9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713225558; c=relaxed/simple; bh=m+xulR3dysgmpUUHIkzQIx4UXc1TWfuPowYAh/T9Ogo=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iU8izLTip88li9XG9vIFm16AnpyHIPwQrdYXfL2TD/6pNzPs+dii8UEMlwuBazx2yP826YASlCeA1pc9FT6CSTL3qYCYXjFfhbvhJaiCh9df/PG0ojY8IqivEU7SRfeH05YS9vZsKWOjQwIPWkTPfyEWjkrohF3y7e4RYHvVGG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uwqSdqVU; 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="uwqSdqVU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 989E0C113CC; Mon, 15 Apr 2024 23:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713225558; bh=m+xulR3dysgmpUUHIkzQIx4UXc1TWfuPowYAh/T9Ogo=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=uwqSdqVUK76zkCHO7pL/M4VdSDXEZfjYOP6+Sr6JcEwC8v/g84mOz/pYTX2pEGXzX xOfEwsCppzkB89FXh0sea6GkWAGg/KWJlBjSu5ffCTNkbGMn6UBuIGlfYfT9PRHfUn JvX545MNXQFccNKNX2261MulQMemonq0Bt/e/JotBlnBANcLzBsUXXFRJGZZxtfVYj BRCOS4lrKo7Zy1m39atUL3+DSNRkx72KJ64NYr/sTgPjoxatlZq9o05+CK6QwjHb8y VowdN+JXe1Xbq9xr/lEPv/H9+6bjovJHkQeKnioxQxCjRDEVUZK6j+CFce76jHy/oK Xd6dzRq396zBQ== Date: Mon, 15 Apr 2024 16:59:17 -0700 Subject: [PATCH 7/7] xfs: unlock new repair tempfiles after creation From: "Darrick J. Wong" To: chandanbabu@kernel.org, djwong@kernel.org Cc: Christoph Hellwig , hch@lst.de, allison.henderson@oracle.com, catherine.hoang@oracle.com, linux-xfs@vger.kernel.org Message-ID: <171322386630.92087.7506240104067387040.stgit@frogsfrogsfrogs> In-Reply-To: <171322386495.92087.3714112630678704273.stgit@frogsfrogsfrogs> References: <171322386495.92087.3714112630678704273.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 c72e447eb8ec..6f39504a216e 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); }