Skip to content

Commit 5cc3c00

Browse files
committed
xfs: don't write a corrupt unmount record to force summary counter recalc
In commit f467cad, 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: f467cad ("xfs: force summary counter recalc at next mount") Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]>
1 parent 5806165 commit 5cc3c00

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

fs/xfs/xfs_log.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -835,19 +835,6 @@ xlog_unmount_write(
835835
if (error)
836836
goto out_err;
837837

838-
/*
839-
* If we think the summary counters are bad, clear the unmount header
840-
* flag in the unmount record so that the summary counters will be
841-
* recalculated during log recovery at next mount. Refer to
842-
* xlog_check_unmount_rec for more details.
843-
*/
844-
if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
845-
XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
846-
xfs_alert(mp, "%s: will fix summary counters at next mount",
847-
__func__);
848-
flags &= ~XLOG_UNMOUNT_TRANS;
849-
}
850-
851838
error = xlog_write_unmount_record(log, tic, &lsn, flags);
852839
/*
853840
* At this point, we're umounting anyway, so there's no point in
@@ -913,6 +900,20 @@ xfs_log_unmount_write(
913900

914901
if (XLOG_FORCED_SHUTDOWN(log))
915902
return;
903+
904+
/*
905+
* If we think the summary counters are bad, avoid writing the unmount
906+
* record to force log recovery at next mount, after which the summary
907+
* counters will be recalculated. Refer to xlog_check_unmount_rec for
908+
* more details.
909+
*/
910+
if (XFS_TEST_ERROR(xfs_fs_has_sickness(mp, XFS_SICK_FS_COUNTERS), mp,
911+
XFS_ERRTAG_FORCE_SUMMARY_RECALC)) {
912+
xfs_alert(mp, "%s: will fix summary counters at next mount",
913+
__func__);
914+
return;
915+
}
916+
916917
xfs_log_unmount_verify_iclog(log);
917918
xlog_unmount_write(log);
918919
}

0 commit comments

Comments
 (0)