2020-08-28 07:33:22

by Xiao Yang

[permalink] [raw]
Subject: [PATCH] ext4: Disallow modifying DAX inode flag if inline_data has been set

inline_data is mutually exclusive to DAX so enabling both of them triggers
the following issue:
------------------------------------------
# mkfs.ext4 -F -O inline_data /dev/pmem1
...
# mount /dev/pmem1 /mnt
# echo 'test' >/mnt/file
# lsattr -l /mnt/file
/mnt/file Inline_Data
# xfs_io -c "chattr +x" /mnt/file
# xfs_io -c "lsattr -v" /mnt/file
[dax] /mnt/file
# umount /mnt
# mount /dev/pmem1 /mnt
# cat /mnt/file
cat: /mnt/file: Numerical result out of range
------------------------------------------

Signed-off-by: Xiao Yang <[email protected]>
---
fs/ext4/ext4.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 523e00d7b392..69187b6205b2 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -492,7 +492,7 @@ struct flex_groups {

/* Flags which are mutually exclusive to DAX */
#define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
- EXT4_JOURNAL_DATA_FL)
+ EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)

/* Mask out flags that are inappropriate for the given type of inode. */
static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
--
2.25.1




2020-08-28 08:52:14

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] ext4: Disallow modifying DAX inode flag if inline_data has been set

On Fri 28-08-20 15:15:01, Xiao Yang wrote:
> inline_data is mutually exclusive to DAX so enabling both of them triggers
> the following issue:
> ------------------------------------------
> # mkfs.ext4 -F -O inline_data /dev/pmem1
> ...
> # mount /dev/pmem1 /mnt
> # echo 'test' >/mnt/file
> # lsattr -l /mnt/file
> /mnt/file Inline_Data
> # xfs_io -c "chattr +x" /mnt/file
> # xfs_io -c "lsattr -v" /mnt/file
> [dax] /mnt/file
> # umount /mnt
> # mount /dev/pmem1 /mnt
> # cat /mnt/file
> cat: /mnt/file: Numerical result out of range
> ------------------------------------------
>
> Signed-off-by: Xiao Yang <[email protected]>

Thanks. The patch looks good to me. You can add:

Reviewed-by: Jan Kara <[email protected]>

Please also add the following tag to the changelog:

Fixes: b383a73f2b83 ("fs/ext4: Introduce DAX inode flag")

so that the patch gets properly picked up to stable trees etc. Thanks!

Honza

> ---
> fs/ext4/ext4.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 523e00d7b392..69187b6205b2 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -492,7 +492,7 @@ struct flex_groups {
>
> /* Flags which are mutually exclusive to DAX */
> #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
> - EXT4_JOURNAL_DATA_FL)
> + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)
>
> /* Mask out flags that are inappropriate for the given type of inode. */
> static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
> --
> 2.25.1
>
>
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2020-08-28 08:59:57

by Xiao Yang

[permalink] [raw]
Subject: Re: [PATCH] ext4: Disallow modifying DAX inode flag if inline_data has been set

On 2020/8/28 16:49, Jan Kara wrote:
> On Fri 28-08-20 15:15:01, Xiao Yang wrote:
>> inline_data is mutually exclusive to DAX so enabling both of them triggers
>> the following issue:
>> ------------------------------------------
>> # mkfs.ext4 -F -O inline_data /dev/pmem1
>> ...
>> # mount /dev/pmem1 /mnt
>> # echo 'test'>/mnt/file
>> # lsattr -l /mnt/file
>> /mnt/file Inline_Data
>> # xfs_io -c "chattr +x" /mnt/file
>> # xfs_io -c "lsattr -v" /mnt/file
>> [dax] /mnt/file
>> # umount /mnt
>> # mount /dev/pmem1 /mnt
>> # cat /mnt/file
>> cat: /mnt/file: Numerical result out of range
>> ------------------------------------------
>>
>> Signed-off-by: Xiao Yang<[email protected]>
> Thanks. The patch looks good to me. You can add:
>
> Reviewed-by: Jan Kara<[email protected]>
>
> Please also add the following tag to the changelog:
>
> Fixes: b383a73f2b83 ("fs/ext4: Introduce DAX inode flag")
>
> so that the patch gets properly picked up to stable trees etc.
Hi Jan,

Thanks for your quick reply. :-)
I will send v2 patch shortly as you suggested.

Best Regards,
Xiao Yang
> Thanks!
>
> Honza
>
>> ---
>> fs/ext4/ext4.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
>> index 523e00d7b392..69187b6205b2 100644
>> --- a/fs/ext4/ext4.h
>> +++ b/fs/ext4/ext4.h
>> @@ -492,7 +492,7 @@ struct flex_groups {
>>
>> /* Flags which are mutually exclusive to DAX */
>> #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
>> - EXT4_JOURNAL_DATA_FL)
>> + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)
>>
>> /* Mask out flags that are inappropriate for the given type of inode. */
>> static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
>> --
>> 2.25.1
>>
>>
>>



2020-08-28 17:02:33

by Ira Weiny

[permalink] [raw]
Subject: Re: [PATCH] ext4: Disallow modifying DAX inode flag if inline_data has been set

On Fri, Aug 28, 2020 at 03:15:01PM +0800, Xiao Yang wrote:
> inline_data is mutually exclusive to DAX so enabling both of them triggers
> the following issue:
> ------------------------------------------
> # mkfs.ext4 -F -O inline_data /dev/pmem1
> ...
> # mount /dev/pmem1 /mnt
> # echo 'test' >/mnt/file
> # lsattr -l /mnt/file
> /mnt/file Inline_Data
> # xfs_io -c "chattr +x" /mnt/file
> # xfs_io -c "lsattr -v" /mnt/file
> [dax] /mnt/file
> # umount /mnt
> # mount /dev/pmem1 /mnt
> # cat /mnt/file
> cat: /mnt/file: Numerical result out of range
> ------------------------------------------
>
> Signed-off-by: Xiao Yang <[email protected]>

Thank you for the fix!

Reviewed-by: Ira Weiny <[email protected]>

> ---
> fs/ext4/ext4.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 523e00d7b392..69187b6205b2 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -492,7 +492,7 @@ struct flex_groups {
>
> /* Flags which are mutually exclusive to DAX */
> #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
> - EXT4_JOURNAL_DATA_FL)
> + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)
>
> /* Mask out flags that are inappropriate for the given type of inode. */
> static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
> --
> 2.25.1
>
>
>

2020-08-28 17:03:21

by Ira Weiny

[permalink] [raw]
Subject: Re: [PATCH] ext4: Disallow modifying DAX inode flag if inline_data has been set

On Fri, Aug 28, 2020 at 10:49:21AM +0200, Jan Kara wrote:
> On Fri 28-08-20 15:15:01, Xiao Yang wrote:
> > inline_data is mutually exclusive to DAX so enabling both of them triggers
> > the following issue:
> > ------------------------------------------
> > # mkfs.ext4 -F -O inline_data /dev/pmem1
> > ...
> > # mount /dev/pmem1 /mnt
> > # echo 'test' >/mnt/file
> > # lsattr -l /mnt/file
> > /mnt/file Inline_Data
> > # xfs_io -c "chattr +x" /mnt/file
> > # xfs_io -c "lsattr -v" /mnt/file
> > [dax] /mnt/file
> > # umount /mnt
> > # mount /dev/pmem1 /mnt
> > # cat /mnt/file
> > cat: /mnt/file: Numerical result out of range
> > ------------------------------------------
> >
> > Signed-off-by: Xiao Yang <[email protected]>
>
> Thanks. The patch looks good to me. You can add:
>
> Reviewed-by: Jan Kara <[email protected]>
>
> Please also add the following tag to the changelog:
>
> Fixes: b383a73f2b83 ("fs/ext4: Introduce DAX inode flag")
>
> so that the patch gets properly picked up to stable trees etc. Thanks!

And +1 on getting this to stable.

Thanks!
Ira

>
> Honza
>
> > ---
> > fs/ext4/ext4.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> > index 523e00d7b392..69187b6205b2 100644
> > --- a/fs/ext4/ext4.h
> > +++ b/fs/ext4/ext4.h
> > @@ -492,7 +492,7 @@ struct flex_groups {
> >
> > /* Flags which are mutually exclusive to DAX */
> > #define EXT4_DAX_MUT_EXCL (EXT4_VERITY_FL | EXT4_ENCRYPT_FL |\
> > - EXT4_JOURNAL_DATA_FL)
> > + EXT4_JOURNAL_DATA_FL | EXT4_INLINE_DATA_FL)
> >
> > /* Mask out flags that are inappropriate for the given type of inode. */
> > static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
> > --
> > 2.25.1
> >
> >
> >
> --
> Jan Kara <[email protected]>
> SUSE Labs, CR