All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to do sanity with enabled features in image
Date: Tue, 16 Jul 2019 18:02:21 +0800	[thread overview]
Message-ID: <a16a0c1c-16c6-5fe8-bfc4-7cc0e0866c77@huawei.com> (raw)
In-Reply-To: <192bae92-2193-570f-7b50-00334271bd2e@huawei.com>

Hi Jaegeuk,

On 2019/5/9 9:15, Chao Yu wrote:
> On 2019/5/5 10:51, Chao Yu wrote:
>> On 2019/5/1 11:22, Jaegeuk Kim wrote:
>>> On 04/29, Chao Yu wrote:
>>>> On 2019-4-28 21:38, Jaegeuk Kim wrote:
>>>>> On 04/24, Chao Yu wrote:
>>>>>> This patch fixes to do sanity with enabled features in image, if
>>>>>> there are features kernel can not recognize, just fail the mount.
>>>>>
>>>>> We need to figure out per-feature-based rejection, since some of them can
>>>>> be set without layout change.

What about adding one field in superblock for compatible features in future?

sb.feature(F2FS_FEATURE_LAST, max] stores uncompatible features
sb.compatible_feature stores compatible features

If we follow above rule when adding one feature, then, we can fail the mount if
sb.feature(F2FS_FEATURE_LAST, max] is valid.

Thanks,

>>>>
>>>> So any suggestion on how to implement this?
>>>
>>> Which features do we need to disallow? When we introduce new features, they
>>
>> I guess it should be the new features.
>>
>>> didn't hurt the previous flow by checking f2fs_sb_has_###().
>>
>> Yes, but new features may use new disk layout, if old kernel handled it with old
>> disk layout, there must be problematic.
>>
>> e.g. format image with -O extra_attr, and mount it with kernel who don't
>> recognize new inode layout.
> 
> Jaegeuk,
> 
> Any thoughts?
> 
> Thanks,
> 
>>
>> Thanks,
>>
>>>
>>>>
>>>> Maybe:
>>>>
>>>> if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))
>>>> 	check 4.14+ features
>>>> else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
>>>> 	check 4.9+ features
>>>> else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))
>>>> 	check 4.4+ features
>>>>
>>>> Thanks,
>>>>
>>>>>
>>>>>>
>>>>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>>>>> ---
>>>>>>  fs/f2fs/f2fs.h  | 13 +++++++++++++
>>>>>>  fs/f2fs/super.c |  9 +++++++++
>>>>>>  2 files changed, 22 insertions(+)
>>>>>>
>>>>>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>>>>>> index f5ffc09705eb..15b640967e12 100644
>>>>>> --- a/fs/f2fs/f2fs.h
>>>>>> +++ b/fs/f2fs/f2fs.h
>>>>>> @@ -151,6 +151,19 @@ struct f2fs_mount_info {
>>>>>>  #define F2FS_FEATURE_VERITY		0x0400	/* reserved */
>>>>>>  #define F2FS_FEATURE_SB_CHKSUM		0x0800
>>>>>>  
>>>>>> +#define F2FS_ALL_FEATURES	(F2FS_FEATURE_ENCRYPT |			\
>>>>>> +				F2FS_FEATURE_BLKZONED |			\
>>>>>> +				F2FS_FEATURE_ATOMIC_WRITE |		\
>>>>>> +				F2FS_FEATURE_EXTRA_ATTR |		\
>>>>>> +				F2FS_FEATURE_PRJQUOTA |			\
>>>>>> +				F2FS_FEATURE_INODE_CHKSUM |		\
>>>>>> +				F2FS_FEATURE_FLEXIBLE_INLINE_XATTR |	\
>>>>>> +				F2FS_FEATURE_QUOTA_INO |		\
>>>>>> +				F2FS_FEATURE_INODE_CRTIME |		\
>>>>>> +				F2FS_FEATURE_LOST_FOUND |		\
>>>>>> +				F2FS_FEATURE_VERITY |			\
>>>>>> +				F2FS_FEATURE_SB_CHKSUM)
>>>>>> +
>>>>>>  #define __F2FS_HAS_FEATURE(raw_super, mask)				\
>>>>>>  	((raw_super->feature & cpu_to_le32(mask)) != 0)
>>>>>>  #define F2FS_HAS_FEATURE(sbi, mask)	__F2FS_HAS_FEATURE(sbi->raw_super, mask)
>>>>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>>>>> index 4f8e9ab48b26..57f2fc6d14ba 100644
>>>>>> --- a/fs/f2fs/super.c
>>>>>> +++ b/fs/f2fs/super.c
>>>>>> @@ -2573,6 +2573,15 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
>>>>>>  		return 1;
>>>>>>  	}
>>>>>>  
>>>>>> +	/* check whether kernel supports all features */
>>>>>> +	if (le32_to_cpu(raw_super->feature) & (~F2FS_ALL_FEATURES)) {
>>>>>> +		f2fs_msg(sb, KERN_INFO,
>>>>>> +			"Unsupported feature:%u: supported:%u",
>>>>>> +			le32_to_cpu(raw_super->feature),
>>>>>> +			F2FS_ALL_FEATURES);
>>>>>> +		return 1;
>>>>>> +	}
>>>>>> +
>>>>>>  	/* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
>>>>>>  	if (sanity_check_area_boundary(sbi, bh))
>>>>>>  		return 1;
>>>>>> -- 
>>>>>> 2.18.0.rc1
>>> .
>>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>> .
>>
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> .
> 

WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to do sanity with enabled features in image
Date: Tue, 16 Jul 2019 18:02:21 +0800	[thread overview]
Message-ID: <a16a0c1c-16c6-5fe8-bfc4-7cc0e0866c77@huawei.com> (raw)
In-Reply-To: <192bae92-2193-570f-7b50-00334271bd2e@huawei.com>

Hi Jaegeuk,

On 2019/5/9 9:15, Chao Yu wrote:
> On 2019/5/5 10:51, Chao Yu wrote:
>> On 2019/5/1 11:22, Jaegeuk Kim wrote:
>>> On 04/29, Chao Yu wrote:
>>>> On 2019-4-28 21:38, Jaegeuk Kim wrote:
>>>>> On 04/24, Chao Yu wrote:
>>>>>> This patch fixes to do sanity with enabled features in image, if
>>>>>> there are features kernel can not recognize, just fail the mount.
>>>>>
>>>>> We need to figure out per-feature-based rejection, since some of them can
>>>>> be set without layout change.

What about adding one field in superblock for compatible features in future?

sb.feature(F2FS_FEATURE_LAST, max] stores uncompatible features
sb.compatible_feature stores compatible features

If we follow above rule when adding one feature, then, we can fail the mount if
sb.feature(F2FS_FEATURE_LAST, max] is valid.

Thanks,

>>>>
>>>> So any suggestion on how to implement this?
>>>
>>> Which features do we need to disallow? When we introduce new features, they
>>
>> I guess it should be the new features.
>>
>>> didn't hurt the previous flow by checking f2fs_sb_has_###().
>>
>> Yes, but new features may use new disk layout, if old kernel handled it with old
>> disk layout, there must be problematic.
>>
>> e.g. format image with -O extra_attr, and mount it with kernel who don't
>> recognize new inode layout.
> 
> Jaegeuk,
> 
> Any thoughts?
> 
> Thanks,
> 
>>
>> Thanks,
>>
>>>
>>>>
>>>> Maybe:
>>>>
>>>> if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0))
>>>> 	check 4.14+ features
>>>> else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0))
>>>> 	check 4.9+ features
>>>> else if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0))
>>>> 	check 4.4+ features
>>>>
>>>> Thanks,
>>>>
>>>>>
>>>>>>
>>>>>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>>>>>> ---
>>>>>>  fs/f2fs/f2fs.h  | 13 +++++++++++++
>>>>>>  fs/f2fs/super.c |  9 +++++++++
>>>>>>  2 files changed, 22 insertions(+)
>>>>>>
>>>>>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>>>>>> index f5ffc09705eb..15b640967e12 100644
>>>>>> --- a/fs/f2fs/f2fs.h
>>>>>> +++ b/fs/f2fs/f2fs.h
>>>>>> @@ -151,6 +151,19 @@ struct f2fs_mount_info {
>>>>>>  #define F2FS_FEATURE_VERITY		0x0400	/* reserved */
>>>>>>  #define F2FS_FEATURE_SB_CHKSUM		0x0800
>>>>>>  
>>>>>> +#define F2FS_ALL_FEATURES	(F2FS_FEATURE_ENCRYPT |			\
>>>>>> +				F2FS_FEATURE_BLKZONED |			\
>>>>>> +				F2FS_FEATURE_ATOMIC_WRITE |		\
>>>>>> +				F2FS_FEATURE_EXTRA_ATTR |		\
>>>>>> +				F2FS_FEATURE_PRJQUOTA |			\
>>>>>> +				F2FS_FEATURE_INODE_CHKSUM |		\
>>>>>> +				F2FS_FEATURE_FLEXIBLE_INLINE_XATTR |	\
>>>>>> +				F2FS_FEATURE_QUOTA_INO |		\
>>>>>> +				F2FS_FEATURE_INODE_CRTIME |		\
>>>>>> +				F2FS_FEATURE_LOST_FOUND |		\
>>>>>> +				F2FS_FEATURE_VERITY |			\
>>>>>> +				F2FS_FEATURE_SB_CHKSUM)
>>>>>> +
>>>>>>  #define __F2FS_HAS_FEATURE(raw_super, mask)				\
>>>>>>  	((raw_super->feature & cpu_to_le32(mask)) != 0)
>>>>>>  #define F2FS_HAS_FEATURE(sbi, mask)	__F2FS_HAS_FEATURE(sbi->raw_super, mask)
>>>>>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>>>>>> index 4f8e9ab48b26..57f2fc6d14ba 100644
>>>>>> --- a/fs/f2fs/super.c
>>>>>> +++ b/fs/f2fs/super.c
>>>>>> @@ -2573,6 +2573,15 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
>>>>>>  		return 1;
>>>>>>  	}
>>>>>>  
>>>>>> +	/* check whether kernel supports all features */
>>>>>> +	if (le32_to_cpu(raw_super->feature) & (~F2FS_ALL_FEATURES)) {
>>>>>> +		f2fs_msg(sb, KERN_INFO,
>>>>>> +			"Unsupported feature:%u: supported:%u",
>>>>>> +			le32_to_cpu(raw_super->feature),
>>>>>> +			F2FS_ALL_FEATURES);
>>>>>> +		return 1;
>>>>>> +	}
>>>>>> +
>>>>>>  	/* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
>>>>>>  	if (sanity_check_area_boundary(sbi, bh))
>>>>>>  		return 1;
>>>>>> -- 
>>>>>> 2.18.0.rc1
>>> .
>>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>> .
>>
> 
> 
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2019-07-16 10:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24  9:48 [PATCH] f2fs: fix to do sanity with enabled features in image Chao Yu
2019-04-24  9:48 ` Chao Yu
2019-04-28 13:38 ` Jaegeuk Kim
2019-04-29 13:57   ` Chao Yu
2019-05-01  3:22     ` Jaegeuk Kim
2019-05-05  2:51       ` Chao Yu
2019-05-05  2:51         ` Chao Yu
2019-05-09  1:15         ` [f2fs-dev] " Chao Yu
2019-05-09  1:15           ` Chao Yu
2019-07-16 10:02           ` Chao Yu [this message]
2019-07-16 10:02             ` Chao Yu
2019-07-23  1:35             ` Jaegeuk Kim
2019-07-23  1:35               ` Jaegeuk Kim
2019-07-23  7:01               ` Chao Yu
2019-07-23  7:01                 ` Chao Yu
2019-07-29  5:47                 ` Jaegeuk Kim
2019-07-29  5:47                   ` Jaegeuk Kim
2019-07-29  7:09                   ` Chao Yu
2019-07-29  7:09                     ` Chao Yu
2019-04-29 20:54 ` Ju Hyung Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a16a0c1c-16c6-5fe8-bfc4-7cc0e0866c77@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.