Patch "xfs: clean up xfs_bui_item_recover iget/trans_alloc/ilock ordering" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    xfs: clean up xfs_bui_item_recover iget/trans_alloc/ilock ordering

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xfs-clean-up-xfs_bui_item_recover-iget-trans_alloc-ilock-ordering.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From chandan.babu@xxxxxxxxxx Thu Feb 16 06:22:24 2023
From: Chandan Babu R <chandan.babu@xxxxxxxxxx>
Date: Thu, 16 Feb 2023 10:50:09 +0530
Subject: xfs: clean up xfs_bui_item_recover iget/trans_alloc/ilock ordering
To: gregkh@xxxxxxxxxxxxxxxxxxx
Cc: sashal@xxxxxxxxxx, mcgrof@xxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, djwong@xxxxxxxxxx, chandan.babu@xxxxxxxxxx, amir73il@xxxxxxxxx, leah.rumancik@xxxxxxxxx
Message-ID: <20230216052019.368896-16-chandan.babu@xxxxxxxxxx>

From: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>

commit 64a3f3315bc60f710a0a25c1798ac0ea58c6fa1f upstream.

In most places in XFS, we have a specific order in which we gather
resources: grab the inode, allocate a transaction, then lock the inode.
xfs_bui_item_recover doesn't do it in that order, so fix it to be more
consistent.  This also makes the error bailout code a bit less weird.

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>
Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx>
Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/xfs/xfs_bmap_item.c |   38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -22,6 +22,7 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_trans_space.h"
 #include "xfs_error.h"
+#include "xfs_quota.h"
 
 kmem_zone_t	*xfs_bui_zone;
 kmem_zone_t	*xfs_bud_zone;
@@ -488,21 +489,26 @@ xfs_bui_recover(
 		return -EFSCORRUPTED;
 	}
 
-	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
-			XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);
+	/* Grab the inode. */
+	error = xfs_iget(mp, NULL, bmap->me_owner, 0, 0, &ip);
 	if (error)
 		return error;
 
-	budp = xfs_trans_get_bud(tp, buip);
-
-	/* Grab the inode. */
-	error = xfs_iget(mp, tp, bmap->me_owner, 0, XFS_ILOCK_EXCL, &ip);
+	error = xfs_qm_dqattach(ip);
 	if (error)
-		goto err_inode;
+		goto err_rele;
 
 	if (VFS_I(ip)->i_nlink == 0)
 		xfs_iflags_set(ip, XFS_IRECOVERY);
 
+	/* Allocate transaction and do the work. */
+	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate,
+			XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK), 0, 0, &tp);
+	if (error)
+		goto err_rele;
+
+	budp = xfs_trans_get_bud(tp, buip);
+	xfs_ilock(ip, XFS_ILOCK_EXCL);
 	xfs_trans_ijoin(tp, ip, 0);
 
 	count = bmap->me_len;
@@ -510,7 +516,7 @@ xfs_bui_recover(
 			whichfork, bmap->me_startoff, bmap->me_startblock,
 			&count, state);
 	if (error)
-		goto err_inode;
+		goto err_cancel;
 
 	if (count > 0) {
 		ASSERT(bui_type == XFS_BMAP_UNMAP);
@@ -522,16 +528,20 @@ xfs_bui_recover(
 	}
 
 	set_bit(XFS_BUI_RECOVERED, &buip->bui_flags);
+	/* Commit transaction, which frees the transaction. */
 	error = xfs_defer_ops_capture_and_commit(tp, capture_list);
+	if (error)
+		goto err_unlock;
+
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	xfs_irele(ip);
-	return error;
+	return 0;
 
-err_inode:
+err_cancel:
 	xfs_trans_cancel(tp);
-	if (ip) {
-		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		xfs_irele(ip);
-	}
+err_unlock:
+	xfs_iunlock(ip, XFS_ILOCK_EXCL);
+err_rele:
+	xfs_irele(ip);
 	return error;
 }


Patches currently in stable-queue which might be from chandan.babu@xxxxxxxxxx are

queue-5.4/xfs-remove-the-xfs_efd_log_item_t-typedef.patch
queue-5.4/xfs-change-the-order-in-which-child-and-parent-defer-ops-are-finished.patch
queue-5.4/xfs-refactor-xfs_defer_finish_noroll.patch
queue-5.4/xfs-sync-lazy-sb-accounting-on-quiesce-of-read-only-mounts.patch
queue-5.4/xfs-clean-up-xfs_bui_item_recover-iget-trans_alloc-ilock-ordering.patch
queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-block-reservations.patch
queue-5.4/xfs-factor-out-a-xfs_defer_create_intent-helper.patch
queue-5.4/xfs-turn-dfp_intent-into-a-xfs_log_item.patch
queue-5.4/xfs-fix-finobt-btree-block-recovery-ordering.patch
queue-5.4/xfs-xfs_defer_capture-should-absorb-remaining-transaction-reservation.patch
queue-5.4/xfs-merge-the-diff_items-defer-op-into-create_intent.patch
queue-5.4/xfs-prevent-uaf-in-xfs_log_item_in_current_chkpt.patch
queue-5.4/xfs-fix-missing-cow-blocks-writeback-conversion-retry.patch
queue-5.4/xfs-remove-the-xfs_efi_log_item_t-typedef.patch
queue-5.4/xfs-only-relog-deferred-intent-items-if-free-space-in-the-log-gets-low.patch
queue-5.4/xfs-proper-replay-of-deferred-ops-queued-during-log-recovery.patch
queue-5.4/xfs-clean-up-bmap-intent-item-recovery-checking.patch
queue-5.4/xfs-fix-the-forward-progress-assertion-in-xfs_iwalk_run_callbacks.patch
queue-5.4/xfs-log-new-intent-items-created-as-part-of-finishing-recovered-intent-items.patch
queue-5.4/xfs-ensure-inobt-record-walks-always-make-forward-progress.patch
queue-5.4/xfs-remove-the-xfs_inode_log_item_t-typedef.patch
queue-5.4/xfs-fix-an-incore-inode-uaf-in-xfs_bui_recover.patch
queue-5.4/xfs-expose-the-log-push-threshold.patch
queue-5.4/xfs-periodically-relog-deferred-intent-items.patch
queue-5.4/xfs-merge-the-log_item-defer-op-into-create_intent.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux