From patchwork Tue May 8 06:31:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10385433 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 C051C60159 for ; Tue, 8 May 2018 06:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B11E928C9C for ; Tue, 8 May 2018 06:32:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A465328C94; Tue, 8 May 2018 06:32:26 +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.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 16F9428C94 for ; Tue, 8 May 2018 06:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754220AbeEHGcP (ORCPT ); Tue, 8 May 2018 02:32:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:42575 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754204AbeEHGcN (ORCPT ); Tue, 8 May 2018 02:32:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 19DDAAF68 for ; Tue, 8 May 2018 06:32:12 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH RESEND 09/12] btrfs-progs: mkfs: Introduce --runtime-features option Date: Tue, 8 May 2018 14:31:53 +0800 Message-Id: <20180508063156.24665-10-wqu@suse.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508063156.24665-1-wqu@suse.com> References: <20180508063156.24665-1-wqu@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just like -O|--features, introduce -R|--runtime-features to enable features like qgroup, and maybe space cache later. Currently only mkfs is supported, mainly for test purpose. Convert is not supported yet. Signed-off-by: Qu Wenruo --- Documentation/mkfs.btrfs.asciidoc | 16 +++++++++ mkfs/main.c | 56 ++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/Documentation/mkfs.btrfs.asciidoc b/Documentation/mkfs.btrfs.asciidoc index 2a1c3592bcb4..5c8f8f1f70bd 100644 --- a/Documentation/mkfs.btrfs.asciidoc +++ b/Documentation/mkfs.btrfs.asciidoc @@ -125,6 +125,16 @@ features that mkfs.btrfs supports run: + +mkfs.btrfs -O list-all+ +*-R|--runtime-features [,...]*:: +A list of runtime features turned on at mkfs time. +Although no runtime feature is enabled by default, +to disable a feature, prefix it with '^'. ++ +See section *RUNTIME FEATURES* for more details. To see all available +runtime features that mkfs.btrfs supports run: ++ ++mkfs.btrfs -R list-all+ + *-f|--force*:: Forcibly overwrite the block devices when an existing filesystem is detected. By default, mkfs.btrfs will utilize 'libblkid' to check for any known @@ -219,6 +229,12 @@ reduced-size metadata for extent references, saves a few percent of metadata improved representation of file extents where holes are not explicitly stored as an extent, saves a few percent of metadata if sparse files are used +RUNTIME FEATURES +---------------- + +Btrfs has some feature which can be enabled by ioctl after mount. +Some of such features can also be enabled during creation time. + BLOCK GROUPS, CHUNKS, RAID -------------------------- diff --git a/mkfs/main.c b/mkfs/main.c index 388349f87319..f9b3599447ef 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -347,15 +347,16 @@ static void print_usage(int ret) printf("Usage: mkfs.btrfs [options] dev [ dev ... ]\n"); printf("Options:\n"); printf(" allocation profiles:\n"); - printf("\t-d|--data PROFILE data profile, raid0, raid1, raid5, raid6, raid10, dup or single\n"); - printf("\t-m|--metadata PROFILE metadata profile, values like for data profile\n"); - printf("\t-M|--mixed mix metadata and data together\n"); + printf("\t-d|--data PROFILE data profile, raid0, raid1, raid5, raid6, raid10, dup or single\n"); + printf("\t-m|--metadata PROFILE metadata profile, values like for data profile\n"); + printf("\t-M|--mixed mix metadata and data together\n"); printf(" features:\n"); - printf("\t-n|--nodesize SIZE size of btree nodes\n"); - printf("\t-s|--sectorsize SIZE data block size (may not be mountable by current kernel)\n"); - printf("\t-O|--features LIST comma separated list of filesystem features (use '-O list-all' to list features)\n"); - printf("\t-L|--label LABEL set the filesystem label\n"); - printf("\t-U|--uuid UUID specify the filesystem UUID (must be unique)\n"); + printf("\t-n|--nodesize SIZE size of btree nodes\n"); + printf("\t-s|--sectorsize SIZE data block size (may not be mountable by current kernel)\n"); + printf("\t-O|--features LIST comma separated list of filesystem features (use '-O list-all' to list features)\n"); + printf("\t-R|--runtime-features LIST comma separated list of runtime features (use '-R list-all' to list runtime features)\n"); + printf("\t-L|--label LABEL set the filesystem label\n"); + printf("\t-U|--uuid UUID specify the filesystem UUID (must be unique)\n"); printf(" creation:\n"); printf("\t-b|--byte-count SIZE set filesystem size to SIZE (on the first device)\n"); printf("\t-r|--rootdir DIR copy files from DIR to the image root directory\n"); @@ -363,12 +364,12 @@ static void print_usage(int ret) printf("\t-K|--nodiscard do not perform whole device TRIM\n"); printf("\t-f|--force force overwrite of existing filesystem\n"); printf(" general:\n"); - printf("\t-q|--quiet no messages except errors\n"); - printf("\t-V|--version print the mkfs.btrfs version and exit\n"); - printf("\t--help print this help and exit\n"); + printf("\t-q|--quiet no messages except errors\n"); + printf("\t-V|--version print the mkfs.btrfs version and exit\n"); + printf("\t--help print this help and exit\n"); printf(" deprecated:\n"); - printf("\t-A|--alloc-start START the offset to start the filesystem\n"); - printf("\t-l|--leafsize SIZE deprecated, alias for nodesize\n"); + printf("\t-A|--alloc-start START the offset to start the filesystem\n"); + printf("\t-l|--leafsize SIZE deprecated, alias for nodesize\n"); exit(ret); } @@ -867,6 +868,7 @@ int main(int argc, char **argv) int saved_optind; char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 }; u64 features = BTRFS_MKFS_DEFAULT_FEATURES; + u64 runtime_features = 0; struct mkfs_allocation allocation = { 0 }; struct btrfs_mkfs_config mkfs_cfg; @@ -888,6 +890,7 @@ int main(int argc, char **argv) { "rootdir", required_argument, NULL, 'r' }, { "nodiscard", no_argument, NULL, 'K' }, { "features", required_argument, NULL, 'O' }, + { "runtime-features", required_argument, NULL, 'R' }, { "uuid", required_argument, NULL, 'U' }, { "quiet", 0, NULL, 'q' }, { "shrink", no_argument, NULL, GETOPT_VAL_SHRINK }, @@ -895,7 +898,7 @@ int main(int argc, char **argv) { NULL, 0, NULL, 0} }; - c = getopt_long(argc, argv, "A:b:fl:n:s:m:d:L:O:r:U:VMKq", + c = getopt_long(argc, argv, "A:b:fl:n:s:m:d:L:R:O:r:U:VMKq", long_options, NULL); if (c < 0) break; @@ -945,6 +948,25 @@ int main(int argc, char **argv) } break; } + case 'R': { + char *orig = strdup(optarg); + char *tmp = orig; + + tmp = btrfs_parse_runtime_features(tmp, + &runtime_features); + if (tmp) { + error("unrecognized runtime feature '%s'", + tmp); + free(orig); + goto error; + } + free(orig); + if (runtime_features & BTRFS_FEATURE_LIST_ALL) { + btrfs_list_all_runtime_features(0); + goto success; + } + break; + } case 's': sectorsize = parse_size(optarg); break; @@ -1391,8 +1413,10 @@ raid_groups: pretty_size(allocation.system)); printf("SSD detected: %s\n", ssd ? "yes" : "no"); btrfs_parse_fs_features_to_string(features_buf, features); - printf("Incompat features: %s", features_buf); - printf("\n"); + printf("Incompat features: %s\n", features_buf); + btrfs_parse_runtime_features_to_string(features_buf, + runtime_features); + printf("Runtime features: %s\n", features_buf); list_all_devices(root); }