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

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