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 <w...@suse.com>
---
 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 <feature1>[,<feature2>...]*::
+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);
        }
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to