All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
@ 2021-12-21 12:32 Ye Bin
  2021-12-21 14:43 ` Lukas Czerner
  0 siblings, 1 reply; 12+ messages in thread
From: Ye Bin @ 2021-12-21 12:32 UTC (permalink / raw)
  To: tytso, adilger.kernel, linux-ext4; +Cc: linux-kernel, jack, Ye Bin

We test remount with 'abort' option as follows:
[root@localhost home]# mount  /dev/sda test
[root@localhost home]# mount | grep test
/dev/sda on /home/test type ext4 (rw,relatime)
[root@localhost home]# mount -o remount,abort test
[root@localhost home]# mount | grep test
/dev/sda on /home/test type ext4 (rw,relatime)

Obviously, remount 'abort' option isn't effective.
After 6e47a3cc68fc commit we process abort option with 'ctx_set_mount_flags':
static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int flag)
{
	ctx->mask_s_mount_flags |= flag;
	ctx->vals_s_mount_flags |= flag;
}

But we test 'abort' option with 'ext4_test_mount_flag':
static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
{
        return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
}

To solve this issue, pass (1 <<  EXT4_MF_FS_ABORTED) to 'ctx_set_mount_flags'.

Fixes:6e47a3cc68fc("ext4: get rid of super block and sbi from handle_mount_ops()")
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 fs/ext4/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b72d989b77fb..071b7b3c5678 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2236,7 +2236,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 			 param->key);
 		return 0;
 	case Opt_abort:
-		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
+		ctx_set_mount_flags(ctx, 1 << EXT4_MF_FS_ABORTED);
 		return 0;
 	case Opt_i_version:
 		ctx_set_flags(ctx, SB_I_VERSION);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
  2021-12-21 12:32 [PATCH -next] ext4: Fix remount with 'abort' option isn't effective Ye Bin
@ 2021-12-21 14:43 ` Lukas Czerner
  2021-12-22  1:06   ` yebin
  0 siblings, 1 reply; 12+ messages in thread
From: Lukas Czerner @ 2021-12-21 14:43 UTC (permalink / raw)
  To: Ye Bin; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, jack

Hi,

nice catch. This is a bug indeed. However I am currently in a process of
changing the ctx_set/clear/test_ helpers because currently it generates
functions that are unused.

While I am at it I can just create a custom ctx_set_mount_flags()
helper that would behave as expected so that we won't have to specify
"1 < EXT4_MF_FS_ABORTED" which is not really obvious and hence error
prone.

My plan is to send my patch set including this one tomorrow, will that
be fine with you ?

-Lukas

On Tue, Dec 21, 2021 at 08:32:14PM +0800, Ye Bin wrote:
> We test remount with 'abort' option as follows:
> [root@localhost home]# mount  /dev/sda test
> [root@localhost home]# mount | grep test
> /dev/sda on /home/test type ext4 (rw,relatime)
> [root@localhost home]# mount -o remount,abort test
> [root@localhost home]# mount | grep test
> /dev/sda on /home/test type ext4 (rw,relatime)
> 
> Obviously, remount 'abort' option isn't effective.
> After 6e47a3cc68fc commit we process abort option with 'ctx_set_mount_flags':
> static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int flag)
> {
> 	ctx->mask_s_mount_flags |= flag;
> 	ctx->vals_s_mount_flags |= flag;
> }
> 
> But we test 'abort' option with 'ext4_test_mount_flag':
> static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
> {
>         return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
> }
> 
> To solve this issue, pass (1 <<  EXT4_MF_FS_ABORTED) to 'ctx_set_mount_flags'.
> 
> Fixes:6e47a3cc68fc("ext4: get rid of super block and sbi from handle_mount_ops()")
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
>  fs/ext4/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index b72d989b77fb..071b7b3c5678 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2236,7 +2236,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  			 param->key);
>  		return 0;
>  	case Opt_abort:
> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
> +		ctx_set_mount_flags(ctx, 1 << EXT4_MF_FS_ABORTED);
>  		return 0;
>  	case Opt_i_version:
>  		ctx_set_flags(ctx, SB_I_VERSION);
> -- 
> 2.31.1
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
  2021-12-21 14:43 ` Lukas Czerner
@ 2021-12-22  1:06   ` yebin
  2021-12-22  9:19     ` Lukas Czerner
  0 siblings, 1 reply; 12+ messages in thread
From: yebin @ 2021-12-22  1:06 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, jack



On 2021/12/21 22:43, Lukas Czerner wrote:
> Hi,
>
> nice catch. This is a bug indeed. However I am currently in a process of
> changing the ctx_set/clear/test_ helpers because currently it generates
> functions that are unused.
>
> While I am at it I can just create a custom ctx_set_mount_flags()
> helper that would behave as expected so that we won't have to specify
> "1 < EXT4_MF_FS_ABORTED" which is not really obvious and hence error
> prone.
Actually, I fixed the first version as follows:

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b72d989b77fb..199920ffc7d3 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2049,8 +2049,8 @@ struct ext4_fs_context {
  	unsigned int	mask_s_mount_opt;
  	unsigned int	vals_s_mount_opt2;
  	unsigned int	mask_s_mount_opt2;
-	unsigned int	vals_s_mount_flags;
-	unsigned int	mask_s_mount_flags;
+	unsigned long	vals_s_mount_flags;
+	unsigned long	mask_s_mount_flags;
  	unsigned int	opt_flags;	/* MOPT flags */
  	unsigned int	spec;
  	u32		s_max_batch_time;
@@ -2166,7 +2166,12 @@ static inline bool ctx_test_##name(struct ext4_fs_context *ctx, int flag)\
  EXT4_SET_CTX(flags);
  EXT4_SET_CTX(mount_opt);
  EXT4_SET_CTX(mount_opt2);
-EXT4_SET_CTX(mount_flags);
+
+static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int bit)
+{
+	set_bit(bit, &ctx->mask_s_mount_flags);
+	set_bit(bit, &ctx->vals_s_mount_flags);
+}


I think 'mask_s_mount_flags' is useless now.
>
> My plan is to send my patch set including this one tomorrow, will that
> be fine with you ?
>
> -Lukas
>
> On Tue, Dec 21, 2021 at 08:32:14PM +0800, Ye Bin wrote:
>> We test remount with 'abort' option as follows:
>> [root@localhost home]# mount  /dev/sda test
>> [root@localhost home]# mount | grep test
>> /dev/sda on /home/test type ext4 (rw,relatime)
>> [root@localhost home]# mount -o remount,abort test
>> [root@localhost home]# mount | grep test
>> /dev/sda on /home/test type ext4 (rw,relatime)
>>
>> Obviously, remount 'abort' option isn't effective.
>> After 6e47a3cc68fc commit we process abort option with 'ctx_set_mount_flags':
>> static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int flag)
>> {
>> 	ctx->mask_s_mount_flags |= flag;
>> 	ctx->vals_s_mount_flags |= flag;
>> }
>>
>> But we test 'abort' option with 'ext4_test_mount_flag':
>> static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
>> {
>>          return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
>> }
>>
>> To solve this issue, pass (1 <<  EXT4_MF_FS_ABORTED) to 'ctx_set_mount_flags'.
>>
>> Fixes:6e47a3cc68fc("ext4: get rid of super block and sbi from handle_mount_ops()")
>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>> ---
>>   fs/ext4/super.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index b72d989b77fb..071b7b3c5678 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -2236,7 +2236,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>>   			 param->key);
>>   		return 0;
>>   	case Opt_abort:
>> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
>> +		ctx_set_mount_flags(ctx, 1 << EXT4_MF_FS_ABORTED);
>>   		return 0;
>>   	case Opt_i_version:
>>   		ctx_set_flags(ctx, SB_I_VERSION);
>> -- 
>> 2.31.1
>>
> .
>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
  2021-12-22  1:06   ` yebin
@ 2021-12-22  9:19     ` Lukas Czerner
  2021-12-23  1:41       ` yebin
  0 siblings, 1 reply; 12+ messages in thread
From: Lukas Czerner @ 2021-12-22  9:19 UTC (permalink / raw)
  To: yebin; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, jack

On Wed, Dec 22, 2021 at 09:06:22AM +0800, yebin wrote:
> 
> 
> On 2021/12/21 22:43, Lukas Czerner wrote:
> > Hi,
> > 
> > nice catch. This is a bug indeed. However I am currently in a process of
> > changing the ctx_set/clear/test_ helpers because currently it generates
> > functions that are unused.
> > 
> > While I am at it I can just create a custom ctx_set_mount_flags()
> > helper that would behave as expected so that we won't have to specify
> > "1 < EXT4_MF_FS_ABORTED" which is not really obvious and hence error
> > prone.
> Actually, I fixed the first version as follows:

Allright, this looks better.

> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index b72d989b77fb..199920ffc7d3 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2049,8 +2049,8 @@ struct ext4_fs_context {
>  	unsigned int	mask_s_mount_opt;
>  	unsigned int	vals_s_mount_opt2;
>  	unsigned int	mask_s_mount_opt2;
> -	unsigned int	vals_s_mount_flags;
> -	unsigned int	mask_s_mount_flags;
> +	unsigned long	vals_s_mount_flags;
> +	unsigned long	mask_s_mount_flags;
>  	unsigned int	opt_flags;	/* MOPT flags */
>  	unsigned int	spec;
>  	u32		s_max_batch_time;
> @@ -2166,7 +2166,12 @@ static inline bool ctx_test_##name(struct ext4_fs_context *ctx, int flag)\
>  EXT4_SET_CTX(flags);
>  EXT4_SET_CTX(mount_opt);
>  EXT4_SET_CTX(mount_opt2);
> -EXT4_SET_CTX(mount_flags);
> +
> +static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int bit)

Maybe ctx_set_mount_flag since you can't really set more than one this
way?

> +{
> +	set_bit(bit, &ctx->mask_s_mount_flags);
> +	set_bit(bit, &ctx->vals_s_mount_flags);
> +}
> 
> 
> I think 'mask_s_mount_flags' is useless now.

So how would we know what flags have changed ? Sure, there is currently
no need to clear the flag but that can come in future and once it does
we'll only need to create a clear helper, the rest will be ready.
I'd rather keep it.

-Lukas

> > 
> > My plan is to send my patch set including this one tomorrow, will that
> > be fine with you ?
> > 
> > -Lukas
> > 
> > On Tue, Dec 21, 2021 at 08:32:14PM +0800, Ye Bin wrote:
> > > We test remount with 'abort' option as follows:
> > > [root@localhost home]# mount  /dev/sda test
> > > [root@localhost home]# mount | grep test
> > > /dev/sda on /home/test type ext4 (rw,relatime)
> > > [root@localhost home]# mount -o remount,abort test
> > > [root@localhost home]# mount | grep test
> > > /dev/sda on /home/test type ext4 (rw,relatime)
> > > 
> > > Obviously, remount 'abort' option isn't effective.
> > > After 6e47a3cc68fc commit we process abort option with 'ctx_set_mount_flags':
> > > static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int flag)
> > > {
> > > 	ctx->mask_s_mount_flags |= flag;
> > > 	ctx->vals_s_mount_flags |= flag;
> > > }
> > > 
> > > But we test 'abort' option with 'ext4_test_mount_flag':
> > > static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
> > > {
> > >          return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
> > > }
> > > 
> > > To solve this issue, pass (1 <<  EXT4_MF_FS_ABORTED) to 'ctx_set_mount_flags'.
> > > 
> > > Fixes:6e47a3cc68fc("ext4: get rid of super block and sbi from handle_mount_ops()")
> > > Signed-off-by: Ye Bin <yebin10@huawei.com>
> > > ---
> > >   fs/ext4/super.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> > > index b72d989b77fb..071b7b3c5678 100644
> > > --- a/fs/ext4/super.c
> > > +++ b/fs/ext4/super.c
> > > @@ -2236,7 +2236,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
> > >   			 param->key);
> > >   		return 0;
> > >   	case Opt_abort:
> > > -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
> > > +		ctx_set_mount_flags(ctx, 1 << EXT4_MF_FS_ABORTED);
> > >   		return 0;
> > >   	case Opt_i_version:
> > >   		ctx_set_flags(ctx, SB_I_VERSION);
> > > -- 
> > > 2.31.1
> > > 
> > .
> > 
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
  2021-12-22  9:19     ` Lukas Czerner
@ 2021-12-23  1:41       ` yebin
  2021-12-23 15:41         ` Theodore Ts'o
  0 siblings, 1 reply; 12+ messages in thread
From: yebin @ 2021-12-23  1:41 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: tytso, adilger.kernel, linux-ext4, linux-kernel, jack



On 2021/12/22 17:19, Lukas Czerner wrote:
> On Wed, Dec 22, 2021 at 09:06:22AM +0800, yebin wrote:
>>
>> On 2021/12/21 22:43, Lukas Czerner wrote:
>>> Hi,
>>>
>>> nice catch. This is a bug indeed. However I am currently in a process of
>>> changing the ctx_set/clear/test_ helpers because currently it generates
>>> functions that are unused.
>>>
>>> While I am at it I can just create a custom ctx_set_mount_flags()
>>> helper that would behave as expected so that we won't have to specify
>>> "1 < EXT4_MF_FS_ABORTED" which is not really obvious and hence error
>>> prone.
>> Actually, I fixed the first version as follows:
> Allright, this looks better.
>
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index b72d989b77fb..199920ffc7d3 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -2049,8 +2049,8 @@ struct ext4_fs_context {
>>   	unsigned int	mask_s_mount_opt;
>>   	unsigned int	vals_s_mount_opt2;
>>   	unsigned int	mask_s_mount_opt2;
>> -	unsigned int	vals_s_mount_flags;
>> -	unsigned int	mask_s_mount_flags;
>> +	unsigned long	vals_s_mount_flags;
>> +	unsigned long	mask_s_mount_flags;
>>   	unsigned int	opt_flags;	/* MOPT flags */
>>   	unsigned int	spec;
>>   	u32		s_max_batch_time;
>> @@ -2166,7 +2166,12 @@ static inline bool ctx_test_##name(struct ext4_fs_context *ctx, int flag)\
>>   EXT4_SET_CTX(flags);
>>   EXT4_SET_CTX(mount_opt);
>>   EXT4_SET_CTX(mount_opt2);
>> -EXT4_SET_CTX(mount_flags);
>> +
>> +static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int bit)
> Maybe ctx_set_mount_flag since you can't really set more than one this
> way?
So I think it's a little inappropriate to use the current repair scheme.
>> +{
>> +	set_bit(bit, &ctx->mask_s_mount_flags);
>> +	set_bit(bit, &ctx->vals_s_mount_flags);
>> +}
>>
>>
>> I think 'mask_s_mount_flags' is useless now.
> So how would we know what flags have changed ? Sure, there is currently
> no need to clear the flag but that can come in future and once it does
> we'll only need to create a clear helper, the rest will be ready.
> I'd rather keep it.
>
> -Lukas
 From this point of view, I agree with you.
>>> My plan is to send my patch set including this one tomorrow, will that
>>> be fine with you ?
>>>
>>> -Lukas
>>>
>>> On Tue, Dec 21, 2021 at 08:32:14PM +0800, Ye Bin wrote:
>>>> We test remount with 'abort' option as follows:
>>>> [root@localhost home]# mount  /dev/sda test
>>>> [root@localhost home]# mount | grep test
>>>> /dev/sda on /home/test type ext4 (rw,relatime)
>>>> [root@localhost home]# mount -o remount,abort test
>>>> [root@localhost home]# mount | grep test
>>>> /dev/sda on /home/test type ext4 (rw,relatime)
>>>>
>>>> Obviously, remount 'abort' option isn't effective.
>>>> After 6e47a3cc68fc commit we process abort option with 'ctx_set_mount_flags':
>>>> static inline void ctx_set_mount_flags(struct ext4_fs_context *ctx, int flag)
>>>> {
>>>> 	ctx->mask_s_mount_flags |= flag;
>>>> 	ctx->vals_s_mount_flags |= flag;
>>>> }
>>>>
>>>> But we test 'abort' option with 'ext4_test_mount_flag':
>>>> static inline int ext4_test_mount_flag(struct super_block *sb, int bit)
>>>> {
>>>>           return test_bit(bit, &EXT4_SB(sb)->s_mount_flags);
>>>> }
>>>>
>>>> To solve this issue, pass (1 <<  EXT4_MF_FS_ABORTED) to 'ctx_set_mount_flags'.
>>>>
>>>> Fixes:6e47a3cc68fc("ext4: get rid of super block and sbi from handle_mount_ops()")
>>>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>>>> ---
>>>>    fs/ext4/super.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>>>> index b72d989b77fb..071b7b3c5678 100644
>>>> --- a/fs/ext4/super.c
>>>> +++ b/fs/ext4/super.c
>>>> @@ -2236,7 +2236,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>>>>    			 param->key);
>>>>    		return 0;
>>>>    	case Opt_abort:
>>>> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
>>>> +		ctx_set_mount_flags(ctx, 1 << EXT4_MF_FS_ABORTED);
>>>>    		return 0;
>>>>    	case Opt_i_version:
>>>>    		ctx_set_flags(ctx, SB_I_VERSION);
>>>> -- 
>>>> 2.31.1
>>>>
>>> .
>>>
> .
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH -next] ext4: Fix remount with 'abort' option isn't effective
  2021-12-23  1:41       ` yebin
@ 2021-12-23 15:41         ` Theodore Ts'o
  2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
  0 siblings, 1 reply; 12+ messages in thread
From: Theodore Ts'o @ 2021-12-23 15:41 UTC (permalink / raw)
  To: yebin; +Cc: Lukas Czerner, adilger.kernel, linux-ext4, linux-kernel, jack

On Thu, Dec 23, 2021 at 09:41:31AM +0800, yebin wrote:
> 
> On 2021/12/22 17:19, Lukas Czerner wrote:
> > On Wed, Dec 22, 2021 at 09:06:22AM +0800, yebin wrote:
> > > 
> > > On 2021/12/21 22:43, Lukas Czerner wrote:
> > > > Hi,
> > > > 
> > > > nice catch. This is a bug indeed. However I am currently in a process of
> > > > changing the ctx_set/clear/test_ helpers because currently it generates
> > > > functions that are unused.
> > > > 
> > > > While I am at it I can just create a custom ctx_set_mount_flags()
> > > > helper that would behave as expected so that we won't have to specify
> > > > "1 < EXT4_MF_FS_ABORTED" which is not really obvious and hence error
> > > > prone.
> > > Actually, I fixed the first version as follows:
> > Allright, this looks better.

Was there an update to this patch?  I can't seem to find it in my
inbox or in patchwork....

Thanks,

					- Ted

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] ext4: fix remount with 'abort' option
  2021-12-23 15:41         ` Theodore Ts'o
@ 2022-02-01 13:13           ` Lukas Czerner
  2022-02-02 16:42             ` Gabriel Krisman Bertazi
                               ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Lukas Czerner @ 2022-02-01 13:13 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Ye Bin

After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from
handle_mount_ops()") the 'abort' options stopped working. This is
because we're using ctx_set_mount_flags() helper that's expecting an
argument with the appropriate bit set, but instead got
EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
using set_bit() while ctx_set_mount_flags() was using bitwise OR.

Create a separate helper ctx_set_mount_flag() to handle setting the
mount_flags correctly.

While we're at it clean up the EXT4_SET_CTX macros so that we're only
creating helpers that we actually use to avoid warnings.

Fixes: 6e47a3cc68fc ("ext4: get rid of super block and sbi from handle_mount_ops()")
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: Ye Bin <yebin10@huawei.com>
---
 fs/ext4/super.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index eee0d9ebfa6c..6f74cd51df2e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2045,8 +2045,8 @@ struct ext4_fs_context {
 	unsigned int	mask_s_mount_opt;
 	unsigned int	vals_s_mount_opt2;
 	unsigned int	mask_s_mount_opt2;
-	unsigned int	vals_s_mount_flags;
-	unsigned int	mask_s_mount_flags;
+	unsigned long	vals_s_mount_flags;
+	unsigned long	mask_s_mount_flags;
 	unsigned int	opt_flags;	/* MOPT flags */
 	unsigned int	spec;
 	u32		s_max_batch_time;
@@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx,		\
 {									\
 	ctx->mask_s_##name |= flag;					\
 	ctx->vals_s_##name |= flag;					\
-}									\
+}
+
+#define EXT4_CLEAR_CTX(name)						\
 static inline void ctx_clear_##name(struct ext4_fs_context *ctx,	\
 				    unsigned long flag)			\
 {									\
 	ctx->mask_s_##name |= flag;					\
 	ctx->vals_s_##name &= ~flag;					\
-}									\
+}
+
+#define EXT4_TEST_CTX(name)						\
 static inline unsigned long						\
 ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag)	\
 {									\
 	return (ctx->vals_s_##name & flag);				\
-}									\
+}
 
-EXT4_SET_CTX(flags);
+EXT4_SET_CTX(flags); /* set only */
 EXT4_SET_CTX(mount_opt);
+EXT4_CLEAR_CTX(mount_opt);
+EXT4_TEST_CTX(mount_opt);
 EXT4_SET_CTX(mount_opt2);
-EXT4_SET_CTX(mount_flags);
+EXT4_CLEAR_CTX(mount_opt2);
+EXT4_TEST_CTX(mount_opt2);
+
+static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
+{
+	set_bit(bit, &ctx->mask_s_mount_flags);
+	set_bit(bit, &ctx->vals_s_mount_flags);
+}
 
 static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
@@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 			 param->key);
 		return 0;
 	case Opt_abort:
-		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
+		ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
 		return 0;
 	case Opt_i_version:
 		ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] ext4: fix remount with 'abort' option
  2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
@ 2022-02-02 16:42             ` Gabriel Krisman Bertazi
  2022-02-02 19:00             ` Eric Sandeen
                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Gabriel Krisman Bertazi @ 2022-02-02 16:42 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: tytso, linux-ext4, Ye Bin

Lukas Czerner <lczerner@redhat.com> writes:

> After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from
> handle_mount_ops()") the 'abort' options stopped working. This is
> because we're using ctx_set_mount_flags() helper that's expecting an
> argument with the appropriate bit set, but instead got
> EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
> using set_bit() while ctx_set_mount_flags() was using bitwise OR.
>
> Create a separate helper ctx_set_mount_flag() to handle setting the
> mount_flags correctly.
>
> While we're at it clean up the EXT4_SET_CTX macros so that we're only
> creating helpers that we actually use to avoid warnings.
>
> Fixes: 6e47a3cc68fc ("ext4: get rid of super block and sbi from handle_mount_ops()")
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Cc: Ye Bin <yebin10@huawei.com>

We also observed this abort issue as a regression of an fanotify LTP
test (fanotify22).  This patch fixes that test case for me.

Tested-by: Gabriel Krisman Bertazi <krisman@collabora.com>

> ---
>  fs/ext4/super.c | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index eee0d9ebfa6c..6f74cd51df2e 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2045,8 +2045,8 @@ struct ext4_fs_context {
>  	unsigned int	mask_s_mount_opt;
>  	unsigned int	vals_s_mount_opt2;
>  	unsigned int	mask_s_mount_opt2;
> -	unsigned int	vals_s_mount_flags;
> -	unsigned int	mask_s_mount_flags;
> +	unsigned long	vals_s_mount_flags;
> +	unsigned long	mask_s_mount_flags;
>  	unsigned int	opt_flags;	/* MOPT flags */
>  	unsigned int	spec;
>  	u32		s_max_batch_time;
> @@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx,		\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name |= flag;					\
> -}									\
> +}
> +
> +#define EXT4_CLEAR_CTX(name)						\
>  static inline void ctx_clear_##name(struct ext4_fs_context *ctx,	\
>  				    unsigned long flag)			\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name &= ~flag;					\
> -}									\
> +}
> +
> +#define EXT4_TEST_CTX(name)						\
>  static inline unsigned long						\
>  ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag)	\
>  {									\
>  	return (ctx->vals_s_##name & flag);				\
> -}									\
> +}
>  
> -EXT4_SET_CTX(flags);
> +EXT4_SET_CTX(flags); /* set only */
>  EXT4_SET_CTX(mount_opt);
> +EXT4_CLEAR_CTX(mount_opt);
> +EXT4_TEST_CTX(mount_opt);
>  EXT4_SET_CTX(mount_opt2);
> -EXT4_SET_CTX(mount_flags);
> +EXT4_CLEAR_CTX(mount_opt2);
> +EXT4_TEST_CTX(mount_opt2);
> +
> +static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
> +{
> +	set_bit(bit, &ctx->mask_s_mount_flags);
> +	set_bit(bit, &ctx->vals_s_mount_flags);
> +}
>  
>  static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  {
> @@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  			 param->key);
>  		return 0;
>  	case Opt_abort:
> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
> +		ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
>  		return 0;
>  	case Opt_i_version:
>  		ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");

-- 
Gabriel Krisman Bertazi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] ext4: fix remount with 'abort' option
  2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
  2022-02-02 16:42             ` Gabriel Krisman Bertazi
@ 2022-02-02 19:00             ` Eric Sandeen
  2022-03-02  9:43             ` Lukas Czerner
  2022-03-03  0:41             ` Theodore Ts'o
  3 siblings, 0 replies; 12+ messages in thread
From: Eric Sandeen @ 2022-02-02 19:00 UTC (permalink / raw)
  To: Lukas Czerner, tytso; +Cc: linux-ext4, Ye Bin

On 2/1/22 7:13 AM, Lukas Czerner wrote:
> After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from
> handle_mount_ops()") the 'abort' options stopped working. This is
> because we're using ctx_set_mount_flags() helper that's expecting an
> argument with the appropriate bit set, but instead got
> EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
> using set_bit() while ctx_set_mount_flags() was using bitwise OR.
> 
> Create a separate helper ctx_set_mount_flag() to handle setting the
> mount_flags correctly.
> 
> While we're at it clean up the EXT4_SET_CTX macros so that we're only
> creating helpers that we actually use to avoid warnings.
> 
> Fixes: 6e47a3cc68fc ("ext4: get rid of super block and sbi from handle_mount_ops()")
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Cc: Ye Bin <yebin10@huawei.com>

ok thinking out loud here - reducing this to the functional change that
fixes the bug, (apologies for the surely-mangled whitespace, I'm being lazy),
it looks something like:

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index eee0d9ebfa6c..a3047b033053 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2045,8 +2045,8 @@ struct ext4_fs_context {
        unsigned int    mask_s_mount_opt;
        unsigned int    vals_s_mount_opt2;
        unsigned int    mask_s_mount_opt2;
-       unsigned int    vals_s_mount_flags;
-       unsigned int    mask_s_mount_flags;
+       unsigned long   vals_s_mount_flags;
+       unsigned long   mask_s_mount_flags;
        unsigned int    opt_flags;      /* MOPT flags */
        unsigned int    spec;
        u32             s_max_batch_time;
@@ -2165,7 +2165,13 @@ ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag) \
 EXT4_SET_CTX(flags);
 EXT4_SET_CTX(mount_opt);
 EXT4_SET_CTX(mount_opt2);
-EXT4_SET_CTX(mount_flags);
+
+/* Setting the mount_flags field is special, it takes a bit number */
+static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
+{
+       set_bit(bit, &ctx->mask_s_mount_flags);
+       set_bit(bit, &ctx->vals_s_mount_flags);
+}
 
 static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
 {
@@ -2235,7 +2241,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
                         param->key);
                return 0;
        case Opt_abort:
-               ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
+               ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
                return 0;
        case Opt_i_version:
                ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");

and that makes sense to me. I wonder if there's any further cleanup that could
make it slightly more clear or foolproof re: which flag matches which ctx_set_*
generated function, so the wrong thing doesn't get sent to the wrong routine,
but that's a different issue, so for the patch as you sent it,

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  fs/ext4/super.c | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index eee0d9ebfa6c..6f74cd51df2e 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2045,8 +2045,8 @@ struct ext4_fs_context {
>  	unsigned int	mask_s_mount_opt;
>  	unsigned int	vals_s_mount_opt2;
>  	unsigned int	mask_s_mount_opt2;
> -	unsigned int	vals_s_mount_flags;
> -	unsigned int	mask_s_mount_flags;
> +	unsigned long	vals_s_mount_flags;
> +	unsigned long	mask_s_mount_flags;
>  	unsigned int	opt_flags;	/* MOPT flags */
>  	unsigned int	spec;
>  	u32		s_max_batch_time;
> @@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx,		\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name |= flag;					\
> -}									\
> +}
> +
> +#define EXT4_CLEAR_CTX(name)						\
>  static inline void ctx_clear_##name(struct ext4_fs_context *ctx,	\
>  				    unsigned long flag)			\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name &= ~flag;					\
> -}									\
> +}
> +
> +#define EXT4_TEST_CTX(name)						\
>  static inline unsigned long						\
>  ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag)	\
>  {									\
>  	return (ctx->vals_s_##name & flag);				\
> -}									\
> +}
>  
> -EXT4_SET_CTX(flags);
> +EXT4_SET_CTX(flags); /* set only */
>  EXT4_SET_CTX(mount_opt);
> +EXT4_CLEAR_CTX(mount_opt);
> +EXT4_TEST_CTX(mount_opt);
>  EXT4_SET_CTX(mount_opt2);
> -EXT4_SET_CTX(mount_flags);
> +EXT4_CLEAR_CTX(mount_opt2);
> +EXT4_TEST_CTX(mount_opt2);
> +
> +static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
> +{
> +	set_bit(bit, &ctx->mask_s_mount_flags);
> +	set_bit(bit, &ctx->vals_s_mount_flags);
> +}
>  
>  static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  {
> @@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  			 param->key);
>  		return 0;
>  	case Opt_abort:
> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
> +		ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
>  		return 0;
>  	case Opt_i_version:
>  		ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] ext4: fix remount with 'abort' option
  2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
  2022-02-02 16:42             ` Gabriel Krisman Bertazi
  2022-02-02 19:00             ` Eric Sandeen
@ 2022-03-02  9:43             ` Lukas Czerner
  2022-03-03  0:40               ` Theodore Ts'o
  2022-03-03  0:41             ` Theodore Ts'o
  3 siblings, 1 reply; 12+ messages in thread
From: Lukas Czerner @ 2022-03-02  9:43 UTC (permalink / raw)
  To: tytso; +Cc: linux-ext4, Ye Bin

Hi Ted,

this problem is still generating warnings. Can you please take this in
when you have time?

Thanks!
-Lukas

On Tue, Feb 01, 2022 at 02:13:45PM +0100, Lukas Czerner wrote:
> After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from
> handle_mount_ops()") the 'abort' options stopped working. This is
> because we're using ctx_set_mount_flags() helper that's expecting an
> argument with the appropriate bit set, but instead got
> EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
> using set_bit() while ctx_set_mount_flags() was using bitwise OR.
> 
> Create a separate helper ctx_set_mount_flag() to handle setting the
> mount_flags correctly.
> 
> While we're at it clean up the EXT4_SET_CTX macros so that we're only
> creating helpers that we actually use to avoid warnings.
> 
> Fixes: 6e47a3cc68fc ("ext4: get rid of super block and sbi from handle_mount_ops()")
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Cc: Ye Bin <yebin10@huawei.com>
> ---
>  fs/ext4/super.c | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index eee0d9ebfa6c..6f74cd51df2e 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2045,8 +2045,8 @@ struct ext4_fs_context {
>  	unsigned int	mask_s_mount_opt;
>  	unsigned int	vals_s_mount_opt2;
>  	unsigned int	mask_s_mount_opt2;
> -	unsigned int	vals_s_mount_flags;
> -	unsigned int	mask_s_mount_flags;
> +	unsigned long	vals_s_mount_flags;
> +	unsigned long	mask_s_mount_flags;
>  	unsigned int	opt_flags;	/* MOPT flags */
>  	unsigned int	spec;
>  	u32		s_max_batch_time;
> @@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx,		\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name |= flag;					\
> -}									\
> +}
> +
> +#define EXT4_CLEAR_CTX(name)						\
>  static inline void ctx_clear_##name(struct ext4_fs_context *ctx,	\
>  				    unsigned long flag)			\
>  {									\
>  	ctx->mask_s_##name |= flag;					\
>  	ctx->vals_s_##name &= ~flag;					\
> -}									\
> +}
> +
> +#define EXT4_TEST_CTX(name)						\
>  static inline unsigned long						\
>  ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag)	\
>  {									\
>  	return (ctx->vals_s_##name & flag);				\
> -}									\
> +}
>  
> -EXT4_SET_CTX(flags);
> +EXT4_SET_CTX(flags); /* set only */
>  EXT4_SET_CTX(mount_opt);
> +EXT4_CLEAR_CTX(mount_opt);
> +EXT4_TEST_CTX(mount_opt);
>  EXT4_SET_CTX(mount_opt2);
> -EXT4_SET_CTX(mount_flags);
> +EXT4_CLEAR_CTX(mount_opt2);
> +EXT4_TEST_CTX(mount_opt2);
> +
> +static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit)
> +{
> +	set_bit(bit, &ctx->mask_s_mount_flags);
> +	set_bit(bit, &ctx->vals_s_mount_flags);
> +}
>  
>  static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  {
> @@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
>  			 param->key);
>  		return 0;
>  	case Opt_abort:
> -		ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
> +		ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED);
>  		return 0;
>  	case Opt_i_version:
>  		ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");
> -- 
> 2.31.1
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] ext4: fix remount with 'abort' option
  2022-03-02  9:43             ` Lukas Czerner
@ 2022-03-03  0:40               ` Theodore Ts'o
  0 siblings, 0 replies; 12+ messages in thread
From: Theodore Ts'o @ 2022-03-03  0:40 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4, Ye Bin

On Wed, Mar 02, 2022 at 10:43:37AM +0100, Lukas Czerner wrote:
> Hi Ted,
> 
> this problem is still generating warnings. Can you please take this in
> when you have time?

Oops, sorry.  I processed a bunch of patches last week, and had even
pushed them them out to ext4.git on git.kernel.org, but I had
forgotten to run "b4 ty".  (I was waiting for the regression tests to
finish, and then forgot to send out the e-mail ack's.)  I'll send
them out now.

					- Ted

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] ext4: fix remount with 'abort' option
  2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
                               ` (2 preceding siblings ...)
  2022-03-02  9:43             ` Lukas Czerner
@ 2022-03-03  0:41             ` Theodore Ts'o
  3 siblings, 0 replies; 12+ messages in thread
From: Theodore Ts'o @ 2022-03-03  0:41 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: Theodore Ts'o, linux-ext4, Ye Bin

On Tue, 1 Feb 2022 14:13:45 +0100, Lukas Czerner wrote:
> After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from
> handle_mount_ops()") the 'abort' options stopped working. This is
> because we're using ctx_set_mount_flags() helper that's expecting an
> argument with the appropriate bit set, but instead got
> EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is
> using set_bit() while ctx_set_mount_flags() was using bitwise OR.
> 
> [...]

Applied, thanks!

[1/1] ext4: fix remount with 'abort' option
      commit: e3952fcce1aad934f1322843b564ff86256444b2

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-03  0:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 12:32 [PATCH -next] ext4: Fix remount with 'abort' option isn't effective Ye Bin
2021-12-21 14:43 ` Lukas Czerner
2021-12-22  1:06   ` yebin
2021-12-22  9:19     ` Lukas Czerner
2021-12-23  1:41       ` yebin
2021-12-23 15:41         ` Theodore Ts'o
2022-02-01 13:13           ` [PATCH] ext4: fix remount with 'abort' option Lukas Czerner
2022-02-02 16:42             ` Gabriel Krisman Bertazi
2022-02-02 19:00             ` Eric Sandeen
2022-03-02  9:43             ` Lukas Czerner
2022-03-03  0:40               ` Theodore Ts'o
2022-03-03  0:41             ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.