From patchwork Thu May 19 17:46:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav Dubeyko X-Patchwork-Id: 9128025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0C9860221 for ; Thu, 19 May 2016 17:46:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6C55281B3 for ; Thu, 19 May 2016 17:46:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB7F1281BA; Thu, 19 May 2016 17:46:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2342B281B3 for ; Thu, 19 May 2016 17:46:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932794AbcESRqL (ORCPT ); Thu, 19 May 2016 13:46:11 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33376 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932765AbcESRqJ (ORCPT ); Thu, 19 May 2016 13:46:09 -0400 Received: by mail-pf0-f170.google.com with SMTP id 206so32565269pfu.0 for ; Thu, 19 May 2016 10:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:mime-version :content-transfer-encoding; bh=Zt0kzF8oXjQLiHp9CPjAYsQtijwzq1pCMUazK8FGW40=; b=nb4J460RyeQ5TeWSxjsekJmh+uClt8pgyD699YJyId4aocfeF3Q/T9yoax98x6oavt 2o8eWg28HpfXj4hPnwK0o7FWVu+nbyreJ8BdRCtTg1RTh7QFOV5gL9gjJZ5d8F0DJhg6 Zc6TtZh/zRgpahEHeKMxTwo33uHj8RF1CKdLdA52pk7VnJC2krB3Q9dLkZWyFxNM/XfE h0COVS+0elJZs2qXbPMO4rdoGmYxHDdKZr0VVugyhDloE31If55I/S1JqqNAOLsAcm+y aGAwkIeqX2cBJttQ2IzbEKQLlWw1e8VwkhJkY54Zz6EhvvGLnXE40wvkmRjsLJZxoEaM hNKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:mime-version :content-transfer-encoding; bh=Zt0kzF8oXjQLiHp9CPjAYsQtijwzq1pCMUazK8FGW40=; b=fo84GIE39/GFcoLX1xbKvLbmkH4fPRApC05+tPROv/HQqgADRxlgf7hkkey14RzewI c4HSvaOlPIkLeIdLp3J/aabzaMHYkwFwZqdW0dnA1CizqtmExWxDoDKV8RH4gOYUgZp3 8y3zGM29t6W+CeuE/gS8pvoGBXg5C6/bp70bSIDHo9oxvcPB7lWKlZvYq0ufOvhNtuPp DTOzHRdWrWA3osAeO+RJ908QDW2s7MVVWNPpoMnPP6dvOQwKtTDVJ8dik1JyY9zcavPk 1jkYhmyYpD24Wb1WG9jOvG5XhElahOSmBimls3MrkGbQQsS/DFTscfTGCwlNumqCv7AV /khQ== X-Gm-Message-State: AOPr4FXI6L17T02RcigOGgBynS+lxB/r76SyDCW/3UXK8lnwRPPIdYEn/161AeBMBm2j4Q== X-Received: by 10.98.54.193 with SMTP id d184mr21667371pfa.59.1463679968202; Thu, 19 May 2016 10:46:08 -0700 (PDT) Received: from [10.82.7.163] (sjc00ib2.hgst.com. [199.255.44.5]) by smtp.gmail.com with ESMTPSA id lg17sm12102134pab.36.2016.05.19.10.46.06 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 May 2016 10:46:07 -0700 (PDT) Message-ID: <1463679966.3573.4.camel@slavad-ubuntu-14.04> Subject: [PATCH] f2fs: introduce on-disk layout version checking functionality From: Viacheslav Dubeyko To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Vyacheslav.Dubeyko@hgst.com, Cyril.Guyot@hgst.com, Adam.Manzanares@hgst.com, Damien.LeMoal@hgst.com Date: Thu, 19 May 2016 10:46:06 -0700 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vyacheslav Dubeyko Date: Wed, 18 May 2016 15:58:00 -0700 Subject: [PATCH] f2fs: introduce on-disk layout version checking functionality Currently, F2FS has 16TB limitation on volume size. But 16TB NAND-based SSDs are around the corner. Unfortunately, support of 16TB+ volume size needs in modification of on-disk layout metadata structures that will be incompatible with current version of F2FS's on-disk layout. This patch implements support of checking version of F2FS on-disk layout. The F2FS superblock contains major_ver and feature fields. Implemented functionality checks the major_ver field and presence of flag that declares 16TB+ volumes support. If file system driver is unable to support 16TB+ volume size then mount of operation of F2FS volume with incompatible version or feature will fail. Signed-off-by: Vyacheslav Dubeyko CC: Vyacheslav Dubeyko CC: Jaegeuk Kim CC: Cyril Guyot CC: Adam Manzanares CC: Damien Le Moal --- fs/f2fs/Kconfig | 12 ++++++++++++ fs/f2fs/f2fs.h | 10 +++++++++- fs/f2fs/super.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig index 1f8982a..ec6bba4 100644 --- a/fs/f2fs/Kconfig +++ b/fs/f2fs/Kconfig @@ -94,3 +94,15 @@ config F2FS_IO_TRACE information and block IO patterns in the filesystem level. If unsure, say N. + +config F2FS_16TB_VOLUME_SUPPORT + bool "Support for large (16TB+) F2FS volumes" + depends on F2FS_FS + default n + help + Enable support of 16TB and larger F2FS volumes. + + This feature is under implementation right now. So, no real support + is available yet. + + If unsure, say N. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 7a4558d..8fa3acc 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -37,6 +37,13 @@ } while (0) #endif +#ifdef CONFIG_F2FS_16TB_VOLUME_SUPPORT +#define F2FS_MAX_SUPP_MAJOR_VERSION (2) +#define F2FS_MIN_16TB_VOLUME_SUPPORT_VERSION (2) +#else +#define F2FS_MAX_SUPP_MAJOR_VERSION (1) +#endif + /* * For mount options */ @@ -75,7 +82,8 @@ struct f2fs_mount_info { unsigned int opt; }; -#define F2FS_FEATURE_ENCRYPT 0x0001 +#define F2FS_FEATURE_ENCRYPT (1 << 0) +#define F2FS_FEATURE_16TB_SUPPORT (1 << 1) #define F2FS_HAS_FEATURE(sb, mask) \ ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 006f87d..9dcb7a4 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1318,6 +1318,53 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover) return err; } +static int f2fs_check_version_and_features(struct super_block *sb, + struct f2fs_super_block *raw_super) +{ + u16 major_ver = le16_to_cpu(raw_super->major_ver); + u32 feature = le32_to_cpu(raw_super->feature); + + if (major_ver > F2FS_MAX_SUPP_MAJOR_VERSION) { + f2fs_msg(sb, KERN_CRIT, + "Failed to mount volume: " + "major version %u, max supported version %u", + major_ver, + F2FS_MAX_SUPP_MAJOR_VERSION); + return -EOPNOTSUPP; + } + +#ifdef CONFIG_F2FS_16TB_VOLUME_SUPPORT + + if (major_ver < F2FS_MIN_16TB_VOLUME_SUPPORT_VERSION) { + if (feature & F2FS_FEATURE_16TB_SUPPORT) { + f2fs_msg(sb, KERN_CRIT, + "Failed to mount corrupted volume. " + "Please, check the volume by FSCK utility."); + return -EOPNOTSUPP; + } + } else { + if (!(feature & F2FS_FEATURE_16TB_SUPPORT)) { + f2fs_msg(sb, KERN_CRIT, + "Failed to mount corrupted volume. " + "Please, check the volume by FSCK utility."); + return -EOPNOTSUPP; + } + } + +#else + + if (feature & F2FS_FEATURE_16TB_SUPPORT) { + f2fs_msg(sb, KERN_CRIT, + "Failed to mount corrupted volume. " + "Please, check the volume by FSCK utility."); + return -EOPNOTSUPP; + } + +#endif + + return 0; +} + static int f2fs_fill_super(struct super_block *sb, void *data, int silent) { struct f2fs_sb_info *sbi; @@ -1360,6 +1407,10 @@ try_onemore: if (err) goto free_sbi; + err = f2fs_check_version_and_features(sb, raw_super); + if (err) + goto free_sbi; + sb->s_fs_info = sbi; default_options(sbi); /* parse mount options */