From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32DCFC7618F for ; Tue, 23 Jul 2019 01:35:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0315A21E70 for ; Tue, 23 Jul 2019 01:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563845750; bh=FPkhYZRerqlQyPmcW02dE8STqYcZI7MQzFDIeGLxF5E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=NcEpwMSDmBkT+d13w67m0HoVBKAfYAkbQrAcTbfMWRCSTnWNpzvCfEXEPmghrT580 6YgacHios97HvPPZo8+2q+ckIPyB56FBx2PpK+6b0m1K1V042WTV1CuMUfblgZquEt Kgb7ctzdTgU0PzaR6DXplfIhYRI7zG5ujXvQY2O4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387791AbfGWBfs (ORCPT ); Mon, 22 Jul 2019 21:35:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:42150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726590AbfGWBfs (ORCPT ); Mon, 22 Jul 2019 21:35:48 -0400 Received: from localhost (unknown [104.132.0.81]) (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 25B0A21BF6; Tue, 23 Jul 2019 01:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563845747; bh=FPkhYZRerqlQyPmcW02dE8STqYcZI7MQzFDIeGLxF5E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NLgWqwWaHXADqJBkd8U7l6lbJJeIbxkQ4KjdPlEL8JBdTq9x4yzh4Zd+2mQwbgsUI +s6VOnjnGW75bkxav6MNivZK3GmtBTjuEXrGLNoGmSJdID1+sgYpqO/sFn/SEQpFOq mXyPC7ZXH6emOEQ/bO0hTzDRqwFqZx16ehJP6gFc= Date: Mon, 22 Jul 2019 18:35:46 -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: <20190723013546.GA60778@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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/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? > > 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 > > . > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09218C76190 for ; Tue, 23 Jul 2019 01:35:58 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D033121BF6 for ; Tue, 23 Jul 2019 01:35:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="NaxD4YzK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="KC/sp8bS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="NLgWqwWa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D033121BF6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hpjif-0002i5-AB; Tue, 23 Jul 2019 01:35:57 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hpjie-0002hp-7J for linux-f2fs-devel@lists.sourceforge.net; Tue, 23 Jul 2019 01:35:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0GjgOgR3gD/mOra/6TGu35pOg65gFEpInUErLROoMLU=; b=NaxD4YzKWUvaSziero1Vx/retB amNbs8T0izMpfn2d2BeY9WQKUQpyQz6XTCCe1qSZ7NywFi98QEyOyHEuJQQd8N0SFYuailTJs0eM9 gPCpKYH0YiAeO3Mz6fGWcEO0WRTw39a6P7HJHKcaGHy7m2XOd9WDitfhbhpeqZlZbxbA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0GjgOgR3gD/mOra/6TGu35pOg65gFEpInUErLROoMLU=; b=KC/sp8bS7QcyZ7Gx9HpsGmKUjX 7ZD8JTMPyNJXOrShBgUg04ecqHc6g14lIMQSkwI0dJQ5QgN5fCFx9Q4P+nVHja3HNXmVRaHq4/42J c/Sc3N3RazZunLiapr2ZKBhz64lagvw1ln/Fi2kUt4pG+8DtkVMAUPxgXqb6tKc9AAjw=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hpjia-00BRFP-On for linux-f2fs-devel@lists.sourceforge.net; Tue, 23 Jul 2019 01:35:56 +0000 Received: from localhost (unknown [104.132.0.81]) (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 25B0A21BF6; Tue, 23 Jul 2019 01:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563845747; bh=FPkhYZRerqlQyPmcW02dE8STqYcZI7MQzFDIeGLxF5E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NLgWqwWaHXADqJBkd8U7l6lbJJeIbxkQ4KjdPlEL8JBdTq9x4yzh4Zd+2mQwbgsUI +s6VOnjnGW75bkxav6MNivZK3GmtBTjuEXrGLNoGmSJdID1+sgYpqO/sFn/SEQpFOq mXyPC7ZXH6emOEQ/bO0hTzDRqwFqZx16ehJP6gFc= Date: Mon, 22 Jul 2019 18:35:46 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: <20190723013546.GA60778@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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.2 (2017-04-18) X-Headers-End: 1hpjia-00BRFP-On Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to do sanity with enabled features in image X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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? > > 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 > > . > > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel