linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: Dusty Mabe <dustymabe@redhat.com>
Subject: [PATCH] e2fsck: fix last mount/write time when e2fsck is forced
Date: Mon, 14 Jun 2021 15:27:25 +0200	[thread overview]
Message-ID: <20210614132725.10339-1-lczerner@redhat.com> (raw)

With commit c52d930f e2fsck is no longer able to fix bad last
mount/write time by default because it is conditioned on s_checkinterval
not being zero, which it is by default.

One place where it matters is when other e2fsprogs tools require to run
full file system check before a certain operation. If the last mount
time is for any reason in future, it will not allow it to run even if
full e2fsck is ran.

Fix it by checking the last mount/write time when the e2fsck is forced,
except for the case where we know the system clock is broken.

Fixes: c52d930f ("e2fsck: don't check for future superblock times if checkinterval == 0")
Reported-by: Dusty Mabe <dustymabe@redhat.com>
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 e2fsck/super.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/e2fsck/super.c b/e2fsck/super.c
index e1c3f935..d8c1dcec 100644
--- a/e2fsck/super.c
+++ b/e2fsck/super.c
@@ -1038,9 +1038,10 @@ void check_super_block(e2fsck_t ctx)
 	 * Check to see if the superblock last mount time or last
 	 * write time is in the future.
 	 */
-	if (!broken_system_clock && fs->super->s_checkinterval &&
-	    !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
-	    fs->super->s_mtime > (__u32) ctx->now) {
+	if ((!broken_system_clock && ctx->options & E2F_OPT_FORCE) ||
+	    (!broken_system_clock && fs->super->s_checkinterval &&
+	     !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
+	     fs->super->s_mtime > (__u32) ctx->now)) {
 		pctx.num = fs->super->s_mtime;
 		problem = PR_0_FUTURE_SB_LAST_MOUNT;
 		if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge)
@@ -1050,9 +1051,10 @@ void check_super_block(e2fsck_t ctx)
 			fs->flags |= EXT2_FLAG_DIRTY;
 		}
 	}
-	if (!broken_system_clock && fs->super->s_checkinterval &&
-	    !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
-	    fs->super->s_wtime > (__u32) ctx->now) {
+	if ((!broken_system_clock && ctx->options & E2F_OPT_FORCE) ||
+	    (!broken_system_clock && fs->super->s_checkinterval &&
+	     !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
+	     fs->super->s_wtime > (__u32) ctx->now)) {
 		pctx.num = fs->super->s_wtime;
 		problem = PR_0_FUTURE_SB_LAST_WRITE;
 		if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge)
-- 
2.26.3


             reply	other threads:[~2021-06-14 13:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 13:27 Lukas Czerner [this message]
2021-07-06 20:23 ` [PATCH] e2fsck: fix last mount/write time when e2fsck is forced Theodore Ts'o
2021-07-06 23:52   ` Theodore Ts'o
2021-07-07  8:51     ` Lukas Czerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210614132725.10339-1-lczerner@redhat.com \
    --to=lczerner@redhat.com \
    --cc=dustymabe@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).