Blame SOURCES/e2fsprogs-1.45.6-e2fsck-fix-last-mount-write-time-when-e2fsck-is-forc.patch

f239de
From b93c62c3d46ed363a88668d41a87500eb5d29f98 Mon Sep 17 00:00:00 2001
f239de
From: Lukas Czerner <lczerner@redhat.com>
f239de
Date: Mon, 14 Jun 2021 15:27:25 +0200
f239de
Subject: [PATCH 26/46] e2fsck: fix last mount/write time when e2fsck is forced
f239de
Content-Type: text/plain
f239de
f239de
With commit c52d930f e2fsck is no longer able to fix bad last
f239de
mount/write time by default because it is conditioned on s_checkinterval
f239de
not being zero, which it is by default.
f239de
f239de
One place where it matters is when other e2fsprogs tools require to run
f239de
full file system check before a certain operation. If the last mount
f239de
time is for any reason in future, it will not allow it to run even if
f239de
full e2fsck is ran.
f239de
f239de
Fix it by checking the last mount/write time when the e2fsck is forced,
f239de
except for the case where we know the system clock is broken.
f239de
f239de
[ Reworked the conditionals so error messages claiming that the last
f239de
  write/mount time were corrupted wouldn't be always printed when the
f239de
  e2fsck was run with the -f option, thus causing 299 out of 372
f239de
  regression tests to fail.  -- TYT ]
f239de
f239de
Fixes: c52d930f ("e2fsck: don't check for future superblock times if checkinterval == 0")
f239de
Reported-by: Dusty Mabe <dustymabe@redhat.com>
f239de
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
f239de
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
f239de
---
f239de
 e2fsck/super.c | 12 ++++++------
f239de
 1 file changed, 6 insertions(+), 6 deletions(-)
f239de
f239de
diff --git a/e2fsck/super.c b/e2fsck/super.c
f239de
index e1c3f935..31e2ffb2 100644
f239de
--- a/e2fsck/super.c
f239de
+++ b/e2fsck/super.c
f239de
@@ -1038,9 +1038,9 @@ void check_super_block(e2fsck_t ctx)
f239de
 	 * Check to see if the superblock last mount time or last
f239de
 	 * write time is in the future.
f239de
 	 */
f239de
-	if (!broken_system_clock && fs->super->s_checkinterval &&
f239de
-	    !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
f239de
-	    fs->super->s_mtime > (__u32) ctx->now) {
f239de
+	if (((ctx->options & E2F_OPT_FORCE) || fs->super->s_checkinterval) &&
f239de
+	    !broken_system_clock && !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
f239de
+	    (fs->super->s_mtime > (__u32) ctx->now)) {
f239de
 		pctx.num = fs->super->s_mtime;
f239de
 		problem = PR_0_FUTURE_SB_LAST_MOUNT;
f239de
 		if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge)
f239de
@@ -1050,9 +1050,9 @@ void check_super_block(e2fsck_t ctx)
f239de
 			fs->flags |= EXT2_FLAG_DIRTY;
f239de
 		}
f239de
 	}
f239de
-	if (!broken_system_clock && fs->super->s_checkinterval &&
f239de
-	    !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
f239de
-	    fs->super->s_wtime > (__u32) ctx->now) {
f239de
+	if (((ctx->options & E2F_OPT_FORCE) || fs->super->s_checkinterval) &&
f239de
+	    !broken_system_clock && !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
f239de
+	    (fs->super->s_wtime > (__u32) ctx->now)) {
f239de
 		pctx.num = fs->super->s_wtime;
f239de
 		problem = PR_0_FUTURE_SB_LAST_WRITE;
f239de
 		if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge)
f239de
-- 
f239de
2.35.1
f239de