linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v3 RESEND] f2fs: introduce sb.required_features to store incompatible features
Date: Wed, 31 Jul 2019 21:22:15 -0700	[thread overview]
Message-ID: <20190801042215.GC84433@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <c7232d80-a4d8-88ae-2eca-01290dd0e56a@huawei.com>

On 07/31, Chao Yu wrote:
> On 2019/7/31 7:18, Jaegeuk Kim wrote:
> > On 07/29, Chao Yu wrote:
> >> From: Chao Yu <yuchao0@huawei.com>
> >>
> >> Later after this patch was merged, all new incompatible feature's
> >> bit should be added into sb.required_features field, and define new
> >> feature function with F2FS_INCOMPAT_FEATURE_FUNCS() macro.
> >>
> >> Then during mount, we will do sanity check with enabled features in
> >> image, if there are features in sb.required_features that kernel can
> >> not recognize, just fail the mount.
> >>
> >> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> >> ---
> >> v3:
> >> - change commit title.
> >> - fix wrong macro name.
> >>  fs/f2fs/f2fs.h          | 15 +++++++++++++++
> >>  fs/f2fs/super.c         | 10 ++++++++++
> >>  include/linux/f2fs_fs.h |  3 ++-
> >>  3 files changed, 27 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> >> index a6eb828af57f..b8e17d4ddb8d 100644
> >> --- a/fs/f2fs/f2fs.h
> >> +++ b/fs/f2fs/f2fs.h
> >> @@ -163,6 +163,15 @@ struct f2fs_mount_info {
> >>  #define F2FS_CLEAR_FEATURE(sbi, mask)					\
> >>  	(sbi->raw_super->feature &= ~cpu_to_le32(mask))
> >>  
> >> +#define F2FS_INCOMPAT_FEATURES		0
> >> +
> >> +#define F2FS_HAS_INCOMPAT_FEATURE(sbi, mask)				\
> >> +	((sbi->raw_super->required_features & cpu_to_le32(mask)) != 0)
> >> +#define F2FS_SET_INCOMPAT_FEATURE(sbi, mask)				\
> >> +	(sbi->raw_super->required_features |= cpu_to_le32(mask))
> >> +#define F2FS_CLEAR_INCOMPAT_FEATURE(sbi, mask)				\
> >> +	(sbi->raw_super->required_features &= ~cpu_to_le32(mask))
> >> +
> >>  /*
> >>   * Default values for user and/or group using reserved blocks
> >>   */
> >> @@ -3585,6 +3594,12 @@ F2FS_FEATURE_FUNCS(lost_found, LOST_FOUND);
> >>  F2FS_FEATURE_FUNCS(sb_chksum, SB_CHKSUM);
> >>  F2FS_FEATURE_FUNCS(casefold, CASEFOLD);
> >>  
> >> +#define F2FS_INCOMPAT_FEATURE_FUNCS(name, flagname) \
> >> +static inline int f2fs_sb_has_##name(struct f2fs_sb_info *sbi) \
> >> +{ \
> >> +	return F2FS_HAS_INCOMPAT_FEATURE(sbi, F2FS_FEATURE_##flagname); \
> >> +}
> >> +
> >>  #ifdef CONFIG_BLK_DEV_ZONED
> >>  static inline bool f2fs_blkz_is_seq(struct f2fs_sb_info *sbi, int devi,
> >>  				    block_t blkaddr)
> >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> >> index 5540fee0fe3f..3701dcce90e6 100644
> >> --- a/fs/f2fs/super.c
> >> +++ b/fs/f2fs/super.c
> >> @@ -2513,6 +2513,16 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
> >>  		return -EINVAL;
> >>  	}
> >>  
> >> +	/* check whether current kernel supports all features on image */
> >> +	if (le32_to_cpu(raw_super->required_features) &
> > 
> > ...
> > #define F2FS_FEATURE_VERITY	0x0400	/* reserved */
> > ...
> > #define F2FS_FEATURE_CASEFOLD	0x1000
> > #define F2FS_FEATURE_SUPPORT	0x1BFF
> > 
> > 	if (le32_to_cpu(raw_super->required_features) & ~F2FS_FEATURE_SUPPORT) {
> > 		...
> > 		return -EINVAL;
> > 	}
> 
> Um, I thought .required_features are used to store new feature flags from 0x0.
> 
> All 'F2FS_FEATURE_SUPPORT' bits should be stored in sb.feature instead of
> sb.required_features, I'm confused...

I'm thinking,

f2fs-tools     sb->required_features     f2fs    F2FS_FEATURE_SUPPORT
v0             0                         v0      no_check -> ok
v1             0x1BFF                    v0      no_check -> ok
v0             0                         v1      0x1BFF -> ok
v1             0x1BFF                    v1      0x1BFF -> ok
v2             0x3BFF                    v1      0x1BFF -> fail
v1             0x1BFF                    v2      0x3BFF -> ok
v2             0x3BFF                    v2      0x3BFF -> ok

> 
> Thanks,
> 
> > 
> > 
> >> +			~F2FS_INCOMPAT_FEATURES) {
> >> +		f2fs_info(sbi, "Unsupported feature: %x: supported: %x",
> >> +			  le32_to_cpu(raw_super->required_features) ^
> >> +			  F2FS_INCOMPAT_FEATURES,
> >> +			  F2FS_INCOMPAT_FEATURES);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >>  	/* Check checksum_offset and crc in superblock */
> >>  	if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) {
> >>  		crc_offset = le32_to_cpu(raw_super->checksum_offset);
> >> diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
> >> index a2b36b2e286f..4141be3f219c 100644
> >> --- a/include/linux/f2fs_fs.h
> >> +++ b/include/linux/f2fs_fs.h
> >> @@ -117,7 +117,8 @@ struct f2fs_super_block {
> >>  	__u8 hot_ext_count;		/* # of hot file extension */
> >>  	__le16	s_encoding;		/* Filename charset encoding */
> >>  	__le16	s_encoding_flags;	/* Filename charset encoding flags */
> >> -	__u8 reserved[306];		/* valid reserved region */
> >> +	__le32 required_features;       /* incompatible features to old kernel */
> >> +	__u8 reserved[302];		/* valid reserved region */
> >>  	__le32 crc;			/* checksum of superblock */
> >>  } __packed;
> >>  
> >> -- 
> >> 2.22.0
> > .
> > 


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

  reply	other threads:[~2019-08-01  4:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 15:03 [f2fs-dev] [PATCH v3 RESEND] f2fs: introduce sb.required_features to store incompatible features Chao Yu
2019-07-30 23:18 ` Jaegeuk Kim
2019-07-31 10:02   ` Chao Yu
2019-08-01  4:22     ` Jaegeuk Kim [this message]
2019-08-01  7:45       ` Chao Yu
2019-08-01 22:35         ` Jaegeuk Kim
2019-08-02  7:54           ` Chao Yu
2019-08-06  0:35             ` Jaegeuk Kim
2019-08-06  1:01               ` Chao Yu
2019-08-06  1:24                 ` Jaegeuk Kim
2019-08-06  2:01                   ` Chao Yu
2019-08-06  2:11                     ` Jaegeuk Kim
2019-08-06  2:22                       ` Chao Yu
2019-08-09 15:26                         ` Jaegeuk Kim
2019-08-12  7:15                           ` Chao Yu

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=20190801042215.GC84433@jaegeuk-macbookpro.roam.corp.google.com \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).