Patch "xfs: don't write a corrupt unmount record to force summary counter recalc" 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: don't write a corrupt unmount record to force summary counter recalc

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-don-t-write-a-corrupt-unmount-record-to-force-summary-counter-recalc.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 foo@baz Wed Oct 26 04:49:40 PM CEST 2022
From: Chandan Babu R <chandan.babu@xxxxxxxxxx>
Date: Wed, 26 Oct 2022 11:58:38 +0530
Subject: xfs: don't write a corrupt unmount record to force summary counter recalc
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: <20221026062843.927600-22-chandan.babu@xxxxxxxxxx>

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

commit 5cc3c006eb45524860c4d1dd4dd7ad4a506bf3f5 upstream.

[ Modify fs/xfs/xfs_log.c to include the changes at locations suitable for
  5.4-lts kernel ]

In commit f467cad95f5e3, I added the ability to force a recalculation of
the filesystem summary counters if they seemed incorrect.  This was done
(not entirely correctly) by tweaking the log code to write an unmount
record without the UMOUNT_TRANS flag set.  At next mount, the log
recovery code will fail to find the unmount record and go into recovery,
which triggers the recalculation.

What actually gets written to the log is what ought to be an unmount
record, but without any flags set to indicate what kind of record it
actually is.  This worked to trigger the recalculation, but we shouldn't
write bogus log records when we could simply write nothing.

Fixes: f467cad95f5e3 ("xfs: force summary counter recalc at next mount")
Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
Reviewed-by: Brian Foster <bfoster@xxxxxxxxxx>
Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx>
Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/xfs/xfs_log.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -837,19 +837,6 @@ xfs_log_write_unmount_record(
 	if (error)
 		goto out_err;
 
-	/*
-	 * If we think the summary counters are bad, clear the unmount header
-	 * flag in the unmount record so that the summary counters will be
-	 * recalculated during log recovery at next mount.  Refer to
-	 * xlog_check_unmount_rec for more details.
-	 */
-	if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
-			XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
-		xfs_alert(mp, "%s: will fix summary counters at next mount",
-				__func__);
-		flags &= ~XLOG_UNMOUNT_TRANS;
-	}
-
 	/* remove inited flag, and account for space used */
 	tic->t_flags = 0;
 	tic->t_curr_res -= sizeof(magic);
@@ -932,6 +919,19 @@ xfs_log_unmount_write(xfs_mount_t *mp)
 	} while (iclog != first_iclog);
 #endif
 	if (! (XLOG_FORCED_SHUTDOWN(log))) {
+		/*
+		 * If we think the summary counters are bad, avoid writing the
+		 * unmount record to force log recovery at next mount, after
+		 * which the summary counters will be recalculated.  Refer to
+		 * xlog_check_unmount_rec for more details.
+		 */
+		if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS),
+				mp, XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
+			xfs_alert(mp,
+				"%s: will fix summary counters at next mount",
+				__func__);
+			return 0;
+		}
 		xfs_log_write_unmount_record(mp);
 	} else {
 		/*


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

queue-5.4/xfs-check-owner-of-dir3-blocks.patch
queue-5.4/xfs-throttle-commits-on-delayed-background-cil-push.patch
queue-5.4/xfs-factor-common-ail-item-deletion-code.patch
queue-5.4/xfs-remove-the-xfs_dq_logitem_t-typedef.patch
queue-5.4/xfs-fix-buffer-corruption-reporting-when-xfs_dir3_free_header_check-fails.patch
queue-5.4/xfs-xfs_buf_corruption_error-should-take-__this_address.patch
queue-5.4/xfs-open-code-insert-range-extent-split-helper.patch
queue-5.4/xfs-don-t-write-a-corrupt-unmount-record-to-force-summary-counter-recalc.patch
queue-5.4/xfs-check-owner-of-dir3-data-blocks.patch
queue-5.4/xfs-factor-out-quotaoff-intent-ail-removal-and-memory-free.patch
queue-5.4/xfs-trylock-underlying-buffer-on-dquot-flush.patch
queue-5.4/xfs-remove-the-xfs_disk_dquot_t-and-xfs_dquot_t.patch
queue-5.4/xfs-add-a-function-to-deal-with-corrupt-buffers-post-verifiers.patch
queue-5.4/xfs-fix-use-after-free-on-cil-context-on-shutdown.patch
queue-5.4/xfs-tail-updates-only-need-to-occur-when-lsn-changes.patch
queue-5.4/xfs-use-scnprintf-for-avoiding-potential-buffer-overflow.patch
queue-5.4/xfs-move-inode-flush-to-the-sync-workqueue.patch
queue-5.4/xfs-lower-cil-flush-limit-for-large-logs.patch
queue-5.4/xfs-rework-collapse-range-into-an-atomic-operation.patch
queue-5.4/xfs-remove-the-xfs_qoff_logitem_t-typedef.patch
queue-5.4/xfs-fix-unmount-hang-and-memory-leak-on-shutdown-during-quotaoff.patch
queue-5.4/xfs-preserve-default-grace-interval-during-quotacheck.patch
queue-5.4/xfs-replace-function-declaration-by-actual-definition.patch
queue-5.4/xfs-rework-insert-range-into-an-atomic-operation.patch
queue-5.4/xfs-factor-out-a-new-xfs_log_force_inode-helper.patch
queue-5.4/xfs-reflink-should-force-the-log-out-if-mounted-with-wsync.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