2010-09-26 22:40:23

by Maciej Żenczykowski

[permalink] [raw]
Subject: [PATCH 1/2] ext3: don't update sb journal_devnum when RO dev

An ext3 filesystem on a read-only device, with an external journal
which is at a different device number then recorded in the superblock
will fail to honor the read-only setting of the device and trigger
a superblock update (write).

For example:
- ext3 on a software raid which is in read-only mode
- external journal on a read-write device which has changed device num
- attempt to mount with -o journal_dev=<new_number>
- hits BUG_ON(mddev->ro = 1) in md.c

Cc: Theodore Ts'o <[email protected]>
Signed-off-by: Maciej Żenczykowski <[email protected]>
---
fs/ext3/super.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 5dbf4db..19dfbe9 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2299,7 +2299,7 @@ static int ext3_load_journal(struct super_block *sb,
EXT3_SB(sb)->s_journal = journal;
ext3_clear_journal_err(sb, es);

- if (journal_devnum &&
+ if (!really_read_only && journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
es->s_journal_dev = cpu_to_le32(journal_devnum);

--
1.7.2.3


2010-09-26 22:40:54

by Maciej Żenczykowski

[permalink] [raw]
Subject: [PATCH 2/2] ext4: don't update sb journal_devnum when RO dev

An ext4 filesystem on a read-only device, with an external journal
which is at a different device number then recorded in the superblock
will fail to honor the read-only setting of the device and trigger
a superblock update (write).

For example:
- ext4 on a software raid which is in read-only mode
- external journal on a read-write device which has changed device num
- attempt to mount with -o journal_dev=<new_number>
- hits BUG_ON(mddev->ro = 1) in md.c

Cc: Theodore Ts'o <[email protected]>
Signed-off-by: Maciej Żenczykowski <[email protected]>
---
fs/ext4/super.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2614774..48388c7 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3470,7 +3470,7 @@ static int ext4_load_journal(struct super_block *sb,
EXT4_SB(sb)->s_journal = journal;
ext4_clear_journal_err(sb, es);

- if (journal_devnum &&
+ if (!really_read_only && journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
es->s_journal_dev = cpu_to_le32(journal_devnum);

--
1.7.2.3

2010-11-08 01:09:25

by Maciej Żenczykowski

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext3: don't update sb journal_devnum when RO dev

2010/9/26 Maciej Żenczykowski <[email protected]>:
> An ext3 filesystem on a read-only device, with an external journal
> which is at a different device number then recorded in the superblock
> will fail to honor the read-only setting of the device and trigger
> a superblock update (write).
>
> For example:
>  - ext3 on a software raid which is in read-only mode
>  - external journal on a read-write device which has changed device num
>  - attempt to mount with -o journal_dev=<new_number>
>  - hits BUG_ON(mddev->ro = 1) in md.c
>
> Cc: Theodore Ts'o <[email protected]>
> Signed-off-by: Maciej Żenczykowski <[email protected]>
> ---
>  fs/ext3/super.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ext3/super.c b/fs/ext3/super.c
> index 5dbf4db..19dfbe9 100644
> --- a/fs/ext3/super.c
> +++ b/fs/ext3/super.c
> @@ -2299,7 +2299,7 @@ static int ext3_load_journal(struct super_block *sb,
>        EXT3_SB(sb)->s_journal = journal;
>        ext3_clear_journal_err(sb, es);
>
> -       if (journal_devnum &&
> +       if (!really_read_only && journal_devnum &&
>            journal_devnum != le32_to_cpu(es->s_journal_dev)) {
>                es->s_journal_dev = cpu_to_le32(journal_devnum);
>
> --
> 1.7.2.3
>
>

While I can see the ext4 patch at:

http://git.kernel.org/?p=linux/kernel/git/tytso/ext4.git;a=shortlog

I can't find the ext3 patch. Did it get missed?

Maciej

2010-11-08 12:15:07

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/2] ext3: don't update sb journal_devnum when RO dev

On Sun 07-11-10 17:09:24, Maciej Żenczykowski wrote:
> 2010/9/26 Maciej Żenczykowski <[email protected]>:
> > An ext3 filesystem on a read-only device, with an external journal
> > which is at a different device number then recorded in the superblock
> > will fail to honor the read-only setting of the device and trigger
> > a superblock update (write).
> >
> > For example:
> >  - ext3 on a software raid which is in read-only mode
> >  - external journal on a read-write device which has changed device num
> >  - attempt to mount with -o journal_dev=<new_number>
> >  - hits BUG_ON(mddev->ro = 1) in md.c
> >
> > Cc: Theodore Ts'o <[email protected]>
> > Signed-off-by: Maciej Żenczykowski <[email protected]>
> > ---
> >  fs/ext3/super.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/fs/ext3/super.c b/fs/ext3/super.c
> > index 5dbf4db..19dfbe9 100644
> > --- a/fs/ext3/super.c
> > +++ b/fs/ext3/super.c
> > @@ -2299,7 +2299,7 @@ static int ext3_load_journal(struct super_block *sb,
> >        EXT3_SB(sb)->s_journal = journal;
> >        ext3_clear_journal_err(sb, es);
> >
> > -       if (journal_devnum &&
> > +       if (!really_read_only && journal_devnum &&
> >            journal_devnum != le32_to_cpu(es->s_journal_dev)) {
> >                es->s_journal_dev = cpu_to_le32(journal_devnum);
> >
> > --
> > 1.7.2.3
> >
> >
>
> While I can see the ext4 patch at:
>
> http://git.kernel.org/?p=linux/kernel/git/tytso/ext4.git;a=shortlog
>
> I can't find the ext3 patch. Did it get missed?
Yes, it seems so. I'm taking care of ext3 so please CC me directly for
ext3 fixes. Thanks! I'll merge this fix.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR