From 6ee4ab24da40bf1f818c666f85fe80c62cf81612 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 8 May 2018 14:31:54 +0800 Subject: [PATCH] btrfs-progs: mkfs: introduce quota runtime feature Add support for enabling quotas at mkfs time. The qgroup accounting will be consistent, ie. works with --rootdir. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- Documentation/mkfs.btrfs.asciidoc | 6 ++++++ common/fsfeatures.c | 3 +++ common/fsfeatures.h | 2 ++ mkfs/main.c | 7 +++++++ 4 files changed, 18 insertions(+) diff --git a/Documentation/mkfs.btrfs.asciidoc b/Documentation/mkfs.btrfs.asciidoc index 8fc8e092..2ddd63c0 100644 --- a/Documentation/mkfs.btrfs.asciidoc +++ b/Documentation/mkfs.btrfs.asciidoc @@ -244,6 +244,12 @@ option or by an ioctl. Some of them can be enabled early, at mkfs time. This applies to features that need to be enabled once and then the status is permanent, this does not replace mount options. +*quota*:: +(kernel support since 3.4) ++ +Enable quota support (qgroups). The qgroup accounting will be consistent, +can be used together with '--rootdir'. See also `btrfs-quota`(8). + BLOCK GROUPS, CHUNKS, RAID -------------------------- diff --git a/common/fsfeatures.c b/common/fsfeatures.c index 4b614705..ae075daf 100644 --- a/common/fsfeatures.c +++ b/common/fsfeatures.c @@ -104,6 +104,9 @@ static const struct btrfs_feature mkfs_features[] = { }; static const struct btrfs_feature runtime_features[] = { + { "quota", BTRFS_RUNTIME_FEATURE_QUOTA, NULL, + VERSION_TO_STRING2(3, 4), NULL, 0, NULL, 0, + "quota support (qgroups)" }, /* Keep this one last */ { "list-all", BTRFS_FEATURE_LIST_ALL, NULL } }; diff --git a/common/fsfeatures.h b/common/fsfeatures.h index 7ea4a2b4..13141254 100644 --- a/common/fsfeatures.h +++ b/common/fsfeatures.h @@ -39,6 +39,8 @@ #define BTRFS_FEATURE_LIST_ALL (1ULL << 63) +#define BTRFS_RUNTIME_FEATURE_QUOTA (1ULL << 0) + void btrfs_list_all_fs_features(u64 mask_disallowed); void btrfs_list_all_runtime_features(u64 mask_disallowed); char *btrfs_parse_fs_features(char *namelist, u64 *flags); diff --git a/mkfs/main.c b/mkfs/main.c index 5cf1b765..74e1ed6e 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -1484,6 +1484,13 @@ raid_groups: } } + if (runtime_features & BTRFS_RUNTIME_FEATURE_QUOTA) { + ret = setup_quota_root(fs_info); + if (ret < 0) { + error("failed to initialize quota: %d (%m)", ret); + goto out; + } + } if (verbose) { char features_buf[64];