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>
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>
Sparse reports:
warning: non-ANSI function declaration of function
and we're using func(void) elsewhere.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>