[PATCH] btrfs-progs: btrfs_list_find_updated_files: Fix memory leak.

2013-10-07 Thread chandan
The current code returns from the function when the call to ioctl fails. This may leak cache_dir_name and cache_full_name. Fix it. Signed-off-by: chandan chan...@linux.vnet.ibm.com --- btrfs-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/btrfs-list.c b/btrfs-list.c

[PATCH v3 08/12] Btrfs-progs: enhance btrfs qgroup show to sort qgroups

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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

[PATCH v3 01/12] Btrfs-progs: restructure show_qgroups

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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

[PATCH v3 07/12] Btrfs-progs: list all qgroups impact given path(exclude ancestral qgroups)

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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) / \

[PATCH v3 10/12] Btrfs-progs: add '--block-size' option to control print result

2013-10-07 Thread Wang Shilong
You can use it like: btrfs qgroup show --block-size=m mnt Here, block size supports k/K/m/M/g/G/t/T/p/P/e/E. Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com --- cmds-qgroup.c | 16 +--- qgroup.c | 78 ---

[PATCH v3 12/12] Btrfs-progs: add '-h' options to print sizes in human readable format

2013-10-07 Thread Wang Shilong
This is a short cut for people who don't want to use '--block-size',it will print sizes in human readable format. Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com --- cmds-qgroup.c | 17 +--- qgroup.c | 62 +++

[PATCH v3 11/12] Btrfs-progs: make pretty_size_snprintf() return len

2013-10-07 Thread Wang Shilong
Sometimes, we need to catch length of snprintf() in pretty_size_snprintf(). Signed-off-by: Wang Shilong wangsl.f...@cn.fujitsu.com --- utils.c | 9 + utils.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/utils.c b/utils.c index 4ed7405..7b42022 100644 ---

[PATCH v3 05/12] Btrfs-progs: introduce '-e' option to print max exclusive size of qgroups

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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-f...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH v3 03/12] Btrfs-progs: introduces '-c' option to print the ID of the child qgroups

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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) / \ / \ /

[PATCH v3 02/12] Btrfs-progs: introduces '-p' option to print the ID of the parent qgroups

2013-10-07 Thread Wang Shilong
From: Wang Shilong wangsl-f...@cn.fujitsu.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) / \ / \ /

Re: kernel BUG at fs/btrfs/relocation.c:1060 during rebalancing

2013-10-07 Thread Jan Krcmar
hi, i've got the same problem kernel BUG at fs/btrfs/relocation.c:1060. this was solved by patching the kernel with following patch https://git.kernel.org/cgit/linux/kernel/git/josef/btrfs-next.git/commit/?id=b6c60c8018c4e9beb2f83fc82c09f9d033766571 i've also found, that this patch is NOT

Re: [PATCH] btrfs-progs: create helper function to use lblkid to scan for btrfs disks

2013-10-07 Thread Anand Jain
Following this patch the idea is to use lblkid to scan for the btrfs disks by default which means we don't use BTRFS_SCAN_PROC any more. Firstly, i would like to know if we will get any different results between scanning /proc/partions and using lbkid. I take blkid as a more authoritative

Re: btrfs device delete problem

2013-10-07 Thread Duncan
Alfredo Esteban posted on Sun, 06 Oct 2013 13:10:49 +0200 as excerpted: I'm getting an error when trying to delete a device from a raid1 (data and metadata mirrored). btrfs filesystem show failed to read /dev/sr0 Label: none uuid: 78b5162b-489e-4de1-a989-a47b91adef50 Total devices 2

[PATCH] Btrfs: fix the dev-replace suspend sequence

2013-10-07 Thread Ilya Dryomov
Replace progresses strictly from lower to higher offsets, and the progress is tracked in chunks, by storing the physical offset of the dev_extent which is being copied in the cursor_left field of btrfs_dev_replace_item. When we are done copying the chunk, left_cursor is updated to point one byte

[PATCH] Btrfs: fix memory leaks on transaction commit failure

2013-10-07 Thread Filipe David Borba Manana
Structures of the types tree_mod_elem and qgroup_update are allocated during transaction commit but were not being released if the call to btrfs_run_delayed_items() returned an error. Stack trace reported by kmemleak: unreferenced object 0x880679f0b398 (size 128): comm umount, pid 21508,

Some questions after devices addition to existing raid 1 btrfs filesystem

2013-10-07 Thread Laurent Humblet
Hi, I have added 2x2Tb to my existing 2x2Tb raid 1 btrfs filesystem and then ran a balance: # btrfs filesystem show Total devices 4 FS bytes used 1.74TB devid3 size 1.82TB used 0.00 path /dev/sdd devid4 size 1.82TB used 0.00 path /dev/sde devid2 size

Re: Some questions after devices addition to existing raid 1 btrfs filesystem

2013-10-07 Thread Hugo Mills
On Mon, Oct 07, 2013 at 01:45:29PM +0200, Laurent Humblet wrote: I have added 2x2Tb to my existing 2x2Tb raid 1 btrfs filesystem and then ran a balance: # btrfs filesystem show Total devices 4 FS bytes used 1.74TB devid3 size 1.82TB used 0.00 path /dev/sdd devid

Re: Some questions after devices addition to existing raid 1 btrfs filesystem

2013-10-07 Thread Duncan
Hugo Mills posted on Mon, 07 Oct 2013 13:06:23 +0100 as excerpted: On Mon, Oct 07, 2013 at 01:45:29PM +0200, Laurent Humblet wrote: I have added 2x2Tb to my existing 2x2Tb raid 1 btrfs filesystem and then ran a balance: # btrfs filesystem show Total devices 4 FS bytes used 1.74TB

[PATCH] Btrfs: do not free the dirty bytes from the trans block rsv on cleanup

2013-10-07 Thread Josef Bacik
The transactions should be cleaning up their reservations on failure, this just causes us to have warnings on unmount because we go negative by free'ing reservations that have already been free'ed. Thanks, Signed-off-by: Josef Bacik jba...@fusionio.com --- fs/btrfs/disk-io.c | 2 -- 1 file

btrfsck --repair --init-extent-tree: segfault error 4

2013-10-07 Thread Martin
Any clues or educated comment please? Can the corrupt directory tree safely be ignored and left in place? Or might that cause everything to fall over in a big heap as soon as I try to write data again? Could these other tricks work-around or fix the corrupt tree: Run a scrub? Make a snapshot

Re: [PATCH] btrfs: init device stats for new devices

2013-10-07 Thread Stefan Behrens
On Mon, 30 Sep 2013 14:58:02 -0700, Zach Brown wrote: I discovered one minor bug in BTRFS filesystem. You sure did. ERROR: ioctl(BTRFS_IOC_GET_DEV_STATS) on /dev/sde failed: No such device But this is not true ... all specified devices exist and are members of btrfs filesystem. In dmesg

Re: btrfs device delete problem

2013-10-07 Thread Chris Murphy
On Oct 7, 2013, at 4:38 AM, Duncan 1i5t5.dun...@cox.net wrote: Since your btrfs in raid1 mode has two devices currently, you won't be able to delete one of them as-is. You will need to ADD a device first (bringing the total to three devices), optionally do a balance, and THEN delete the

[PATCH] Btrfs: Simplify the logic in alloc_extent_buffer() for existing extent buffer case

2013-10-07 Thread Chandra Seetharaman
alloc_extent_buffer() uses radix_tree_lookup() when radix_tree_insert() fails with EEXIST. That part of the code is very similar to the code in find_extent_buffer(). This patch replaces radix_tree_lookup() and surrounding code in alloc_extent_buffer() with find_extent_buffer(). Note that

Re: btrfs device delete problem

2013-10-07 Thread Chris Murphy
On Oct 7, 2013, at 9:44 AM, Chris Murphy li...@colorremedies.com wrote: On Oct 7, 2013, at 4:38 AM, Duncan 1i5t5.dun...@cox.net wrote: Since your btrfs in raid1 mode has two devices currently, you won't be able to delete one of them as-is. You will need to ADD a device first (bringing

Re: btrfsck --repair --init-extent-tree: segfault error 4

2013-10-07 Thread Chris Murphy
On Oct 7, 2013, at 8:56 AM, Martin m_bt...@ml1.co.uk wrote: Or try mount -o recovery,noatime again? Because of this: free space inode generation (0) did not match free space cache generation (1607) Try mount option clear_cache. You could then use iotop to make sure the btrfs-freespace

minor wiki bug, check_int mount options description

2013-10-07 Thread Chris Murphy
I think the wiki has descriptions for check_int and check_int_data reversed: check_int (since 3.3) Switch on integrity checker for data and metadata (if compiled in) check_int_data (since 3.3) Switch on integrity checker for data (if compiled in)

[PATCH] Btrfs: cleanup reserved space when freeing tree log on error

2013-10-07 Thread Josef Bacik
On error we will wait and free the tree log at unmount without a transaction. This means that the actual freeing of the blocks doesn't happen which means we complain about space leaks on unmount. So to fix this just skip the transaction specific cleanup part of the tree log free'ing if we don't

[PATCH] Btrfs: free up block groups after everything

2013-10-07 Thread Josef Bacik
If we abort a transaction we will do the tree log cleanup at unmount, but this happens after we free up the block groups. This makes all the leak detection warnings go off because we think we've leaked space but in reality we just haven't cleaned it up yet. So instead do the block group cleanup

[PATCH] Btrfs: free reserved space on error in a few places

2013-10-07 Thread Josef Bacik
While trying to track down a reserved space leak I noticed a few places where we won't properly clean up reserved space if we have an error, this patch fixes those up. Thanks, Signed-off-by: Josef Bacik jba...@fusionio.com --- fs/btrfs/extent-tree.c | 21 +++-- fs/btrfs/inode.c

[PATCH] Btrfs: fixup reserved trace points

2013-10-07 Thread Josef Bacik
In trying to track down where we were leaking reserved space I noticed our reserve extent tracepoints are a little off. First we were saying that the reserved space had been alloced in btrfs_reserve_extent, which isn't the case, this needs to be triggered when we actually allocate the space when

[PATCH] Btrfs: remove unnecessary key copy when logging inode

2013-10-07 Thread Filipe David Borba Manana
The btrfs_insert_empty_item() function doesn't modify its key argument. Signed-off-by: Filipe David Borba Manana fdman...@gmail.com --- fs/btrfs/tree-log.c |5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 964c583..2a1f690

Re: Handful of btrfs fixes for 3.11.x stable

2013-10-07 Thread Josef Bacik
On Sat, Oct 05, 2013 at 04:52:18PM -0700, Greg KH wrote: On Fri, Sep 20, 2013 at 09:53:02AM -0700, Greg KH wrote: On Fri, Sep 20, 2013 at 06:34:39PM +0200, David Sterba wrote: Hi stable team, please add the following commits to 3.11 tree, they fix user visible problems, were

[PATCH 01/12] btrfs-progs: check path alloc in corrupt block

2013-10-07 Thread Zach Brown
btrfs-corrupt-block added some untested path allocations. These showed up in static analysis when they pass their path to btrfs_search_slot() which unconditionally dereferences the path. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-corrupt-block.c | 10 -- 1 file changed, 8

[PATCH 02/12] btrfs-progs: check fopen failure in cmds-send

2013-10-07 Thread Zach Brown
Check for fopen() failure. This shows up in static analysis as a possible null pointer derference. Signed-off-by: Zach Brown z...@redhat.com --- cmds-send.c | 5 + 1 file changed, 5 insertions(+) diff --git a/cmds-send.c b/cmds-send.c index 374d040..5f6ff86 100644 --- a/cmds-send.c +++

[RFC] another round of static analysis fixes

2013-10-07 Thread Zach Brown
Hi friends, Eric imported a newer git snapshot of btrfs-progs into Red Hat's universe which kicked off a static analysis run which found a bunch of problems. This series is my attempt to fix the warnings that I agreed were either real bugs or messy code to clean up. This is against Dave's

[PATCH 06/12] btrfs-progs: remove dead block group checking

2013-10-07 Thread Zach Brown
Don't carry around dead code. If its needed again, it's only a few git commands away. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- cmds-check.c | 50 -- 1 file changed, 50 deletions(-) diff --git

[PATCH 08/12] btrfs-progs: don't leak path in verify_space_cache

2013-10-07 Thread Zach Brown
This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- cmds-check.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index ebba58e..b6035d7 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -3228,13 +3228,13 @@ static

[PATCH 11/12] btrfs-progs: remove unused variables

2013-10-07 Thread Zach Brown
Presumably people missed these warnings because btrfs-fragments isn't built by default. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-fragments.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/btrfs-fragments.c b/btrfs-fragments.c index cedbc57..160429a 100644 ---

[PATCH 03/12] btrfs-progs: don't overrun name in find-collisions

2013-10-07 Thread Zach Brown
find_collision() allocates name_len bytes for its sub array so the index must be less than name_len. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btrfs-image.c

[PATCH 07/12] btrfs-progs: free eb in fixup_chunk_tree_block()

2013-10-07 Thread Zach Brown
This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-image.c | 1 + 1 file changed, 1 insertion(+) diff --git a/btrfs-image.c b/btrfs-image.c index 03ad4e9..d10447f 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -1541,6 +1541,7 @@ next:

[PATCH 10/12] btrfs-progs: don't overflow colors[] in fragments

2013-10-07 Thread Zach Brown
Stop iteration at the number of elements in the colors[] array when initializing the elements. Rather than a magic number. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-fragments.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH 09/12] btrfs-progs: don't deref pipefd[-1]

2013-10-07 Thread Zach Brown
commit 4782e8ebdb583dfa3615f7b38dee729d34f62ec1 accidentally replaced [0] with [-1]. Put it back. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- send-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/send-test.c b/send-test.c index

[PATCH 05/12] btrfs-progs: check link_subvol name base

2013-10-07 Thread Zach Brown
In principle, link_subvol() can be given an abitrary string as the name of the saved subvolume. It copies it into a fixed-size stack buffer and then uses it as dirent names without testing its length. This limits its length to BTRFS_NAME_LEN. This was found by static analsys. Signed-off-by:

[PATCH 04/12] btrfs-progs: don't overflow read buffer in image

2013-10-07 Thread Zach Brown
search_for_chunk_blocks() allocates a fixed-size buffer and then reads arbitrary u32 sized buffers in to it. Instead let's fail if the item is bigger than the buffer. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- btrfs-image.c | 14 +++--- 1 file

Re: [PATCH 09/12] btrfs-progs: don't deref pipefd[-1]

2013-10-07 Thread Eric Sandeen
On 10/7/13 4:43 PM, Zach Brown wrote: commit 4782e8ebdb583dfa3615f7b38dee729d34f62ec1 accidentally replaced [0] with [-1]. Put it back. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com eeehhhyeah. Thanks for being charitable. ;) Really, I have no idea how that

Re: [PATCH] Btrfs: remove unnecessary key copy when logging inode

2013-10-07 Thread Zach Brown
On Mon, Oct 07, 2013 at 09:20:44PM +0100, Filipe David Borba Manana wrote: The btrfs_insert_empty_item() function doesn't modify its key argument. Looks reasonable to me. Reviewed-by: Zach Brown z...@redhat.com - z -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the

Re: kernel BUG at mm/page-writeback.c:2317!

2013-10-07 Thread Jan Killius
Hello, I'm hitting similar bug with the patch from Lui Bo. But If I revert: 573aecafca1cf7a974231b759197a1aebcf39c2a, Btrfs: actually limit the size of delalloc range) everything works fine. Here are the 2 backtraces from my machines with 3.12-rc4: http://imgur.com/sVkjGK6,mWUtzMV#0

Re: [PATCH 09/12] btrfs-progs: don't deref pipefd[-1]

2013-10-07 Thread Zach Brown
On Mon, Oct 07, 2013 at 04:45:01PM -0500, Eric Sandeen wrote: On 10/7/13 4:43 PM, Zach Brown wrote: commit 4782e8ebdb583dfa3615f7b38dee729d34f62ec1 accidentally replaced [0] with [-1]. Put it back. This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com

Re: [PATCH] Btrfs: free up block groups after everything

2013-10-07 Thread Liu Bo
On Mon, Oct 07, 2013 at 03:16:01PM -0400, Josef Bacik wrote: If we abort a transaction we will do the tree log cleanup at unmount, but this happens after we free up the block groups. This makes all the leak detection warnings go off because we think we've leaked space but in reality we just

[PATCH] xfstest: an regression test for btrfs balance

2013-10-07 Thread Gui Hecheng
Originally, when executing btrfs balance right after btrfs subvolume snaphot btrfs subvolume delete, a kernel BUG arises. This problem is caused by the patch: [PATCH 1/2] Btrfs: fix for patch cleanup: don't check the same thing twice The commit id: 48475471728f060bfd2e686f592ef208d3ba8b7d (in

Re: kernel BUG at mm/page-writeback.c:2317!

2013-10-07 Thread Josef Bacik
On Tue, Oct 08, 2013 at 12:36:11AM +0200, Jan Killius wrote: Hello, I'm hitting similar bug with the patch from Lui Bo. But If I revert: 573aecafca1cf7a974231b759197a1aebcf39c2a, Btrfs: actually limit the size of delalloc range) everything works fine. Here are the 2 backtraces from my

Re: kernel BUG at mm/page-writeback.c:2317!

2013-10-07 Thread Josef Bacik
On Tue, Oct 08, 2013 at 12:36:11AM +0200, Jan Killius wrote: Hello, I'm hitting similar bug with the patch from Lui Bo. But If I revert: 573aecafca1cf7a974231b759197a1aebcf39c2a, Btrfs: actually limit the size of delalloc range) everything works fine. Here are the 2 backtraces from my

[PATCH 2/3 v2] btrfs-progs: add more parameter to the filesystem show

2013-10-07 Thread Anand Jain
for mounted btrfs filesystem this patch proposes to add mount point and group profile to the filesystem show output. this helps user to quickly understand short details of the btrfs filesystem quickly. end user using this new btrfs fi show would surely notice this will reduce other commands

[PATCH 1/3 v4] btrfs-progs: use kernel for mounted disk for show

2013-10-07 Thread Anand Jain
As of now btrfs filesystem show reads directly from disks. So sometimes output can be stale, mainly when user wants to cross verify their operation like, label or device delete or add... etc. so this patch will read from the kernel ioctl if it finds that disk is mounted. v4: rebase on

[PATCH 3/3] btrfs-progs: use BTRFS_SCAN_LBLKID as default scan in filesystem show

2013-10-07 Thread Anand Jain
btrfs progs has to scan for the btrfs disks for two main reasons, one to register them with the btrfs kernel (under btrfs dev scan) 2nd to report btrfs disks to the user (under btrfs fi show) (there few more minor reasons like check_mounted etc..). To facilitate the scan, in total we have the

Re: [PATCH 08/12] btrfs-progs: don't leak path in verify_space_cache

2013-10-07 Thread chandan
On Monday 07 Oct 2013 2:43:01 PM you wrote: This was found by static analysis. Signed-off-by: Zach Brown z...@redhat.com --- cmds-check.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index ebba58e..b6035d7 100644 ---