2007-09-19 20:20:17

by Eric Sandeen

[permalink] [raw]
Subject: [PATCH e2fsprogs] - ignore bind mounts in fsck

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

The superblock could not be read or does not describe a correct ext2
filesystem. ...

Granted, asking for fsck of a bind mount in the fstab is a bit odd,
but it doesn't seem like it should stop the boot process if you make
this mistake.

Signed-off-by: Eric Sandeen <[email protected]>

Index: e2fsprogs-1.40.2/misc/fsck.c
===================================================================
--- e2fsprogs-1.40.2.orig/misc/fsck.c
+++ e2fsprogs-1.40.2/misc/fsck.c
@@ -867,6 +867,12 @@ static int ignore(struct fs_info *fs)
if (fs->passno == 0)
return 1;

+ /*
+ * If this is a bind mount, ignore it.
+ */
+ if (opt_in_list("bind", fs->opts))
+ return 1;
+
interpret_type(fs);

/*


2007-09-19 20:42:50

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

On Wed, Sep 19, 2007 at 03:20:14PM -0500, Eric Sandeen wrote:
> An entry like this in /etc/fstab:
>
> /foo /bar ext3 bind,defaults 1 3
>
> will stop boot, as fsck.ext3 tries to check it and fails:
>
> e2fsck 1.40.2 (12-Jul-2007)
> fsck.ext3: Is a directory while trying to open /foo
>
> The superblock could not be read or does not describe a correct ext2
> filesystem. ...
>
> Granted, asking for fsck of a bind mount in the fstab is a bit odd,
> but it doesn't seem like it should stop the boot process if you make
> this mistake.

That's fair, but note that the dump number and fsck pass number really
should be zero in the fstab entry. i.e., it really should be "0 0",
or just plain ommitted.

- Ted

2007-09-20 14:32:00

by Eric Sandeen

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

Theodore Tso wrote:
> On Wed, Sep 19, 2007 at 03:20:14PM -0500, Eric Sandeen wrote:
>> An entry like this in /etc/fstab:
>>
>> /foo /bar ext3 bind,defaults 1 3
>>
>> will stop boot, as fsck.ext3 tries to check it and fails:
>>
>> e2fsck 1.40.2 (12-Jul-2007)
>> fsck.ext3: Is a directory while trying to open /foo
>>
>> The superblock could not be read or does not describe a correct ext2
>> filesystem. ...
>>
>> Granted, asking for fsck of a bind mount in the fstab is a bit odd,
>> but it doesn't seem like it should stop the boot process if you make
>> this mistake.
>
> That's fair, but note that the dump number and fsck pass number really
> should be zero in the fstab entry. i.e., it really should be "0 0",
> or just plain ommitted.

Agreed. If you think fsck shouldn't silently cope with this mistake,
and instead punish the user for it (it is what they asked for, after
all), I'm ok with that too. I'm willing to close my end as NOTABUG if
you don't want to take this patch. :)

(FWIW, this is RH bug #151533)

-Eric

2007-09-20 14:42:46

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

On Thu, Sep 20, 2007 at 09:31:56AM -0500, Eric Sandeen wrote:
> Agreed. If you think fsck shouldn't silently cope with this mistake,
> and instead punish the user for it (it is what they asked for, after
> all), I'm ok with that too. I'm willing to close my end as NOTABUG if
> you don't want to take this patch. :)

I'm willing to take the patch, although I am thinking that it might be
appropriate for fsck to print a warning message --- "Bind mount with
non-zero fsck pass, skipping", or some such.

What do you think?

- Ted

2007-09-20 15:12:29

by Eric Sandeen

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

Theodore Tso wrote:
> On Thu, Sep 20, 2007 at 09:31:56AM -0500, Eric Sandeen wrote:
>
>> Agreed. If you think fsck shouldn't silently cope with this mistake,
>> and instead punish the user for it (it is what they asked for, after
>> all), I'm ok with that too. I'm willing to close my end as NOTABUG if
>> you don't want to take this patch. :)
>>
>
> I'm willing to take the patch, although I am thinking that it might be
> appropriate for fsck to print a warning message --- "Bind mount with
> non-zero fsck pass, skipping", or some such.
>
> What do you think?
>
> - Ted
>
Yup, was thinking the same.

----------------

An entry like this in /etc/fstab:

/foo /bar ext3 bind,defaults 1 3

will stop boot, as fsck.ext3 tries to check it and fails:

e2fsck 1.40.2 (12-Jul-2007)
fsck.ext3: Is a directory while trying to open /foo

The superblock could not be read or does not describe a correct ext2
filesystem. ...

Granted, asking for fsck of a bind mount in the fstab is a bit odd,
but it doesn't seem like it should stop the boot process if you make
this mistake.

Signed-off-by: Eric Sandeen <[email protected]>

Index: e2fsprogs-1.40.2/misc/fsck.c
===================================================================
--- e2fsprogs-1.40.2.orig/misc/fsck.c
+++ e2fsprogs-1.40.2/misc/fsck.c
@@ -867,6 +867,16 @@ static int ignore(struct fs_info *fs)
if (fs->passno == 0)
return 1;

+ /*
+ * If this is a bind mount, ignore it.
+ */
+ if (opt_in_list("bind", fs->opts)) {
+ fprintf(stderr,
+ _("Skipping bind mount on %s with nonzero fsck pass\n"),
+ fs->mountpt);
+ return 1;
+ }
+
interpret_type(fs);

/*

2007-09-20 18:59:09

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

It might also be worthwhile to file a documentation bug against the
mount and fstab man pages, since it doesn't currently seem to specify
(at least on my Ubuntu system; maybe it's been fixed in newer upstream
packages) that you can specify the bind option in the fstab file.

/src /dest ext3 bind,default

It's not clear to me that this should be the preferred form. Why not?

/src /dest bind defaults

or


/src /dest none bind,defaults


instead? In any case, how bind mounts are supposed to be specified in
fstab is not documented, and it really should be.

- Ted

2007-09-20 19:08:08

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH e2fsprogs] - ignore bind mounts in fsck

This is what I actually committed into e2fsprogs git, in the maint
branch. Note the one-line summary at the beginning of the patch
description, and the Addresses-Red-Hat-Bugzilla line before the
Signed-off-by lines.

- Ted

commit ed773a263829493e4e4bf612dbec2380cf09349f
Author: Theodore Ts'o <[email protected]>
Date: Thu Sep 20 15:06:35 2007 -0400

fsck: Ignore /etc/fstab entries for bind mounts

If a user specifies a bind mount with a non-zero fsck pass number, for
example:

/foo /bar ext3 bind,defaults 1 3

print a warning and ignore the fstab entry.

Addresses-Red-Hat-Bugzilla: #151533

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

diff --git a/misc/fsck.c b/misc/fsck.c
index 1dcac25..108adf6 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -867,6 +867,16 @@ static int ignore(struct fs_info *fs)
if (fs->passno == 0)
return 1;

+ /*
+ * If this is a bind mount, ignore it.
+ */
+ if (opt_in_list("bind", fs->opts)) {
+ fprintf(stderr,
+ _("%s: skipping bad line in /etc/fstab: bind mount with nonzero fsck pass number\n"),
+ fs->mountpt);
+ return 1;
+ }
+
interpret_type(fs);

/*