From patchwork Sun Feb 25 01:33:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 877490 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mit.edu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=thunk.org header.i=@thunk.org header.b="HN+0HUA3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zpnY90pwzz9s1j for ; Sun, 25 Feb 2018 12:33:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751625AbeBYBdn (ORCPT ); Sat, 24 Feb 2018 20:33:43 -0500 Received: from imap.thunk.org ([74.207.234.97]:51988 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582AbeBYBdl (ORCPT ); Sat, 24 Feb 2018 20:33:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1036FcdQH07+3Gkq5xIkltnfVMnLHb+iC6e7qt6ttP0=; b=HN+0HUA3HnIU3TlmYtSeJmP/yc hQxVNsnAan2w/0ZZHqV+O/hXupz12QOifsR9bc6EUiRNA5GifMH0dWkCzeWiJAi5O7YYC6+9l76B/ CJCjRLxhgY3wFkd9spiJ6qBa8EkjTjvfZtzGHS0tLRr9yDL69MpOQ0EHk3c5Hp6qkku0=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1eplC7-00005J-ED; Sun, 25 Feb 2018 01:33:39 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id 36D477A3EAF; Sat, 24 Feb 2018 20:33:38 -0500 (EST) From: Theodore Ts'o To: Ext4 Developers List Cc: neilb@suse.com, Theodore Ts'o Subject: [PATCH 2/3] tune2fs/fuse2fs/debugfs: after replaying the journal, fix up s_lastcheck Date: Sat, 24 Feb 2018 20:33:24 -0500 Message-Id: <20180225013325.13061-2-tytso@mit.edu> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a In-Reply-To: <20180225013325.13061-1-tytso@mit.edu> References: <20180224222352.GC14111@thunk.org> <20180225013325.13061-1-tytso@mit.edu> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If the file system needs to have the journal replayed, but definition it can't be freshly checked. So if the time when the file system was last checked (s_lastcheck) is before the time it was last mounted (s_mtime), force s_lastcheck to be before s_mtime. This is necessary to make sure some of tune2fs's safety checks work correctly after replaying the journal, since some of tune2fs's operations really require that the file system be self-consistent or grave damage can result. Signed-off-by: Theodore Ts'o --- debugfs/journal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debugfs/journal.c b/debugfs/journal.c index 56a68be52..c16daa5b7 100644 --- a/debugfs/journal.c +++ b/debugfs/journal.c @@ -250,6 +250,12 @@ static void ext2fs_clear_recover(ext2_filsys fs, int error) /* if we had an error doing journal recovery, we need a full fsck */ if (error) fs->super->s_state &= ~EXT2_VALID_FS; + /* + * If we replayed the journal by definition the file system + * was mounted since the last time it was checked + */ + if (fs->super->s_lastcheck >= fs->super->s_mtime) + fs->super->s_lastcheck = fs->super->s_mtime - 1; ext2fs_mark_super_dirty(fs); }