summaryrefslogtreecommitdiff
path: root/cmds-qgroup.c
Commit message (Collapse)AuthorAge
* btrfs-progs: qgroup destroy says create failedAnand 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: annotate fallthroughs in parse_limitEric Sandeen2013-11-07
| | | | | | | | | We intentionally fall through these case statements; just annotate it to be clear. Resolves-Coverity-CID: 1054884 Signed-off-by: Eric Sandeen <sandeen@redhat.com> 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 magic return value in cmds-qgroup.cWang Shilong2013-10-16
| | | | | | Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: use NULL instead of 0Zach Brown2013-09-03
| | | | | | | | | These were mostly in option structs but there were a few gross string pointer arguments given as 0. Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mark static & remove unused from non-kernel codeEric Sandeen2013-09-03
| | | | | | | | Mark many functions as static, and remove any resulting dead code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: fix closing of opendir()Wang Shilong2013-08-09
| | | | | | | | | | valgrind complains open_file_or_dir() causes a memory leak.That is because if we open a directoy by opendir(), and then we should call closedir() to free memory. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: add quota-related info to usage messagesKoen De Wit2013-04-23
| | | | | | | | | | | Extending usage messages with some info on the quota functionality: - The -i option of "subvol create" and "subvol snapshot" was not documented - The -c option of "qgroup limit" is the default option - The "qouta rescan" command is not yet implemented, while it should be executed after enabling quota on a non-empty filesystem. Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
* Btrfs-progs: output the error reason when qgroup_show failsWang Shilong2013-02-27
| | | | | | | The original code forgot to output the reason why the commands failed, fix it. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
* Btrfs-progs: let the error message outputed only onceWang Shilong2013-02-27
| | | | | | | | | | | | If we fail to execute the command: btrfs qgroup show <mnt> It will output the follow messages: ERROR: can't perform the search - Inappropriate ioctl for device ERROR: can't list qgroups The error is outputed twice, this is wrong, fix it. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
* btrfs-progs: close fd in qgroup showZach Brown2013-02-05
| | | | | | It wasn't closed in the error path. Signed-off-by: Zach Brown <zab@redhat.com>
* Btrfs-progs: move open_file_or_dir() to utils.cAnand Jain2013-01-30
| | | | | | | | | | | The definition of the function open_file_or_dir() is moved from common.c to utils.c in order to be able to share some common code between scrub and the device stats in the following step. That common code uses open_file_or_dir(). Since open_file_or_dir() makes use of the function dirfd(3), the required XOPEN version was raised from 6 to 7. Signed-off-by: Anand Jain <anand.jain@oracle.com> Original-Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
* Btrfs-progs: Fix trival compiler error in cmds-qgroup.cGene Czarcinski2013-01-28
| | | | | | | The compiler does not realize that usage() never returns. Initializing the variable keeps it quiet. Signed-off-by: Gene Czarcinski <gene@czarc.net>
* Btrfs-progs: check the relation of two group by real level numbersWang Shilong2013-01-21
| | | | | | | | | Comparing qgroupid is not good way to check the relationship of two groups, the right way is to compare the real level numbers. 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: 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: fix arg parsing for btrfs qgroup limit commandsWang Shilong2013-01-21
| | | | | | | | | | | | | | | | | | | We can use this command in two ways. 1. btrfs qgroup limit size qgroupid path 2. btrfs qgroup limit size path Before applying this patch, we differentiate them by check the parsing result of the second argument. It is not so good because it may make some mistakes, For example: btrfs qgroup limit 1M 123456 ^ It is a subvolume name. In fact, we can differentiate them just by the number of arguments, so fix it by this way. 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: fix arguments check of qgroup limitTsutomu Itoh2012-10-02
| | | | | | | | | | | Segmentation fault occurred in the following command. # btrfs qgroup limit Segmentation fault So, we should check a minimum number of arguments. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
* 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>