summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongsheng Yang <yangds.fnst@cn.fujitsu.com>2015-06-03 14:57:33 +0800
committerDavid Sterba <dsterba@suse.cz>2015-06-05 18:36:55 +0200
commitea496435d5f9eb97681bcd69ff012917b2a3b201 (patch)
tree69a999382fb4e23adc109e44c38cad04c151e37b
parent216259e0e6bc177de74673d5f2c93fedb9495b25 (diff)
btrfs-progs: qgroup: allow user to clear some limitation on qgroup.
Currently, we can not clear a limitation on a qgroup. Although there is a 'none' choice provided to user to do it, it does not work well. It does not set the flag which user want to clear, then kernel will never know what the user want to do at all. *Without this commit* # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none # ./btrfs qgroup limit none /mnt # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none This patch will set the flag user want to clear and pass a size=-1 to kernel. Then kernel will clear it correctly. *With this commit* # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB 5.00GiB none 0/257 100.02MiB 100.02MiB none none # ./btrfs qgroup limit none /mnt # ./btrfs qgroup show -re /mnt qgroupid rfer excl max_rfer max_excl -------- ---- ---- -------- -------- 0/5 2.19GiB 2.19GiB none none 0/257 100.02MiB 100.02MiB none none Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--cmds-qgroup.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index b0732509..00cc0894 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -110,9 +110,10 @@ static int parse_limit(const char *p, unsigned long long *s)
{
char *endptr;
unsigned long long size;
+ unsigned long long CLEAR_VALUE = -1;
if (strcasecmp(p, "none") == 0) {
- *s = 0;
+ *s = CLEAR_VALUE;
return 1;
}
size = strtoull(p, &endptr, 10);
@@ -406,17 +407,15 @@ static int cmd_qgroup_limit(int argc, char **argv)
}
memset(&args, 0, sizeof(args));
- if (size) {
- if (compressed)
- args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
- BTRFS_QGROUP_LIMIT_EXCL_CMPR;
- if (exclusive) {
- args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
- args.lim.max_exclusive = size;
- } else {
- args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
- args.lim.max_referenced = size;
- }
+ if (compressed)
+ args.lim.flags |= BTRFS_QGROUP_LIMIT_RFER_CMPR |
+ BTRFS_QGROUP_LIMIT_EXCL_CMPR;
+ if (exclusive) {
+ args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_EXCL;
+ args.lim.max_exclusive = size;
+ } else {
+ args.lim.flags |= BTRFS_QGROUP_LIMIT_MAX_RFER;
+ args.lim.max_referenced = size;
}
if (argc - optind == 2) {