]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: add an option which causes it to only do a journal replay
authorBernd Schubert <bs_lists@aakef.fastmail.fm>
Fri, 12 Nov 2010 23:09:07 +0000 (00:09 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 6 Dec 2010 22:15:55 +0000 (17:15 -0500)
As recently discussed on linux-ext4@vger.kernel.org add an option to e2fsck
to allow to replay the journal only. That will allow scripts, such as
pacemakers 'Filesystem' RA to first replay the journal and if that sets
an error state from the journal replay, further check for that error
(dumpe2fh -h | grep "Filesystem state:") and if that shows and error
to refuse to mount. It also allows automatic e2fsck scripts to first
replay the journal and on a second run after the real pass1 to passX checks
to test for the return code.

Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/e2fsck.8.in
e2fsck/e2fsck.h
e2fsck/unix.c

index 3fb15e6d3af62ee7336f7ef692a4f3c065c1ba38..c554717f61d31a5692a0e222d1e05a4280e4044f 100644 (file)
@@ -186,6 +186,10 @@ Set the version of the extended attribute blocks which
 will require while checking the filesystem.  The version number may 
 be 1 or 2.  The default extended attribute version format is 2.
 .TP
+.BI journal_only
+Only replay the journal if required, but do not perform any further checks
+or repairs.
+.TP
 .BI fragcheck
 During pass 1, print a detailed report of any discontiguous blocks for
 files in the filesystem.
index 79266581a8caa7bc25b3b7f16c07ca1f6bed1718..4e7fc72b46b57b42b03ff3a18c08606118dd83a0 100644 (file)
@@ -155,6 +155,7 @@ struct resource_track {
 #define E2F_OPT_WRITECHECK     0x0200
 #define E2F_OPT_COMPRESS_DIRS  0x0400
 #define E2F_OPT_FRAGCHECK      0x0800
+#define E2F_OPT_JOURNAL_ONLY   0x1000 /* only replay the journal */
 
 /*
  * E2fsck flags
index 414dd1166395783135c972e90efd47b78a345892..624e11b5d54a13a79a87e614a92a23f6593e8d76 100644 (file)
@@ -307,6 +307,9 @@ static void check_if_skip(e2fsck_t ctx)
        if ((ctx->options & E2F_OPT_FORCE) || bad_blocks_file || cflag)
                return;
 
+       if (ctx->options & E2F_OPT_JOURNAL_ONLY)
+               goto skip;
+
        lastcheck = fs->super->s_lastcheck;
        if (lastcheck > ctx->now)
                lastcheck -= ctx->time_fudge;
@@ -370,6 +373,7 @@ static void check_if_skip(e2fsck_t ctx)
                        printf(_(" (check in %ld mounts)"), next_check);
        }
        fputc('\n', stdout);
+skip:
        ext2fs_close(fs);
        ctx->fs = NULL;
        e2fsck_free_context(ctx);
@@ -592,6 +596,12 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
                } else if (strcmp(token, "fragcheck") == 0) {
                        ctx->options |= E2F_OPT_FRAGCHECK;
                        continue;
+               } else if (strcmp(token, "journal_only") == 0) {
+                       if (arg) {
+                               extended_usage++;
+                               continue;
+                       }
+                       ctx->options |= E2F_OPT_JOURNAL_ONLY;
                } else {
                        fprintf(stderr, _("Unknown extended option: %s\n"),
                                token);
@@ -607,6 +617,7 @@ static void parse_extended_opts(e2fsck_t ctx, const char *opts)
                       "Valid extended options are:\n"), stderr);
                fputs(("\tea_ver=<ea_version (1 or 2)>\n"), stderr);
                fputs(("\tfragcheck\n"), stderr);
+               fputs(("\tjournal_only\n"), stderr);
                fputc('\n', stderr);
                exit(1);
        }