2020-07-15 13:20:38

by Jan Kara

[permalink] [raw]
Subject: [PATCH 1/4] ext4: Handle error of ext4_setup_system_zone() on remount

ext4_setup_system_zone() can fail. Handle the failure in ext4_remount().

Signed-off-by: Jan Kara <[email protected]>
---
fs/ext4/super.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 330957ed1f05..8e055ec57a2c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5653,7 +5653,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
ext4_register_li_request(sb, first_not_zeroed);
}

- ext4_setup_system_zone(sb);
+ err = ext4_setup_system_zone(sb);
+ if (err)
+ goto restore_opts;
+
if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
err = ext4_commit_super(sb, 1);
if (err)
--
2.16.4


2020-07-21 10:37:17

by Lukas Czerner

[permalink] [raw]
Subject: Re: [PATCH 1/4] ext4: Handle error of ext4_setup_system_zone() on remount

On Wed, Jul 15, 2020 at 03:18:09PM +0200, Jan Kara wrote:
> ext4_setup_system_zone() can fail. Handle the failure in ext4_remount().
>
> Signed-off-by: Jan Kara <[email protected]>
> ---
> fs/ext4/super.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 330957ed1f05..8e055ec57a2c 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -5653,7 +5653,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
> ext4_register_li_request(sb, first_not_zeroed);
> }
>
> - ext4_setup_system_zone(sb);
> + err = ext4_setup_system_zone(sb);
> + if (err)
> + goto restore_opts;
> +

Thanks Jan, this looks good. But while you're at it, ext4_remount is
missing ext4_release_system_zone() and so it we want to enable block_validity
on remount and it fails after ext4_setup_system_zone() we wont release
it. This *I think* means that we would end up with block_validity
enabled without user knowing about it ?

-Lukas

> if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
> err = ext4_commit_super(sb, 1);
> if (err)
> --
> 2.16.4
>

2020-07-27 11:08:06

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 1/4] ext4: Handle error of ext4_setup_system_zone() on remount

On Tue 21-07-20 12:36:28, Lukas Czerner wrote:
> On Wed, Jul 15, 2020 at 03:18:09PM +0200, Jan Kara wrote:
> > ext4_setup_system_zone() can fail. Handle the failure in ext4_remount().
> >
> > Signed-off-by: Jan Kara <[email protected]>
> > ---
> > fs/ext4/super.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> > index 330957ed1f05..8e055ec57a2c 100644
> > --- a/fs/ext4/super.c
> > +++ b/fs/ext4/super.c
> > @@ -5653,7 +5653,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
> > ext4_register_li_request(sb, first_not_zeroed);
> > }
> >
> > - ext4_setup_system_zone(sb);
> > + err = ext4_setup_system_zone(sb);
> > + if (err)
> > + goto restore_opts;
> > +
>
> Thanks Jan, this looks good. But while you're at it, ext4_remount is
> missing ext4_release_system_zone() and so it we want to enable block_validity
> on remount and it fails after ext4_setup_system_zone() we wont release
> it. This *I think* means that we would end up with block_validity
> enabled without user knowing about it ?

And vice-versa, yes. I'll add a patch that fixes this bug to the series but
it's independent issue. Can I add your reviewed-by for this patch?

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

2020-07-27 11:24:18

by Lukas Czerner

[permalink] [raw]
Subject: Re: [PATCH 1/4] ext4: Handle error of ext4_setup_system_zone() on remount

On Mon, Jul 27, 2020 at 01:02:21PM +0200, Jan Kara wrote:
> On Tue 21-07-20 12:36:28, Lukas Czerner wrote:
> > On Wed, Jul 15, 2020 at 03:18:09PM +0200, Jan Kara wrote:
> > > ext4_setup_system_zone() can fail. Handle the failure in ext4_remount().
> > >
> > > Signed-off-by: Jan Kara <[email protected]>
> > > ---
> > > fs/ext4/super.c | 5 ++++-
> > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> > > index 330957ed1f05..8e055ec57a2c 100644
> > > --- a/fs/ext4/super.c
> > > +++ b/fs/ext4/super.c
> > > @@ -5653,7 +5653,10 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
> > > ext4_register_li_request(sb, first_not_zeroed);
> > > }
> > >
> > > - ext4_setup_system_zone(sb);
> > > + err = ext4_setup_system_zone(sb);
> > > + if (err)
> > > + goto restore_opts;
> > > +
> >
> > Thanks Jan, this looks good. But while you're at it, ext4_remount is
> > missing ext4_release_system_zone() and so it we want to enable block_validity
> > on remount and it fails after ext4_setup_system_zone() we wont release
> > it. This *I think* means that we would end up with block_validity
> > enabled without user knowing about it ?
>
> And vice-versa, yes. I'll add a patch that fixes this bug to the series but
> it's independent issue. Can I add your reviewed-by for this patch?

Yes, of course. You can add

Reviewed-by: Lukas Czerner <[email protected]>

Thanks!
-Lukas

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