Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3396897ybh; Mon, 5 Aug 2019 18:02:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYTn4UHXAfTznTILBbgJf5AqF7QaRu6Kt86yIFeAP1dG9b4jZEJXy7nS98/fLbC2/J30VX X-Received: by 2002:a65:6904:: with SMTP id s4mr573511pgq.33.1565053322812; Mon, 05 Aug 2019 18:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565053322; cv=none; d=google.com; s=arc-20160816; b=WVkpeGS1AFdJ5+SnaCQS4jlu/E4//8fT5sOBerPAJ3tKdFGpx3+gjnSTLVjziYOq1a qwz8hTxGwK1mghYS7yQhta5xnTUL0BI2B4IgXms+S7snzGImYO2cpU9i/WMwgInECX3j 2460aKzb3e/gQ+ZAsYz6uHnp7mUeqRKPXFdJJgfsBS5syVOwiFeAcTBJ6hDzzZvcDHBp yAXX0zsJaE0ze8XrbKZWIVQN4wKI1iI+NEweQawbXvtM1Fopata7O99xeqy4nidzze2o VCISnFvfunXMEzaztOeamVv0PNXHh8hNeLQZz7csj2daIZOxc1zVoUol/7izLb2YL7Up Lh3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=K8jLiycGaRyfW7YxBqHdSoa9mb4YMg1WU77eQ8eh6Co=; b=yJDhUQZlQYXcIRCVynI12XiR0PwBH3i5tGs76YrefCsC75u3b3huluEaehgVxEUP40 sJmBLYZeErZ+ak+JeGjC6HZIaznOcdIVp8Nl7EPlBeJrAjxjEzIzR/rnaHfhIRzydAfU hAWYRVL/xt3sEvKfA9wsZdADS0QSOGuLm2l6kXa/rCJsQb73Bqm15LqNfbJvDp/voEJK 1DlmAoYGpyoORn7NBKhU4mAl6v9U52ZXlzhe5IHSTnDgfTD2qGphsBRU63TYVCa44OjT 542v/f69Dflx7XjQICJ8A+jKniEuavqyXEkxH1ltmvnZpYynXy3IiSV4cWYWxk8LlIPF JMgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p125si44765719pfp.35.2019.08.05.18.01.45; Mon, 05 Aug 2019 18:02:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731066AbfHFBAv (ORCPT + 99 others); Mon, 5 Aug 2019 21:00:51 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:39146 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730717AbfHFBAu (ORCPT ); Mon, 5 Aug 2019 21:00:50 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A4B06991F57FA1B84805; Tue, 6 Aug 2019 09:00:48 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.209) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 6 Aug 2019 09:00:44 +0800 Subject: Re: [PATCH v3 RESEND] f2fs: introduce sb.required_features to store incompatible features To: Jaegeuk Kim CC: Chao Yu , , References: <20190729150351.12223-1-chao@kernel.org> <20190730231850.GA7097@jaegeuk-macbookpro.roam.corp.google.com> <20190801042215.GC84433@jaegeuk-macbookpro.roam.corp.google.com> <345c55ea-01c2-a9d1-4367-716dbd08ae9d@huawei.com> <20190801223509.GB27597@jaegeuk-macbookpro.roam.corp.google.com> <8e906ddb-81d8-b63e-0c19-1ee9fc7f5cbf@huawei.com> <20190806003522.GA98101@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: Date: Tue, 6 Aug 2019 09:01:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190806003522.GA98101@jaegeuk-macbookpro.roam.corp.google.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/8/6 8:35, Jaegeuk Kim wrote: > On 08/02, Chao Yu wrote: >> On 2019/8/2 6:35, Jaegeuk Kim wrote: >>> On 08/01, Chao Yu wrote: >>>> On 2019/8/1 12:22, Jaegeuk Kim wrote: >>>>> On 07/31, Chao Yu wrote: >>>>>> On 2019/7/31 7:18, Jaegeuk Kim wrote: >>>>>>> On 07/29, Chao Yu wrote: >>>>>>>> From: Chao Yu >>>>>>>> >>>>>>>> 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 >>>>>>>> --- >>>>>>>> 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 >>>> >>>> I see, it's a bit waste for 0x1FFF low bits in sb->required_features. Why not >>>> leaving 0x0FFF in sb->feature w/o sanity check. And make all new incompatible >>>> features (including casefold) adding into sb->required_features. >>> >>> I don't think we can define like this, and we still have 32bits feature filed. >>> This would give another confusion to understand. VERITY is reserved only now. >>> >>> #define F2FS_FEATURE_CASEFOLD 0x0001 >> >> Oops, so you want to make .required_features being almost a mirror of .feature, >> and do sanity check on it... I can see now. :P >> >> If so, why not just use .feature: > > Sometimes, we don't need to set the flag, but not required at some point. > (e.g., verify) Sorry, I'm not sure whether I have understood your point... :( IIUC of your point, we have defined F2FS_FEATURE_SUPPORT (0x0BFF) which excludes F2FS_FEATURE_VERITY (0x0400) feature bit, then once verity feature merged in kernel, we can add it into F2FS_FEATURE_SUPPORT, any problem we may face here? Thanks > >> >> kernel tool >> v5.2 .. 1.12 >> #define F2FS_FEATURE_SUPPORT 0x0BFF >> >> v5.3 .. 1.13 >> #define F2FS_FEATURE_CASEFOLD 0x1000 >> #define F2FS_FEATURE_SUPPORT 0x1BFF >> >> v5.4 .. 1.14 >> #define F2FS_FEATURE_CASEFOLD 0x1000 >> #define F2FS_FEATURE_COMPRESS 0x2000 >> #define F2FS_FEATURE_SUPPORT 0x3BFF >> >> f2fs-tools sb->feature f2fs F2FS_FEATURE_SUPPORT >> >> [enable all features in tools] >> v1.12 0x0BFF v5.2 no_check -> ok >> v1.12 0x0BFF v5.3 0x1BFF -> ok >> v1.12 0x0BFF v5.4 0x3BFF -> ok >> >> v1.13 0x1BFF v5.2 that's issue we need to fix >> v1.13 0x1BFF v5.3 0x1BFF -> ok >> v1.13 0x1BFF v5.4 0x3BFF -> ok >> >> v1.14 0x3BFF v5.2 that's issue we need to fix >> v1.14 0x3BFF v5.3 0x1BFF -> fail >> v1.14 0x3BFF v5.4 0x3BFF -> ok >> >> Or am I missing something? >> >> Thanks, >> >>> >>>> >>>> Then that would be: >>>> >>>> kernel tool >>>> v5.2 .. 1.12 >>>> #define F2FS_FEATURE_SUPPORT 0x0000 >>>> >>>> v5.3 .. 1.13 >>>> #define F2FS_FEATURE_CASEFOLD 0x0001 >>>> #define F2FS_FEATURE_SUPPORT 0x0001 >>>> >>>> v5.4 .. 1.14 >>>> #define F2FS_FEATURE_CASEFOLD 0x0001 >>>> #define F2FS_FEATURE_COMPRESS 0x0002 >>>> #define F2FS_FEATURE_SUPPORT 0x0003 >>>> >>>> f2fs-tools sb->required_features f2fs F2FS_FEATURE_SUPPORT >>>> >>>> v1.12 0x0000 v5.2 no_check -> ok >>>> v1.12 0x0000 v5.3 0x0001 -> ok >>>> v1.12 0x0000 v5.4 0x0003 -> ok >>>> >>>> v1.13 0x0001 v5.2 that's issue we need to fix >>>> v1.13 0x0001 v5.3 0x0001 -> ok >>>> v1.13 0x0001 v5.4 0x0003 -> ok >>>> >>>> v1.14 0x0003 v5.2 that's issue we need to fix >>>> v1.14 0x0003 v5.3 0x0001 -> fail >>>> v1.14 0x0003 v5.4 0x0003 -> ok >>>> >>>> And all compatible features can be added into sb->feature[_VERITY, ....]. >>>> >>>> Would that okay to you? >>>> >>>> Thanks, >>>> >>>>> >>>>>> >>>>>> 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 >>>>>>> . >>>>>>> >>>>> . >>>>> >>> . >>> > . >