2010-11-12 23:09:11

by Bernd Schubert

[permalink] [raw]
Subject: [PATCH] e2fsck: journal-replay-only

e2fsck: journal-replay-only

As recently discussed on [email protected] 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 <[email protected]>


diff --git a/e2fsck/e2fsck.8.in b/e2fsck/e2fsck.8.in
index 3fb15e6..d948f4c 100644
--- a/e2fsck/e2fsck.8.in
+++ b/e2fsck/e2fsck.8.in
@@ -186,6 +186,9 @@ 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 run any further repair action.
+.TP
.BI fragcheck
During pass 1, print a detailed report of any discontiguous blocks for
files in the filesystem.
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index d4df5f3..d8038a5 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -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
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 7eb269c..e3fee9a 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -308,6 +308,10 @@ 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;
@@ -372,6 +376,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);
@@ -594,6 +599,13 @@ 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);
@@ -609,6 +621,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);
}



--
Bernd Schubert
DataDirect Networks


2010-11-13 00:11:14

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On 2010-11-12, at 16:09, Bernd Schubert wrote:
> e2fsck: journal-replay-only
>
> As recently discussed on [email protected] 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 <[email protected]>

I'm definitely in favour of this patch. We've needed something similar as well.

It wouldn't be a terrible idea if tune2fs also would replay the journal on an unmounted filesystem before changing the superblock, if needed, otherwise any changes made to the superblock will be lost (unlike when they are made to the mounted filesystem). That is for a separate patch, however...

> diff --git a/e2fsck/e2fsck.8.in b/e2fsck/e2fsck.8.in
> index 3fb15e6..d948f4c 100644
> --- a/e2fsck/e2fsck.8.in
> +++ b/e2fsck/e2fsck.8.in
> @@ -186,6 +186,9 @@ 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 run any further repair action.
> +.TP
> .BI fragcheck
> During pass 1, print a detailed report of any discontiguous blocks for
> files in the filesystem.
> diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
> index d4df5f3..d8038a5 100644
> --- a/e2fsck/e2fsck.h
> +++ b/e2fsck/e2fsck.h
> @@ -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
> diff --git a/e2fsck/unix.c b/e2fsck/unix.c
> index 7eb269c..e3fee9a 100644
> --- a/e2fsck/unix.c
> +++ b/e2fsck/unix.c
> @@ -308,6 +308,10 @@ 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;
> @@ -372,6 +376,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);
> @@ -594,6 +599,13 @@ 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);
> @@ -609,6 +621,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);
> }
>
>
>
> --
> Bernd Schubert
> DataDirect Networks
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html


Cheers, Andreas






2010-12-06 22:27:16

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On Sat, Nov 13, 2010 at 12:09:07AM +0100, Bernd Schubert wrote:
> e2fsck: journal-replay-only
>
> As recently discussed on [email protected] 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 <[email protected]>

Hi Bernd,

My apologies for the delay. I've made some slight cleanups to your
patch, and committed it to the maint branch. It will be in e2fsprogs
1.41.13.

Thanks!!

- Ted

2010-12-07 15:38:41

by Bernd Schubert

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On 12/06/2010 11:27 PM, Ted Ts'o wrote:
> On Sat, Nov 13, 2010 at 12:09:07AM +0100, Bernd Schubert wrote:
>> e2fsck: journal-replay-only
>>
>> As recently discussed on [email protected] 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 <[email protected]>
>
> Hi Bernd,
>
> My apologies for the delay. I've made some slight cleanups to your
> patch, and committed it to the maint branch. It will be in e2fsprogs
> 1.41.13.

Hello Ted,

thanks! And don't worry please, I'm rather busy either.

It is probably my very limited git knowledge, but I don't any recent
updated in e2fsprogs-git?

bernd@bathl e2fsprogs.git>git pull -v
>From git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs
= [up to date] e2fsprogs-interim -> origin/e2fsprogs-interim
= [up to date] maint -> origin/maint
= [up to date] master -> origin/master
= [up to date] next -> origin/next
= [up to date] pu -> origin/pu
= [up to date] tt/ras -> origin/tt/ras
Already up-to-date.

bernd@bathl e2fsprogs.git>git branch
* maint
master

(maint set up by "git branch --track maint origin/maint")

And the last commit is

commit 73fbe2323af6a2b4d807c80069657bf1449b3bff
Author: Theodore Ts'o <[email protected]>
Date: Fri Sep 24 22:22:09 2010 -0400

libext2fs: Change EXT2_FLAG_DIRECT_IO to avoid conflict with devel
branch

The development branch of e2fsprogs already has a code point assigned
in conflict with EXT2_FLAG_DIRECT_IO. Fix this.

Signed-off-by: "Theodore Ts'o" <[email protected]>


Thanks,
Bernd

2010-12-07 15:59:41

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On Tue, Dec 07, 2010 at 04:38:39PM +0100, Bernd Schubert wrote:
>
> thanks! And don't worry please, I'm rather busy either.
>
> It is probably my very limited git knowledge, but I don't any recent
> updated in e2fsprogs-git?

No, I just hadn't pushed it out yet, my bad. Try again in about 10-15
minutes. (Which is the replication delay between master.kernel.org and
git.kernel.org).

- Ted

2010-12-08 09:23:42

by Bernd Schubert

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On 12/07/2010 04:59 PM, Ted Ts'o wrote:
> On Tue, Dec 07, 2010 at 04:38:39PM +0100, Bernd Schubert wrote:
>>
>> thanks! And don't worry please, I'm rather busy either.
>>
>> It is probably my very limited git knowledge, but I don't any recent
>> updated in e2fsprogs-git?
>
> No, I just hadn't pushed it out yet, my bad. Try again in about 10-15
> minutes. (Which is the replication delay between master.kernel.org and
> git.kernel.org).

Hmm, still nothing. I poked a bit around in
http://www.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/ and also don't see
any recently updated files there.


Thanks,
Bernd

2010-12-08 12:47:59

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only


On Dec 8, 2010, at 4:23 AM, Bernd Schubert wrote:

> Hmm, still nothing. I poked a bit around in
> http://www.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/ and also don't see
> any recently updated files there.

Are you checking the master or maint branch? I will be merging the maint branch into master, but I haven't yet since I'm doing some final patch pulls and testing before I cut 1.41.13.

-- Ted



2010-12-08 12:53:07

by Lukas Czerner

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On Wed, 8 Dec 2010, Theodore Tso wrote:

>
> On Dec 8, 2010, at 4:23 AM, Bernd Schubert wrote:
>
> > Hmm, still nothing. I poked a bit around in
> > http://www.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/ and also don't see
> > any recently updated files there.
>
> Are you checking the master or maint branch? I will be merging the maint branch into master, but I haven't yet since I'm doing some final patch pulls and testing before I cut 1.41.13.
>
> -- Ted

Hi Ted,

I have the same problem, what git mirror are you using ? I am used to
checkout this one:

http://git.kernel.org/?p=fs/ext2/e2fsprogs.git;a=summary

but the latest changes there are from two months ago (even the maint
branch) so I am a bit confused.

Thanks!

-Lukas

>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2010-12-08 15:00:50

by Bernd Schubert

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On 12/08/2010 01:42 PM, Theodore Tso wrote:
>
> On Dec 8, 2010, at 4:23 AM, Bernd Schubert wrote:
>
>> Hmm, still nothing. I poked a bit around in
>> http://www.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/ and also don't see
>> any recently updated files there.
>
> Are you checking the master or maint branch? I will be merging the maint branch into master, but I haven't yet since I'm doing some final patch pulls and testing before I cut 1.41.13.

I checked both already. Even the web interface at
http://git.kernel.org/?p=fs/ext2/e2fsprogs.git;a=summary
does not show any recent updates.

Where did you push to?


Thanks,
Bernd

2010-12-08 23:31:37

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] e2fsck: journal-replay-only

On Wed, Dec 08, 2010 at 04:00:47PM +0100, Bernd Schubert wrote:
>
> I checked both already. Even the web interface at
> http://git.kernel.org/?p=fs/ext2/e2fsprogs.git;a=summary
> does not show any recent updates.

Argh. I pushed locally but I forgot to actually push it out to
kernle.org. I've checked and git.kernel.org's maint branch is now up
to date.

- Ted