xfs: don't write a corrupt unmount record to force summary counter recalc
PATCH 1/1 xfs: don't write a corrupt unmount record to force summary counter recalc
From: Darrick J. Wong <[email protected]>
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.
--- fs/xfs/xfs_log.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
fs/xfs/xfs_log.c +14 -13
@@ -835,19 +835,6 @@ xlog_unmount_write(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 ; - } - error =xlog_write_unmount_record (log, tic, &lsn, flags);/* * At this point, we're umounting anyway, so there's no point in
@@ -913,6 +900,20 @@ xfs_log_unmount_write(if (XLOG_FORCED_SHUTDOWN (log))return ; + +/* +* 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 ; + } +xfs_log_unmount_verify_iclog (log);xlog_unmount_write (log); }
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 theUMOUNT_TRANSflag set. At next mount, the log recovery code will fail to find the unmount record and go into recovery, which triggers the recalculation.
Quoted 7 lines
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 <[email protected]>
Looks good (assuming the "xfs: refactor unmount record writing" is applied):
Quoted 9 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 theUMOUNT_TRANSflag set. At next mount, the log recovery code will fail to find the unmount record and go into recovery, which triggers the recalculation.
Quoted 8 lines
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 <[email protected]>---
Quoted 49 lines
fs/xfs/xfs_log.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)fs/xfs/xfs_log.c +14
-13@@ -835,19 +835,6 @@ xlog_unmount_write(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 ; - } - error =xlog_write_unmount_record (log, tic, &lsn, flags);/* * At this point, we're umounting anyway, so there's no point in @@ -913,6 +900,20 @@ xfs_log_unmount_write(if (XLOG_FORCED_SHUTDOWN (log))return ; + +/* +* 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 ; + } +xfs_log_unmount_verify_iclog (log);xlog_unmount_write (log); }
Quoted 14 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
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 theUMOUNT_TRANSflag 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.
Quoted 5 lines
Fixes f467cad95f5e3 ("xfs: force summary counter recalc at next mount")Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_log.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
Looks fine.
Signature · 2 lines
Dave Chinner [email protected]