summaryrefslogtreecommitdiff
path: root/qgroup.c
Commit message (Collapse)AuthorAge
* btrfs-progs: qgroup: cleanup __qgroup_searchLu Fengqi2018-01-08
| | | | | | | | Replace the if statement with the switch statement, and return the appropriate value for the future use rather than directly exit. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: move btrfs_show_qgroups's error handler to __qgroup_searchLu Fengqi2018-01-08
| | | | | | | | | | | | We have to process the return value of BTRFS_IOC_TREE_SEARCH ioctl in advance, so that we can distinguish between the two case where quota is not enabled (ioctl return -ENOENT) and either parent qgroup or child qgroup does not exist (update_qgroup_relation return -ENOENT). Besides this, any error in this routine has been reported, so we don't need to report again in cmd_qgroup_show. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: split update_qgroup to reduce argumentsLu Fengqi2017-11-14
| | | | | | | | | The function update_qgroup has too many arguments that are too difficult to use. Therefore, split it to update_qgroup_info, update_qgroup_limit, update_qgroup_relation. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: cleanup the redundant function add_qgroupLu Fengqi2017-11-14
| | | | | | | | | | There are reusable parts between update_qgroup and add_qgroup. So introduce the function get_or_add_qgroup and use update_qgroup instead of add_qgroup. No functional changes. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: fix qgroup show sort by multi itemsLu Fengqi2017-11-14
| | | | | | | | | | | We should not free the string until we don't call strtok any longer. If the string is freed in advance, in fact, the second and subsequent sort items will be ignored. Fixes: 9fcdf8f8945b ("btrfs-progs: don't write to optarg in btrfs_qgroup_parse_sort_string") Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup show: refine error messagesDavid Sterba2017-01-25
| | | | | | | | | | | | | When qgroup show is called on a filesystem that does not have quotas enabled, the error message is very unclear: ERROR: can't perform the search - No such file or directory ERROR: can't list qgroups: No such file or director Remove the error from low level helper and let the command handler decide what to print. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroups show: clean up errno passingDavid Sterba2017-01-25
| | | | | | We should use return value for errors, not errno. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: fix error in ASSERT condition expressionTsutomu Itoh2016-11-23
| | | | | | | | Option -f, -F and --sort don't work because a conditional expression of ASSERT is wrong. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused function btrfs_get_path_rootidDavid Sterba2016-11-09
| | | | | | Last user replaced with a more appropriate helper. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: constify string arguments where appropriateDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: don't write to optarg in btrfs_qgroup_parse_sort_stringDavid Sterba2016-10-03
| | | | | | | Dup the string that gets passed to strtok so we don't destroy callers buffer. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: switch to common message helpersDavid Sterba2016-09-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove trivial helpers for filtering functionsDavid Sterba2016-09-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: switch column values to assertsDavid Sterba2016-09-21
| | | | | | This is checking correct usage, not runtime errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use ioctl search headers everywhereDavid Sterba2016-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generated by following semantic patch and manually tweaked. <SmPL> @@ struct btrfs_ioctl_search_header *SH; @@ ( - SH->objectid + btrfs_search_header_objectid(SH) | - SH->offset + btrfs_search_header_offset(SH) | - SH->transid + btrfs_search_header_transid(SH) | - SH->len + btrfs_search_header_len(SH) | - SH->type + btrfs_search_header_type(SH) ) </SmPL> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=112131 Reported-and-tested-by: Anatoly Pugachev <matorola@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unnecessary errno temp variablesDavid Sterba2016-01-12
| | | | | | | We can read errno directly if it's not clobbered by any intermediate calls. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use NULL instead of 0Byongho Lee2016-01-12
| | | | | | | Fix the code assigning 0 to pointer instead of NULL. Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leak in cmd_qgroup_show()Eryu Guan2015-11-02
| | | | | | | filter_set and comparer_set should be freed on return. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use calloc instead of malloc+memsetSilvio Fricke2015-10-21
| | | | | | | | | | | | | | | | | | | | | | This patch is generated from a coccinelle semantic patch: identifier t; expression e; statement s; @@ -t = malloc(e); +t = calloc(1, e); ( if (!t) s | if (t == NULL) s | ) -memset(t, 0, e); Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> [squashed patches into one] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, update function definitions to be ANSI conformantDavid Sterba2015-09-14
| | | | | | | | | | Sparse reports: warning: non-ANSI function declaration of function and we're using func(void) elsewhere. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix memory leaks in error pathByongho Lee2015-08-31
| | | | | | | | | | This patch includes below fixes in error path: 1. fix memory leaks if realloc() fails 2. add missing call free_history() before return error in scrub_read_file() Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com> Reviewed-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroupDongsheng Yang2015-06-05
| | | | | | | | | | | | | | | | | | | There are two understanding of the '0' value in btrfs qgroup show. (1) is no-limitation on this qgroup. (2) is the max-limitation is 0. This patch make it showing in different way. (1) max-limitation for 0 is still showing '0'. (2) no-limitation will show 'none'. qgroupid rfer excl max_rfer max_excl parent -------- ---- ---- -------- -------- ------ 0/5 2.19GiB 2.19GiB none none --- 0/257 100.02MiB 100.02MiB none none --- 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>
* btrfs-progs: Print warning message if qgroup data is inconsistentQu Wenruo2015-03-24
| | | | | | | | | | | | | | | | | Before this patch, qgroup show won't check btrfs qgroup status, so even the INCONSISTENT flags is set, user is not aware of it. This patch will include BTRFS_QGROUP_STATUS_ITEM in the search range and check the flag, if there is any flag meaning the inconsistence of qgroup data, info user. NOTE: There is several kernel bugs from INCONSISTENT flags is always set to RUNNING flags is not cleared until umount. So this warning will always be here if using a newer kernel fixing these bugs. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Move parse_qgroupid() to utils.cQu Wenruo2015-03-24
| | | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [constified strings in parse_qgroupid] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Update qgroup status flags and replace qgroup level/subvid ↵Qu Wenruo2015-03-24
| | | | | | | | | | | | | | calculation with inline function Ctree.h of btrfs-progs contains wrong flags for btrfs_qgroup_status. Update it with the one in kernel. Also, introduce the inline function btrfs_qgroup_(level/subvid) to get the level/subvolid of qgroup, to replace the old open-coded bit operations. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: use correct the return valueFan Chengniang2015-02-27
| | | | | | | | | The return values 12 and 13 are not used spectially except as return value. No description and definition about them. so I change them to generic errno. Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: qgroup: make large size alignedFan Chengniang2015-01-27
| | | | | | | | | Problem: when the size is too big, the output format will be unaligned. The __update__columns_max_len function has been updated to fix this problem. Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: make btrfs qgroups show human readable sizesFan Chengniang2015-01-21
| | | | | | | | | | | | | | | | add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options make columns which show sizes align to right. Others aligned to left. example: qgroupid rfer excl max_rfer max_excl parent child -------- ---- ---- -------- -------- ------ ----- 0/5 299.58MiB 299.58MiB 300.00MiB 300.00MiB 1/1 --- 0/265 299.58MiB 16.00KiB 400.00MiB 0.00B 1/1 --- 0/266 299.58MiB 16.00KiB 350.00MiB 0.00B --- --- 1/1 599.16MiB 299.59MiB 800.00MiB 0.00B --- 0/5,0/265 Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix spacing in error messagesDavid Sterba2014-11-25
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: print qgroup excl as unsignedMark Fasheh2014-08-22
| | | | | | | It's unsigned in the structure definition. Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: make it static if function isn't called outsideAnand Jain2014-01-31
| | | | | | Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: enhance btrfs qgroup to print the result as a tableWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch enhance to print the result as a table. You can use it like: btrfs qgroup show <path> However, to table the result better, we make '-p' and '-c' not present at the same time. For example: btrfs qgroup show -pr <path> The result will output as the follow format: qgroupid rfer excl max_excl parent -------- ---- ---- -------- ------ 0/265 1289752576 1289752576 0 --- 1/0 0 0 10999511627776 2/0,3/0 2/0 0 0 0 --- 3/0 0 0 0 --- 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>
* Btrfs-progs: enhance btrfs qgroup show to sort qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | You might want to list qgroups in order of some items, such as 'qgroupid', 'rfer' and so on, you can use '--sort'. Now you can sort the qgroups by 'qgroupid', 'rfer','excl','max_rfer' and 'max_excl'. For example: If you want to list qgroups in order of 'qgroupid'. You can use the option like that: btrfs qgroup show --sort=+/-qgroupid <path> Here, '+' means the result is sorted by ascending order. '-' is by descending order. If you don't specify either '+' nor '-', the result is sorted by default - ascending order. If you want to combine sort items, you do it like that: btrfs qgroup show --sort=-qgroupid,+rfer,max_rfer,excl <path> 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>
* Btrfs-progs: list all qgroups impact given path(exclude ancestral qgroups)Wang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 -- -- '-f' option helps you list all qgroups impact given path. (exclude 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>
* Btrfs-progs: list all qgroups impact given path(include ancestral qgroups)Wang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Btrfs-progs: introduce '-e' option to print max exclusive size of qgroupsWang Shilong2013-10-16
| | | | | | | | | | | This patch introduce '-e' option to print max exclusive size of qgroups. You may use it like this: btrfs qgroup -e <path> 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>
* Btrfs-progs: introduce '-r' option to print max referenced size of qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | This patch introduces '-r' option to print max referenced size of qgroups. You may use it like: btrfs qgroup show -r <path> 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>
* Btrfs-progs: introduces '-c' option to print the ID of the child qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces '-c' option to print the ID of the child qgroups. You may use it like: btrfs qgroup show -c <path> For Example: qgroupid(2/0) / \ / \ / \ qgroupid(1/0) qgroupid(1/1) \ / \ / qgroupid(0/1) If we use the command: btrfs qgroup show -c <path> The result will output 0/1 -- -- -- 1/0 -- -- 0/1 1/1 -- -- 0/1 2/0 -- -- 1/0,1/1 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>
* Btrfs-progs: introduces '-p' option to print the ID of the parent qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces '-p' option to print the ID of the parent qgroups. You may use it like: btrfs qgroup show -p <path> For Example: qgroupid(2/0) / \ / \ / \ qgroupid(1/0) qgroupid(1/1) \ / \ / qgroupid(0/1) If we use the command: btrfs qgroup show -p <path> The result will output 0/1 -- -- 1/0,1/1 1/0 -- -- 2/0 1/1 -- -- 2/0 2/0 -- -- -- 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>
* Btrfs-progs: restructure show_qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current show_qgroups() just shows a little information, and it is hard to add some functions which the users need in the future, so i restructure it, make it easy to add new functions. In order to improve the scalability of show_qgroups(), i add some important structures: struct qgroup_lookup { struct rb_root root; } /* *store qgroup's information */ struct btrfs_qgroup { struct rb_node rb_node; u64 qgroupid; u64 generation; u64 rfer; u64 rfer_cmpr; u64 excl_cmpr; u64 flags; u64 max_rfer; u64 max_excl; u64 rsv_rfer; u64 rsv_excl; struct list_head qgroups; struct list_head members; } /* *glue structure to represent the relations *between qgroups */ struct btrfs_qgroup_list { struct list_head next_qgroups; struct list_head next_member; struct btrfs_qgroup *qgroup; struct btrfs_qgroup *member; } The above 3 structures are used to manage all the information of qgroups. struct { char *name; char *column_name; int need_print; } btrfs_qgroup_columns[] We define a arrary to manage all the columns that can be outputed, and use a member variant(->need_print) to control the output of the relative column. Some columns are outputed by default. But we can change it according to the requirement of the users. For example: if outputing max referenced size of qgroup is needed,the function 'btrfs_qgroup_setup_column()' will be called, and the parameter 'BTRFS_QGROUP_MAX_RFER' (extend in the future) will be passsed to the function. After the function is done, when showing qgroups, max referenced size of qgroup will be output. 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>
* btrfs-progs: fix qgroup realloc inheritanceZach Brown2013-09-03
| | | | | | | | | | | | | | qgroup.c:82:23: warning: memcpy with byte count of 0 qgroup.c:83:23: warning: memcpy with byte count of 0 The inheritance wasn't copying qgroups[] because a confused sizeof() gave 0 byte memcpy()s. It's been like this for the year since it was merged, so I guess this isn't a very important thing to do :). Signed-off-by: Zach Brown <zab@redhat.com> Reviewed-by: Arne Jansen <sensille@gmx.net> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mark static & remove unused from shared kernel codeEric Sandeen2013-09-03
| | | | | | | | | | | In files copied from the kernel, mark many functions as static, and remove any resulting dead code. Some functions are left unmarked if they aren't static in the kernel tree. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: clean up reduplicate parse_qgroupid() and replace atoi with ↵Wang Shilong2013-01-21
| | | | | | | | | | | strtoull 1. parse_qgroupid() is implemented twice, clean up the reduplicate code. 2. atoi() can not detect errors, so use strtoull() instead of it. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Gene Czarcinski <gene@czarc.net>
* Btrfs progs: quota groups supportArne Jansen2012-09-04
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: Arne Jansen <sensille@gmx.net>