Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2999422ybi; Sun, 28 Jul 2019 22:49:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhk05Mv0MRKV7kyVsZfSrc1EXbA2lGAY877SgreUn6hfMbeKW+QOsYgFn938/g2y04RcyY X-Received: by 2002:a17:902:324:: with SMTP id 33mr105309556pld.340.1564379363933; Sun, 28 Jul 2019 22:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564379363; cv=none; d=google.com; s=arc-20160816; b=Sv0/2ANwh5CvC8ieXshye8cwdh13KiL+BEIX+2ES/ywTc+ZfPMTocxudfVNL492tyL b+4+aJWVvlY/o16SGwOt6GYMVoeCxF3PAVbrvFvHl66Cady9BaQSsCo2YahL+udGC5J4 p/0R5KuInxFn2oTbijfWntejIL6d99o7E4bYkCCygKKTcIryPSOtnA+R0bDeXMpold1W 3+4Ki7yDhQ+JQ19QTfTXei3/O1YgzGCJRd0ahQV5t7ESnxD6a2KXbWqe+APn2y1y4UTK /lugxcX9eFuv/OD9SVsHIjp3ATx1lo60OKfuSi3dp4HtyQiyi71PTone0rSpSnth/7dE iuGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+y5hVpYQ5zAt8g3Y8VsYvqZ+gT+Uk1zz8LAv0s6Djaw=; b=e5hiaYRWavSyr/xqURjT25C+lfm4UubgUwBCdg2SKiA2i/ZCsCfX3Q1optPWhKnvVl 0w25QQ9KWXP6aGhUSJDAN8T0NYCFpET1yGO5+FgDg8GwB+S+rRs+3NTHQYBKG74nd/Bp 0I8suListhHYmUJ/dCQFQy6umS55ghQ7Zq507orLhhCSZYWee9wPf/cDmpH7PX6k3QQG ABbWZPxdObFNvl0ntWY1jUOnRZRlZ5FikNKdM/+XF2ihVn7yQVDg1coB6dUzTAJjI79T qYdz2Sz6+92jaHGwq0+3KL5+DhIVPtE3Vp3QcXbx3d4LNodt3ZH/GqMF9oW+RerCoOxd vBYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dFxOndZN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7si26003259pgi.401.2019.07.28.22.49.08; Sun, 28 Jul 2019 22:49:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=dFxOndZN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726622AbfG2FrI (ORCPT + 99 others); Mon, 29 Jul 2019 01:47:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:60998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725988AbfG2FrI (ORCPT ); Mon, 29 Jul 2019 01:47:08 -0400 Received: from localhost (c-98-234-77-170.hsd1.ca.comcast.net [98.234.77.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 948852070B; Mon, 29 Jul 2019 05:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564379226; bh=yZNgVI84KFPxzIYsaVwbo027q4ATv/wHbHzHadEmIXQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dFxOndZNPXrVMx5B9kzsiQB0+H226fN4oVSDw8vqJd4ILcT8WGVKZwNdkWGXBTLoY kJhN5gDp27YiIz0P73A+qjuGnKMdpUVOotYeVUgL25Gyp2OGHfiSrodipbZx8LBt9A XX6UWsIkSliIkcQ8UK20ajXO3wIvUU17UiKcAZsY= Date: Sun, 28 Jul 2019 22:47:06 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Chao Yu , 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 Message-ID: <20190729054706.GB94090@jaegeuk-macbookpro.roam.corp.google.com> References: <20190424094850.118323-1-yuchao0@huawei.com> <20190428133802.GB37346@jaegeuk-macbookpro.roam.corp.google.com> <373f4633-d331-5cf3-74b7-e982072bc4b4@kernel.org> <20190501032242.GA84420@jaegeuk-macbookpro.roam.corp.google.com> <3f170d86-e556-13ae-ce19-3bba3944f5fa@huawei.com> <192bae92-2193-570f-7b50-00334271bd2e@huawei.com> <20190723013546.GA60778@jaegeuk-macbookpro.roam.corp.google.com> <00726135-f210-7791-a372-ef9cb1ae209f@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00726135-f210-7791-a372-ef9cb1ae209f@huawei.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/23, Chao Yu wrote: > On 2019/7/23 9:35, Jaegeuk Kim wrote: > > On 07/16, Chao Yu wrote: > >> 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. > > > > How about adding required_features flag in sb to check part of features only? > > You mean all incompatible features can be add into sb.required_features later > like this? > > __le32 required_features; /* incompatible feature to old kernel */ > > And we can check required_features with supported features in current kernel? Yeah, I think so. > > if (le32_to_cpu(raw_super->required_features) & > (~NOW_SUPPORTED_FEATURES_IN_CURRENT_KERNEL)) { > print msg & ret error; > } > > Thanks, > > > > >> > >> 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 > >>>>>>>> --- > >>>>>>>> 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 > >>> . > >>> > > . > >