Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1034713yba; Sat, 4 May 2019 19:54:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGcOPGcVrwgsIHGWkc5a1/RUTWJnp5bHTSu2cVlxlM8ZBn9tjCFxx6HI0JEjeXLV4StptC X-Received: by 2002:aa7:8243:: with SMTP id e3mr23106985pfn.213.1557024881035; Sat, 04 May 2019 19:54:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557024881; cv=none; d=google.com; s=arc-20160816; b=MIG3FLhIt18JEjNyPCCdponKv37bEDgFkMT4Q9ZwLLMc1nqypJnUU1SzX+4lAe3+p9 6liuBEDFIdHvXzwz0I5vPw85OL3gofq3PVsi08xuttvGZU5E/IG0+eh+gencQa96KaAQ JZ02z/0pVO1Xvvq1plaIvbGG5ISnm7TQ3n09rbZqMkYORx1q5Ocuv1WFOpBpPIpiry4Y 72AYpHIIrBnM3TYi9J3UKFcsXA/IJJ118EMhe89QVJ/EPMDug5Ge2oj9Oi0KCAOvGwgk UH0b3NHnKxNwDATD9qesdckvWmn1sLgi2RzxOeRS7MUJMkbSCHEnNzW6N4VGgVW2fb2d xn7Q== 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=GqBQ0Pc5dyQqL2kZGrSEkS4yXzAecBupUVEpDbxLCkk=; b=y1qRgfW0KlYhQtFnHgyJzl32iw/CThZb7VDJq8P4s32B1soWVfzVx0LG3XhB/jLDMD sOTynz0QGx46hzfzkpeR0UKgtfBq5maVtFvOqNqoJmJUEsBTlK4Ru5uL8h4tyw+Kk77s SBW2wUZu8kPp5iqW18KRiLyNgP9UVkqQlMqhsQOv0zXyLtTdJpKP/M7pMn0uakWqlXV4 Rj2uAvEaqhwC1R+ubZqVtO8y397TVCkrqfeKPxKENj8aA0DVspLcSACaRHgesbprOdud 9Tp36VgtFu6vmC+MkJ5ocYRSiDzvfncWDIr5pBeYUwIe6UIQpevvsk+Nfnkxty3VHiav j9pw== 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 e192si9038501pgc.222.2019.05.04.19.54.25; Sat, 04 May 2019 19:54:41 -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 S1727454AbfEECwC (ORCPT + 99 others); Sat, 4 May 2019 22:52:02 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:48650 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726636AbfEECwC (ORCPT ); Sat, 4 May 2019 22:52:02 -0400 Received: from DGGEMM405-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id 6FEAC39961684DCBA09C; Sun, 5 May 2019 10:51:59 +0800 (CST) Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by DGGEMM405-HUB.china.huawei.com (10.3.20.213) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 5 May 2019 10:51:58 +0800 Received: from [10.134.22.195] (10.134.22.195) by dggeme763-chm.china.huawei.com (10.3.19.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Sun, 5 May 2019 10:51:58 +0800 Subject: Re: [PATCH] f2fs: fix to do sanity with enabled features in image To: Jaegeuk Kim , Chao Yu CC: , 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> From: Chao Yu Message-ID: <3f170d86-e556-13ae-ce19-3bba3944f5fa@huawei.com> Date: Sun, 5 May 2019 10:51:35 +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: <20190501032242.GA84420@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-ClientProxiedBy: dggeme768-chm.china.huawei.com (10.3.19.114) To dggeme763-chm.china.huawei.com (10.3.19.109) 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/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. >> >> 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. 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 > . >