Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6826834ybi; Wed, 31 Jul 2019 22:33:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFM6IvfKwG6CLJL/9OhyXHYjbgD1EcAo1zgcD5bc53is2cTN18PCAodcNTscut0Hj27eXV X-Received: by 2002:a17:90a:2648:: with SMTP id l66mr6503391pje.65.1564637582161; Wed, 31 Jul 2019 22:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564637582; cv=none; d=google.com; s=arc-20160816; b=WMjbpuCL25fTIln9OuHMw3AUyhyzITqkyq1XayQKxxWI5pfI8iCyCump7uO/0Kzdk5 mS78CnnQX1yasKEd0N60dhy5OeeI0btuBFBAR7vrPvTgA5rW5dmSGRzzKzGeG2lcMqOD u4ADQOLpzgM5E7INq1pUFhCceZnB13OwZ2Ll5fV70EEvkvftrYAV2lrJWMJmuvf6z2gG xkVgHaa05eDBsdfA/ijbSHj/E429g8T+kBkfIow580vq178E9kjLhWIGaVjuazqCAB3d lDe1PguL5ONORSGHRrOklcw6DiPKvGCP/Q7phJ5kDmbnByCko/TFbytoapU3+hGnUDHM Qlzg== 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=T6v0Hy6+ysmT9ltjwHBcIVLbLKn8iAbZ6fuya3fIYTM=; b=LO5UA0VSB+X5QApt5wjZvKijIPWiV0TiYb+KGuYPIiR1upZaHnsjIOSXwNSq+o30Sh X32qMA5Gsijw9SLTCnbDt3ofoB/USQliWMn0OG/Mi+XzMPBozj6Zn+/LLB34mtb4pQDV ysnDKHTmwHGk8crkD8FduaqI1MStYFSF7JrXtBIb9sjFnwtFQ1YvdnWyTQQ7eDJBg+2T 8JiuqA1DgbIWVw5g8mKveOqM9Ve2x8xYFy1E9Sc/+fxjNYE6TCb9ogK0hQoLF88icGCy xhd1B6eJCVDGjl1YaXgqV9pwcasJnNON0tcChhDIe5gSbUEoCMO+us7ksGZpZtj/ci6l euCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="b/SwCI6C"; 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 w18si29966618pll.132.2019.07.31.22.32.44; Wed, 31 Jul 2019 22:33: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; dkim=pass header.i=@kernel.org header.s=default header.b="b/SwCI6C"; 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 S1726936AbfHAEWR (ORCPT + 99 others); Thu, 1 Aug 2019 00:22:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:36006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfHAEWR (ORCPT ); Thu, 1 Aug 2019 00:22:17 -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 92CE8206B8; Thu, 1 Aug 2019 04:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564633335; bh=wX3aVTKu4GQPcVJzRJpgGpEpqupjqD0i6Q9nh8qWnK4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b/SwCI6Cpy109EtBNqad4RqL+FNau8hYh1Ex0ejxlmXr0cACwc1LtzB550QQwlawK qaJksGju8dh82nrD+EQ3L6TSHRYFQbUA10JAJLznO6ISLrbmlfp2ylyXkJiQ5nET5+ LFNEyHxADIBaqxti0VT9erTDxk5gm4igGVz7zE4o= Date: Wed, 31 Jul 2019 21:22:15 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 RESEND] f2fs: introduce sb.required_features to store incompatible features Message-ID: <20190801042215.GC84433@jaegeuk-macbookpro.roam.corp.google.com> References: <20190729150351.12223-1-chao@kernel.org> <20190730231850.GA7097@jaegeuk-macbookpro.roam.corp.google.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/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 > > 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 > > . > >