From patchwork Tue May 29 22:06:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 10437217 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 17BC7601C7 for ; Tue, 29 May 2018 22:06:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 038C92891B for ; Tue, 29 May 2018 22:06:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC4BA28927; Tue, 29 May 2018 22:06:10 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 54D3E2892B for ; Tue, 29 May 2018 22:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967464AbeE2WGJ (ORCPT ); Tue, 29 May 2018 18:06:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:45212 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967446AbeE2WGI (ORCPT ); Tue, 29 May 2018 18:06:08 -0400 Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FF202089D; Tue, 29 May 2018 22:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527631567; bh=E2zHimRdNH27hzO+9JjVXD6MsoXS7zIV40ApzkyjIp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckV5QYJe28sOrCifWxQ2TXDgoVP1SfkJOs+Dpe49CpW7/CqmhwV9UAaxg7Y1FBH8X 5QlAygMbJWnEdi3+vIOF/f8eYBhgvEfUIAz1fbS+m8ahZ+hyQPXiTW4m1iF8DAzkkC Ccio9bsqhSYCdm1JOu4gvrOeLseh+jeBYXnI6Ulg= From: "Luis R. Rodriguez" To: sandeen@sandeen.net, linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, jack@suse.com, jeffm@suse.com, okurz@suse.com, lpechacek@suse.com, jtulak@redhat.com, "Luis R. Rodriguez" Subject: [PATCH v4 2/4] mkfs: move shared config structs and into their own headers Date: Tue, 29 May 2018 15:06:01 -0700 Message-Id: <20180529220603.29420-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180529220603.29420-1-mcgrof@kernel.org> References: <20180529220603.29420-1-mcgrof@kernel.org> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Both struct sb_feat_args and struct mkfs_default_params will be shared between CLI processing and the configuration file processing added later, so move these to their own header. This will help ensure we split things neatly later and also will help ensure the configuration file processing code from the CLI code are kept separate and cannot touch each other's data structures. This also makes it clear what is actually shared between both. There are no introduced functional changes in this commit and no documentation changes, this is just code shuffling. Reviewed-by: Darrick J. Wong Signed-off-by: Luis R. Rodriguez Reviewed-by: Dave Chinner --- mkfs/config.h | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mkfs/xfs_mkfs.c | 55 +--------------------------------------- 2 files changed, 79 insertions(+), 54 deletions(-) create mode 100644 mkfs/config.h diff --git a/mkfs/config.h b/mkfs/config.h new file mode 100644 index 000000000000..e5ea968e2d65 --- /dev/null +++ b/mkfs/config.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000-2005 Silicon Graphics, Inc. + * Copyright (c) 2016-2017 Red Hat, Inc. + * All Rights Reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef _XFS_MKFS_CONFIG_H +#define _XFS_MKFS_CONFIG_H + +struct fsxattr; + +/* + * Shared superblock configuration options + * + * These options provide shared configuration tunables for the filesystem + * superblock. There are three possible sources for these options set, each + * source can overriding the later source: + * + * o built-in defaults + * o configuration file (XXX) + * o command line + * + * These values are not used directly - they are inputs into the mkfs geometry + * validation. + */ +struct sb_feat_args { + int log_version; + int attr_version; + int dir_version; + bool inode_align; /* XFS_SB_VERSION_ALIGNBIT */ + bool nci; /* XFS_SB_VERSION_BORGBIT */ + bool lazy_sb_counters; /* XFS_SB_VERSION2_LAZYSBCOUNTBIT */ + bool parent_pointers; /* XFS_SB_VERSION2_PARENTBIT */ + bool projid32bit; /* XFS_SB_VERSION2_PROJID32BIT */ + bool crcs_enabled; /* XFS_SB_VERSION2_CRCBIT */ + bool dirftype; /* XFS_SB_VERSION2_FTYPE */ + bool finobt; /* XFS_SB_FEAT_RO_COMPAT_FINOBT */ + bool spinodes; /* XFS_SB_FEAT_INCOMPAT_SPINODES */ + bool rmapbt; /* XFS_SB_FEAT_RO_COMPAT_RMAPBT */ + bool reflink; /* XFS_SB_FEAT_RO_COMPAT_REFLINK */ + bool nodalign; + bool nortalign; +}; + +/* + * Default filesystem features and configuration values + * + * This structure contains the default mkfs values that are to be used when + * a user does not specify the option on the command line. We do not use these + * values directly - they are inputs to the mkfs geometry validation and + * calculations. + */ +struct mkfs_default_params { + char *source; /* where the defaults came from */ + + int sectorsize; + int blocksize; + + /* feature flags that are set */ + struct sb_feat_args sb_feat; + + /* root inode characteristics */ + struct fsxattr fsx; +}; + +#endif /* _XFS_MKFS_CONFIG_H */ diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 84e9d6b2562a..4664e507afbf 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -21,6 +21,7 @@ #include "xfs_multidisk.h" #include "libxcmd.h" #include "fsgeom.h" +#include "config.h" #define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog))) @@ -706,39 +707,6 @@ cli_opt_set( opts->subopt_params[subopt].str_seen; } -/* - * Shared superblock configuration options - * - * These options provide shared configuration tunables for the filesystem - * superblock. There are three possible sources for these options set, each - * source can overriding the later source: - * - * o built-in defaults - * o configuration file (XXX) - * o command line - * - * These values are not used directly - they are inputs into the mkfs geometry - * validation. - */ -struct sb_feat_args { - int log_version; - int attr_version; - int dir_version; - bool inode_align; /* XFS_SB_VERSION_ALIGNBIT */ - bool nci; /* XFS_SB_VERSION_BORGBIT */ - bool lazy_sb_counters; /* XFS_SB_VERSION2_LAZYSBCOUNTBIT */ - bool parent_pointers; /* XFS_SB_VERSION2_PARENTBIT */ - bool projid32bit; /* XFS_SB_VERSION2_PROJID32BIT */ - bool crcs_enabled; /* XFS_SB_VERSION2_CRCBIT */ - bool dirftype; /* XFS_SB_VERSION2_FTYPE */ - bool finobt; /* XFS_SB_FEAT_RO_COMPAT_FINOBT */ - bool spinodes; /* XFS_SB_FEAT_INCOMPAT_SPINODES */ - bool rmapbt; /* XFS_SB_FEAT_RO_COMPAT_RMAPBT */ - bool reflink; /* XFS_SB_FEAT_RO_COMPAT_REFLINK */ - bool nodalign; - bool nortalign; -}; - /* * Options configured on the command line. * @@ -850,27 +818,6 @@ struct mkfs_params { struct sb_feat_args sb_feat; }; -/* - * Default filesystem features and configuration values - * - * This structure contains the default mkfs values that are to be used when - * a user does not specify the option on the command line. We do not use these - * values directly - they are inputs to the mkfs geometry validation and - * calculations. - */ -struct mkfs_default_params { - char *source; /* where the defaults came from */ - - int sectorsize; - int blocksize; - - /* feature flags that are set */ - struct sb_feat_args sb_feat; - - /* root inode characteristics */ - struct fsxattr fsx; -}; - static void __attribute__((noreturn)) usage( void ) {