summaryrefslogtreecommitdiff
path: root/cmds-qgroup.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>2013-10-07 15:21:42 +0800
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:23:12 -0400
commit737a373638329138caa4fbd45299a8f4bab7925e (patch)
tree3187bbbe6b3b7985c42ec9ac97ddc30a689b9379 /cmds-qgroup.c
parentae26ff16f85aa6604a8b0d4c7065a3b02c1c78d1 (diff)
Btrfs-progs: list all qgroups impact given path(include ancestral qgroups)
This patch introduces '-F' option which can help you filter the qgroups by the path name, you may use it like: btrfs qgroup show -F <path> For example: qgroupid(2/0) / \ / \ qgroupid(1/0) / \ / \ / \ qgroupid(0/1) qgroupid(0/2) sub1 sub2 / \ / \ dir1 file1 If we use the command: btrfs qgroup show -F sub1/dir1 The result will output 0/1 -- -- 1/0 -- -- 2/0 -- -- '-F' option help you list all qgroups impact given path. (include ancestral qgroups). Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-qgroup.c')
-rw-r--r--cmds-qgroup.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index fc9ad2f8..7c6c9176 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -202,12 +202,14 @@ static int cmd_qgroup_destroy(int argc, char **argv)
}
static const char * const cmd_qgroup_show_usage[] = {
- "btrfs qgroup show -pcre <path>",
- "Show all subvolume quota groups.",
+ "btrfs qgroup show -pcreF <path>",
+ "Show subvolume quota groups.",
"-p print parent qgroup id",
"-c print child qgroup id",
"-r print max referenced size of qgroup",
"-e print max exclusive size of qgroup",
+ "-F list all qgroups which impact the given path"
+ "(include ancestral qgroups)",
NULL
};
@@ -219,10 +221,15 @@ static int cmd_qgroup_show(int argc, char **argv)
int e;
DIR *dirstream = NULL;
int c;
+ u64 qgroupid;
+ int filter_flag = 0;
+
+ struct btrfs_qgroup_filter_set *filter_set;
+ filter_set = btrfs_qgroup_alloc_filter_set();
optind = 1;
while (1) {
- c = getopt(argc, argv, "pcre");
+ c = getopt(argc, argv, "pcreF");
if (c < 0)
break;
switch (c) {
@@ -242,6 +249,9 @@ static int cmd_qgroup_show(int argc, char **argv)
btrfs_qgroup_setup_print_column(
BTRFS_QGROUP_MAX_EXCL);
break;
+ case 'F':
+ filter_flag |= 0x1;
+ break;
default:
usage(cmd_qgroup_show_usage);
}
@@ -256,7 +266,13 @@ static int cmd_qgroup_show(int argc, char **argv)
return 1;
}
- ret = btrfs_show_qgroups(fd);
+ if (filter_flag) {
+ qgroupid = btrfs_get_path_rootid(fd);
+ btrfs_qgroup_setup_filter(&filter_set,
+ BTRFS_QGROUP_FILTER_ALL_PARENT,
+ qgroupid);
+ }
+ ret = btrfs_show_qgroups(fd, filter_set);
e = errno;
close_file_or_dir(fd, dirstream);
if (ret < 0)