Re: [PATCH v2] Btrfs: detect corruption when non-root leaf has zero item

2016-09-02 Thread Liu Bo
Hi, On Fri, Sep 02, 2016 at 01:26:10AM -0400, Jeff Mahoney wrote: > On 8/23/16 6:22 PM, Liu Bo wrote: > > Right now we treat leaf which has zero item as a valid one > > because we could have an empty tree, that is, a root that is > > also a leaf without any item, howe

[PATCH] Btrfs: fix BUG_ON in btrfs_mark_buffer_dirty

2016-09-02 Thread Liu Bo
je...@suse.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 9367c31..b401e6d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -57

Re: kernel BUG at fs/btrfs/ctree.c:5213

2016-09-02 Thread Liu Bo
On Fri, Sep 02, 2016 at 04:58:43PM +0200, ste...@srv1.eu wrote: > Hi, > > since a few weeks ago, my BTRFS (the root file system) sporadically crashes > leaving a "kernel BUG" message in dmesg. I also noticed some files behaving > like this: > > $ ls -lai > ls: cannot access 'nlpsolver.jar':

Re: [PATCH] Btrfs: fix endless loop in balancing block groups

2016-08-31 Thread Liu Bo
On Thu, Sep 01, 2016 at 08:32:00AM +0800, Qu Wenruo wrote: > > > At 09/01/2016 07:43 AM, Liu Bo wrote: > > Qgroup function may overwrite the saved error 'err' with 0 > > in case quota is not enabled, and this ends up with a > > endless loop in balance because we

[PATCH] Btrfs: fix endless loop in balancing block groups

2016-08-31 Thread Liu Bo
Qgroup function may overwrite the saved error 'err' with 0 in case quota is not enabled, and this ends up with a endless loop in balance because we keep going back to balance the same block group. It really should use 'ret' instead. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs

[PATCH] Btrfs: bail out if block group has different mixed flag

2016-08-25 Thread Liu Bo
, and global_block_rsv.space_info points to the latter one, but all bytes from block_group contributes to the mixed space_info, thus all the allocation will fail with ENOSPC. This adds a check for the above case. Reported-by: Vegard Nossum <vegard.nos...@oracle.com> Signed-off-by: Liu Bo

Re: [PATCH] Btrfs: fix memory leak in reading btree blocks

2016-08-24 Thread Liu Bo
Hi David, On Wed, Aug 03, 2016 at 12:33:01PM -0700, Liu Bo wrote: > So we can read a btree block via readahead or intentional read, > and we can end up with a memory leak when something happens as > follows, > 1) readahead starts to read block A but does not wait for read >

Re: [PATCH] btrfs: Fix extent map leak in find_first_block_group

2016-08-24 Thread Liu Bo
On Wed, Aug 24, 2016 at 09:54:16AM +0100, Filipe Manana wrote: > On Wed, Aug 24, 2016 at 5:13 AM, Qu Wenruo <quwen...@cn.fujitsu.com> wrote: > > The following commit introduced the extent map leak: > > commit 6fb37b756acce6d6e045f79c3764206033f617b4 > > Author: L

Re: [PATCH] Btrfs: fix em leak in find_first_block_group

2016-08-24 Thread Liu Bo
On Thu, Aug 18, 2016 at 03:30:06PM -0400, Josef Bacik wrote: > We need to call free_extent_map() on the em we look up.Btrfs: fix em leak in > find_first_block_group > > We need to call free_extent_map() on the em we look up. Thanks for fixing it. Reviewed-by: Liu Bo <bo.li

[PATCH v2] Btrfs: check btree node's nritems

2016-08-23 Thread Liu Bo
s adds the check for btree's node nritems so that we stop reading block when when something is wrong. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - remove unnecessary "noinline" - fix to do the proper check as BTRFS_NODEPTRS_PER_BLOCK(root) is inclusive and nr is unsigned. f

Re: [PATCH] Btrfs: check btree node's nritems

2016-08-23 Thread Liu Bo
On Tue, Aug 16, 2016 at 06:50:00PM +0200, David Sterba wrote: > On Wed, Aug 03, 2016 at 12:57:28PM -0700, Liu Bo wrote: > > When btree node (level = 1) has nritems which equals to zero, > > we can end up with panic due to insert_ptr()'s > > > > BUG_ON(slot > nrit

[PATCH v3] Btrfs: fix memory leak of block group cache

2016-08-23 Thread Liu Bo
sed in cleanup_transaction(), we end up with memory leak of these dirty block group cache. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - remove the 'return' when dirty_bgs is empty because there might be block group in list io_bgs. - remove unnecessary '\n' in btrfs_

Re: [PATCH v2] Btrfs: fix memory leak of block group cache

2016-08-23 Thread Liu Bo
Hi David, On Fri, Aug 19, 2016 at 01:28:23PM +0200, David Sterba wrote: > On Thu, Jul 21, 2016 at 02:33:19PM -0700, Liu Bo wrote: > > > > update_block_group() is the only producer to add block group cache to > > > > dirty_bgs list, and if btrfs_run_delayed_ref

[PATCH v2] Btrfs: detect corruption when non-root leaf has zero item

2016-08-23 Thread Liu Bo
by setup_inline_extent_backref(). This makes us check the situation as a corruption if leaf is not its own root. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: fix code style. fs/btrfs/disk-io.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/disk-

Re: [PATCH] Btrfs: detect corruption when non-root leaf has zero item

2016-08-21 Thread Liu Bo
On Tue, Aug 16, 2016 at 07:07:28PM +0200, David Sterba wrote: > On Wed, Aug 03, 2016 at 09:57:08PM -0700, Liu Bo wrote: > > Right now we treat leaf which has zero item as a valid one > > because we could have an empty tree, that is, a root that is > > also a leaf with

[PATCH] Btrfs: detect corruption when non-root leaf has zero item

2016-08-03 Thread Liu Bo
by setup_inline_extent_backref(). This makes us check the situation as a corruption if leaf is not its own root. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 22 +- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/dis

[PATCH] Btrfs: check btree node's nritems

2016-08-03 Thread Liu Bo
s adds the check for btree's node nritems so that we stop reading block when when something is wrong. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 17 + 1 file changed, 17 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 37d1780..a5

[PATCH] Btrfs: fix memory leak in reading btree blocks

2016-08-03 Thread Liu Bo
y 2) so we has to readpage on the page, we get the wrong eb->io_pages which results in a memory leak of this block. This fixes the problem by firstly getting all pages's locking and then checking pages' uptodate bit. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/ext

[PATCH v2] Btrfs: clarify do_chunk_alloc()'s return value

2016-07-29 Thread Liu Bo
51/ This add comments to clarify do_chunk_alloc()'s return value. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: Since there is already a patch fixing the problem, lets do the comment part separately. fs/btrfs/extent-tree.c | 9 + 1 file changed, 9 insertions(+) diff --

[PATCH v4] Btrfs: remove BUG() in raid56

2016-07-29 Thread Liu Bo
return error properly. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: use btrfs_warn with more debugging information instead of WARN_ONCE. v3: give a short summary about what happens when the error occurs and add a ASSERT(0). v4: remove ASSERT(0). fs/btrfs/raid56.c | 5 - 1 file c

Re: [PATCH] Btrfs: deal with unexpected return value in flush_space

2016-07-29 Thread Liu Bo
On Fri, Jul 29, 2016 at 07:01:50PM +0200, David Sterba wrote: > On Thu, Jul 28, 2016 at 11:49:14AM -0700, Liu Bo wrote: > > > For reviewers - this came up before here: > > > https://patchwork.kernel.org/patch/7778651/ David, this patch made a mistake in commit log.

Re: [PATCH] Btrfs: deal with unexpected return value in flush_space

2016-07-28 Thread Liu Bo
On Thu, Jul 28, 2016 at 03:36:53PM +, Holger Hoffstätte wrote: > On Wed, 27 Jul 2016 18:42:03 -0700, Liu Bo wrote: > > > Function start_transaction() can return ERR_PTR(1) when flush is > > BTRFS_RESERVE_FLUSH_LIMIT, so the call graph is > > > > start

[PATCH] Btrfs: deal with unexpected return value in flush_space

2016-07-27 Thread Liu Bo
on() usually just do the IS_ERR() check which ERR_PTR(1) can pass, then it'll get a panic when dereferencing a pointer which is ERR_PTR(1). This makes flush_space() translate 'ret = 1' to 'ret = 0'. Signed-off-by: Liu Bo <bo.li@oracle.com> --- We found this 'NULL pointer dereference' on

[PATCH v3] Btrfs: remove BUG() in raid56

2016-07-27 Thread Liu Bo
return error properly. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: use btrfs_warn with more debugging information instead of WARN_ONCE. v3: - give a short summary about what happens when the error occurs. - add a ASSERT() which only takes effect for developers. fs/btrfs/raid56

Re: [PATCH v2] Btrfs: remove BUG() in raid56

2016-07-26 Thread Liu Bo
On Tue, Jul 26, 2016 at 06:58:42PM +0200, David Sterba wrote: > On Wed, Jun 29, 2016 at 05:57:56PM -0700, Liu Bo wrote: > > This BUG() has been triggered by a fuzz testing image, but in fact > > btrfs can handle this gracefully by returning -EIO. > > > > Thus, use

Re: [PATCH v2] Btrfs: fix memory leak of block group cache

2016-07-21 Thread Liu Bo
On Thu, Jul 21, 2016 at 03:17:41PM -0400, Chris Mason wrote: > > > On 07/21/2016 03:03 PM, Liu Bo wrote: > > On Thu, Jul 21, 2016 at 11:32:26AM -0400, Chris Mason wrote: > > > > > > > > > On 07/20/2016 08:44 PM, Liu Bo wrote: > > > > Whil

Re: [PATCH v2] Btrfs: fix memory leak of block group cache

2016-07-21 Thread Liu Bo
On Thu, Jul 21, 2016 at 11:32:26AM -0400, Chris Mason wrote: > > > On 07/20/2016 08:44 PM, Liu Bo wrote: > > While processing delayed refs, we may update block group's statistics > > and attach it to cur_trans->dirty_bgs, and later writing dirty block > > group

[PATCH v2] Btrfs: fix memory leak of block group cache

2016-07-20 Thread Liu Bo
sed in cleanup_transaction(), we end up with memory leak of these dirty block group cache. Since btrfs_start_dirty_block_groups() doesn't make it go to the commit critical section, this also adds the cleanup work inside it. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - remove th

[PATCH] Btrfs: fix memory leak of block group cache

2016-07-20 Thread Liu Bo
sed in cleanup_transaction(), we end up with memory leak of these dirty block group cache. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 76 ++ fs/btrfs/disk-io.h | 2 ++ fs/btrfs/extent-tree.c | 2 ++ 3 file

[PATCH] Btrfs: add ASSERT for block group's memory leak

2016-07-20 Thread Liu Bo
This adds several ASSERT()' s to report memory leak of block group cache. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent-tree.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 82b912a..50bd683 100644 --- a/fs

[PATCH] Btrfs: fix memory leak of reloc_root

2016-07-19 Thread Liu Bo
oot in btrfs_drop_snapshots() because its caller, merge_reloc_roots(), still needs to access it to cleanup reloc_root's rbtree. This makes us free reloc_root when we're going to free fs/file roots. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 9 - 1 file changed, 8 i

[PATCH] Btrfs-progs: fix btrfs-map-logical to only print extent mapping info

2016-07-14 Thread Liu Bo
hat is out of our search range and we end up with a negative @real_len and printing all mapping infos till the disk end. Signed-off-by: Liu Bo <bo.li@oracle.com> --- btrfs-map-logical.c | 5 + 1 file changed, 5 insertions(+) diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c index

Re: New btrfs sub command: btrfs inspect physical-find

2016-07-14 Thread Liu Bo
On Thu, Jul 14, 2016 at 04:05:00PM -0700, Liu Bo wrote: > On Tue, Jul 12, 2016 at 11:40:13PM +0200, Goffredo Baroncelli wrote: > > Hi All, > > > > the enclosed patch adds a new btrfs sub command: "btrfs inspect > > physical-find". The aim of thi

Re: New btrfs sub command: btrfs inspect physical-find

2016-07-14 Thread Liu Bo
On Tue, Jul 12, 2016 at 11:40:13PM +0200, Goffredo Baroncelli wrote: > Hi All, > > the enclosed patch adds a new btrfs sub command: "btrfs inspect > physical-find". The aim of this new command is to show the physical placement > on the disk of a file. Currently it handles all the profiles

[PATCH v3] Btrfs: fix unexpected balance crash due to BUG_ON

2016-07-12 Thread Liu Bo
<master.b.at.ra...@chefmail.de> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Initialize path with NULL. - Show more information when we bail out. v3: - Fix typo - Use rcu version btrfs_info - Remove __func__ and __LINE__ fs/btrfs/volumes.c | 28

[PATCH v2] Btrfs: fix panic in balance due to EIO

2016-07-12 Thread Liu Bo
ned-off-by: Liu Bo <bo.li@oracle.com> --- v2: Set node to NULL if we know it'll be freed. fs/btrfs/relocation.c | 4 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 9732919..535314a 100644 --- a/fs/btrfs/relocation.c +++ b

Re: [PATCH] Btrfs: fix panic in balance due to EIO

2016-07-12 Thread Liu Bo
On Tue, Jul 12, 2016 at 11:05:48AM -0400, Chris Mason wrote: > > > On 07/11/2016 08:37 PM, Liu Bo wrote: > > During build_backref_tree(), if we fail to read a btree node, > > we can eventually run into BUG_ON(cache->nr_nodes) that we put > > in backref_cache_clean

[PATCH] Btrfs: change BUG_ON()'s to ASSERT()'s in backref_cache_cleanup()

2016-07-11 Thread Liu Bo
Since it is just an in-memory building of the backrefs of several btree blocks, nothing is fatal other than memory leaks, so this changes BUG_ON()'s to ASSERT()'s. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/relocation.c | 12 ++-- 1 file changed, 6 insertions

[PATCH] Btrfs: fix panic in balance due to EIO

2016-07-11 Thread Liu Bo
ned-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/relocation.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 0477dca..f00267a 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1135,6 +1135

Re: [PATCH v3] Btrfs: fix eb memory leak due to readpage failure

2016-07-11 Thread Liu Bo
On Mon, Jul 11, 2016 at 06:54:02PM -0400, Chris Mason wrote: > On Mon, Jul 11, 2016 at 03:48:38PM -0700, Liu Bo wrote: > > On Mon, Jul 11, 2016 at 02:27:39PM -0400, Chris Mason wrote: > > > > > > > > > On 07/11/2016 01:39 PM, Liu Bo wrote: > > > >

Re: [PATCH v3] Btrfs: fix eb memory leak due to readpage failure

2016-07-11 Thread Liu Bo
On Mon, Jul 11, 2016 at 02:27:39PM -0400, Chris Mason wrote: > > > On 07/11/2016 01:39 PM, Liu Bo wrote: > > eb->io_pages is set in read_extent_buffer_pages(). > > > > In case of readpage failure, for pages that have been added to bio, > > it calls bio_end

[PATCH v3] Btrfs: fix eb memory leak due to readpage failure

2016-07-11 Thread Liu Bo
bio(), it cannot decrease eb->io_pages via bio_endio, and ends up with a memory leak eventually. This lets __do_readpage propagate errors to callers and adds the 'atomic_dec(>io_pages)'. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Move 'dec io_pages' to the caller so that w

[PATCH v2] Btrfs: fix unexpected balance crash due to BUG_ON

2016-07-11 Thread Liu Bo
<master.b.at.ra...@chefmail.de> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Initialize path with NULL. - Show more information when we bail out. fs/btrfs/volumes.c | 30 ++ 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/vo

Re: [PATCH] Btrfs: fix unexpected balance crash due to BUG_ON

2016-07-08 Thread Liu Bo
On Fri, Jul 08, 2016 at 06:05:16PM +0200, David Sterba wrote: > On Tue, May 03, 2016 at 04:30:54PM -0700, Liu Bo wrote: > > > Just a heads up that this seems to introduce a valid warning, since it now > > > can goto error before the first initializing use of path: > >

Re: [PATCH v2] Btrfs: fix eb memory leak due to readpage failure

2016-07-08 Thread Liu Bo
On Fri, Jul 08, 2016 at 06:01:49PM +0200, David Sterba wrote: > On Fri, Jun 03, 2016 at 12:08:38PM -0700, Liu Bo wrote: > > eb->io_pages is set in read_extent_buffer_pages(). > > > > In case of readpage failure, for pages that have been added to bio, > >

Re: [PATCH 1/2] btrfs: use correct offset for reloc_inode in prealloc_file_extent_cluster()

2016-07-06 Thread Liu Bo
On Wed, Jul 06, 2016 at 06:37:52PM +0800, Wang Xiaoguang wrote: > In prealloc_file_extent_cluster(), btrfs_check_data_free_space() uses > wrong file offset for reloc_inode, it uses cluster->start and cluster->end, > which indeed are extent's bytenr. The correct value should be >

[PATCH v2] Btrfs: fix read_node_slot to return errors

2016-07-05 Thread Liu Bo
ed-off-by: Liu Bo <bo.li@oracle.com> --- v2: fix tree_move_down to check the correct extent buffer. fs/btrfs/ctree.c| 69 + fs/btrfs/tree-log.c | 4 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/ctree.

Re: [PATCH] Btrfs: fix read_node_slot to return errors

2016-07-05 Thread Liu Bo
On Mon, Jul 04, 2016 at 07:08:18PM +0200, David Sterba wrote: > On Tue, Jun 28, 2016 at 06:55:48PM -0700, Liu Bo wrote: > > @@ -5238,6 +5256,10 @@ static void tree_move_down(struct btrfs_root *root, > > path->slots[*level]); > > pat

[PATCH v2] Btrfs: remove BUG() in raid56

2016-06-29 Thread Liu Bo
This BUG() has been triggered by a fuzz testing image, but in fact btrfs can handle this gracefully by returning -EIO. Thus, use btrfs_warn to give us more debugging information than a single BUG() and return error properly. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - use btrf

[PATCH] Btrfs: fix read_node_slot to return errors

2016-06-28 Thread Liu Bo
ed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/ctree.c| 63 + fs/btrfs/tree-log.c | 4 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index a85cf7d..63510e0 100644 --- a/fs/b

Re: invalid opcode 0000 / kernel bug with defect HDD

2016-06-28 Thread Liu Bo
On Tue, Jun 28, 2016 at 10:16:58AM +0200, Peter Becker wrote: > Cause of kernel bugs was a defective HDD (/dev/sdd). Thanks for reporting this bug, I can reproduce it, it's due to the fact that we cannot read a valid btree node from the underlying disks, which comes from a defective HDD in your

[PATCH] Btrfs: fix double free of fs root

2016-06-28 Thread Liu Bo
up with the above warning. Instead of reset root->anon_dev to 0 after free_anon_bdev(), we can let btrfs_init_fs_root() return directly since its callers have already done the free job by calling free_fs_root(). Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/disk-io.c | 12 +++-

[PATCH v2] Btrfs: error out if generic_bin_search get invalid arguments

2016-06-23 Thread Liu Bo
return the first child. This lets us know what's happening and returns a EINVAL to callers instead of returning the first item. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: fix typo of in printed message. fs/btrfs/ctree.c | 8 1 file changed, 8 insertions(+) diff --gi

Re: [PATCH] Btrfs: fix BUG_ON in btrfs_submit_compressed_write

2016-06-23 Thread Liu Bo
On Thu, Jun 23, 2016 at 11:09:52AM +0200, David Sterba wrote: > On Wed, Jun 22, 2016 at 06:32:06PM -0700, Liu Bo wrote: > > This is similar to btrfs_submit_compressed_read(), if we fail after > > bio is allocated, then we can use bio_endio() and errors are saved > > in bio-&

Re: [PATCH] Btrfs: error out if generic_bin_search get invalid arguments

2016-06-23 Thread Liu Bo
On Thu, Jun 23, 2016 at 10:51:52AM +0200, David Sterba wrote: > On Wed, Jun 22, 2016 at 06:32:19PM -0700, Liu Bo wrote: > > With btrfs-corrupt-block, one can set btree node/leaf's field, if > > we assign a negative value to node/leaf, we can get various hangs, > > eg. if

Re: [RFC][PATCH] btrfs-progs: inspect: new subcommand to dump chunks

2016-06-22 Thread Liu Bo
On Wed, Jun 22, 2016 at 07:26:46PM +0200, David Sterba wrote: > From: David Sterba > > Hi, > > the chunk dump is a useful thing, for debugging or balance filters. > > Example output: > > Chunks on device id: 1 > PNumberTypePStartLength

[PATCH] Btrfs: cleanup BUG_ON in merge_bio

2016-06-22 Thread Liu Bo
printed the reason, we can just return errors in merge_bio. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 1 - fs/btrfs/inode.c | 8 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index a

[PATCH] Btrfs: error out if generic_bin_search get invalid arguments

2016-06-22 Thread Liu Bo
return the first child. This lets us know what's happening and returns a EINVAL to callers instead of returning the first item. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/ctree.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c

[PATCH] Btrfs: check inconsistence between chunk and block group

2016-06-22 Thread Liu Bo
With btrfs-corrupt-block, one can drop one chunk item and mounting will end up with a panic in btrfs_full_stripe_len(). This doesn't not remove the BUG_ON, but instead checks it a bit earlier when we find the block group item. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/

[PATCH] Btrfs: fix BUG_ON in btrfs_submit_compressed_write

2016-06-22 Thread Liu Bo
off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/compression.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 658c39b..7a4d9c8 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -402,7 +402,

Re: [PATCH] Btrfs: let super_stripesize match with sectorsize

2016-06-17 Thread Liu Bo
On Fri, Jun 17, 2016 at 10:48:05AM +0530, Chandan Rajendra wrote: > On Thursday, June 16, 2016 10:01:41 AM Liu Bo wrote: > > On Thu, Jun 16, 2016 at 01:53:59PM +0530, Chandan Rajendra wrote: > > > On Wednesday, June 15, 2016 05:09:55 PM Liu Bo wrote: > > > > On W

Re: [PATCH] Btrfs: let super_stripesize match with sectorsize

2016-06-16 Thread Liu Bo
On Thu, Jun 16, 2016 at 01:53:59PM +0530, Chandan Rajendra wrote: > On Wednesday, June 15, 2016 05:09:55 PM Liu Bo wrote: > > On Wed, Jun 15, 2016 at 03:50:17PM +0530, Chandan Rajendra wrote: > > > On Wednesday, June 15, 2016 09:12:28 AM Chandan Rajendra wrote: &g

Re: [PATCH] Btrfs: track transid for delayed ref flushing

2016-06-15 Thread Liu Bo
On Wed, Apr 27, 2016 at 09:59:38AM -0400, Chris Mason wrote: > On Mon, Apr 11, 2016 at 05:37:40PM -0400, Josef Bacik wrote: > > Using the offwakecputime bpf script I noticed most of our time was spent > > waiting > > on the delayed ref throttling. This is what is supposed to happen, but > >

Re: [PATCH] Btrfs: let super_stripesize match with sectorsize

2016-06-15 Thread Liu Bo
On Wed, Jun 15, 2016 at 03:50:17PM +0530, Chandan Rajendra wrote: > On Wednesday, June 15, 2016 09:12:28 AM Chandan Rajendra wrote: > > Hello Liu Bo, > > > > We have to fix the following check in check_super() as well, > > > >if (b

Re: [PATCH] Btrfs: add missing check for writeback errors on fsync

2016-06-15 Thread Liu Bo
gt; Fix this by checking for errors in the flags of the inode's mapping when > we notice we can skip logging the inode. > > This caused sporadic failures in the test generic/331 (which explicitly > tests for IO errors during an fsync call). Good catch. Reviewed-by: Liu Bo <bo.li@

[PATCH] Btrfs: let super_stripesize match with sectorsize

2016-06-14 Thread Liu Bo
Right now stripesize is set to 4096 while sectorsize is set to max(4096, pagesize). However, kernel requires super_stripesize to match with sectorsize. Reported-by: Eryu Guan <guane...@gmail.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- mkfs.c | 2 ++ 1 file changed,

Re: BUG: unable to mount btrfs on ppc64 starting from v4.7-rc3 kernel

2016-06-14 Thread Liu Bo
Hi, On Tue, Jun 14, 2016 at 07:13:22PM +0800, Eryu Guan wrote: > Hi, > > I'm unable to mount btrfs on ppc64 hosts and other hosts with 64k > pagesize(like aarch64, ppc64le). It seems that it's commit 99e3ecfcb9f4 > ("Btrfs: add more validation checks for superblock") introduced this > failure,

Re: [PATCH 2/2] btrfs: prefix fsid to all trace events

2016-06-10 Thread Liu Bo
standard information to the head of a trace event. > > The extent_state alloc/free events are all that's left without an > fs_info available. Looks good to me. Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > > Signed-off-by: Jeff Mahoney <je...@suse.com> >

[PATCH v2] Btrfs: check if extent buffer is aligned to sectorsize

2016-06-06 Thread Liu Bo
. Now that alloc_extent_buffer() no more returns NULL, this changes its caller and callers of its caller to match with the new error handling. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Add more fine-grained error handling to alloc_extent_buffer() and its callers - Use btr

Re: [PATCH] Btrfs: clear uptodate flags of pages in sys_array eb

2016-06-03 Thread Liu Bo
On Fri, Jun 03, 2016 at 05:41:42PM -0700, Liu Bo wrote: > We set uptodate flag to pages in the temporary sys_array eb, > but do not clear the flag after free eb. As the special > btree inode may still hold a reference on those pages, the > uptodate flag can remain a

[PATCH] Btrfs: clear uptodate flags of pages in sys_array eb

2016-06-03 Thread Liu Bo
of this sys_array eb, reading chunk_root will read content of sys_array and it will pass our beautiful checks in btree_readpage_end_io_hook() because of "pages of eb are uptodate => eb is uptodate" This adds the 'clear uptodate' part to force it to read from disk. Signed-off-by:

[PATCH v2] Btrfs: fix eb memory leak due to readpage failure

2016-06-03 Thread Liu Bo
bio(), it cannot decrease eb->io_pages via bio_endio, and ends up with a memory leak eventually. This lets __do_readpage propagate errors to callers and adds the 'atomic_dec(>io_pages)'. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Move 'dec io_pages' to the caller so that w

[PATCH v2 2/2] Btrfs: add valid checks for chunk loading

2016-06-03 Thread Liu Bo
cases, feel free to add more checks. Reported-by: Vegard Nossum <vegard.nos...@oracle.com> Reported-by: Quentin Casasnovas <quentin.casasno...@oracle.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - Fix several typos. fs/bt

[PATCH v2 1/2] Btrfs: add more valid checks for superblock

2016-06-03 Thread Liu Bo
This adds valid checks for super_total_bytes, super_bytes_used and super_stripesize, super_num_devices. Reported-by: Vegard Nossum <vegard.nos...@oracle.com> Reported-by: Quentin Casasnovas <quentin.casasno...@oracle.com> Signed-off-by: Liu Bo <bo.li@oracle.com>

Re: btrfs ENOSPC "not the usual problem"

2016-06-03 Thread Liu Bo
On Thu, Jun 02, 2016 at 07:45:49PM +, Omari Stephens wrote: > [Note: not on list; please reply-all] > > I've read everything I can find about running out of space on btrfs, and it > hasn't helped. I'm currently dead in the water. > > Everything I do seems to make the problem monotonically

Re: [PATCH v3 21/22] btrfs-progs: convert: Strictly avoid meta or system chunk allocation

2016-05-27 Thread Liu Bo
On Fri, Jan 29, 2016 at 01:03:31PM +0800, Qu Wenruo wrote: > Before this patch, btrfs-convert only rely on large enough initial > system/metadata chunk size to ensure no newer system/meta chunk will be > created. > > But that's not safe enough. So add two new members in fs_info, >

Re: [PATCH v3 16/22] btrfs-progs: convert: Introduce function to migrate reserved ranges

2016-05-27 Thread Liu Bo
On Fri, Jan 29, 2016 at 01:03:26PM +0800, Qu Wenruo wrote: > Introduce new function, migrate_reserved_ranges() to migrate used fs > data in btrfs reserved space. > > Unlike old implement, which will need to relocate all the complicated > csum and reference relocation, previous patches already

Re: [PATCH v3 15/22] btrfs-progs: convert: Introduce new function to create converted image

2016-05-27 Thread Liu Bo
On Fri, Jan 29, 2016 at 01:03:25PM +0800, Qu Wenruo wrote: > Use new function, create_convert_image_v2() to create snapshot of old > filesystem. > > Unlike old function which is called after copying all inodes, this > function need to be called before copying inodes. > > Signed-off-by: Qu Wenruo

Re: [PATCH v3 05/22] btrfs-progs: Introduce function to setup temporary superblock

2016-05-27 Thread Liu Bo
On Fri, Jan 29, 2016 at 01:03:15PM +0800, Qu Wenruo wrote: > Introduce a new function, setup_temp_super(), to setup temporary super > for make_btrfs_v2(). > > Signed-off-by: Qu Wenruo > Signed-off-by: David Sterba > --- > utils.c | 117 >

[PATCH 1/2] Btrfs-progs: make convert to allocate space from the desired type of block group

2016-05-26 Thread Liu Bo
During btrfs-convert, it can allocate space from METADATA block group for data, which is not supposed to be correct, although it doesn't cause any serious problem except eating METADATA space more quickly. Signed-off-by: Liu Bo <bo.li@oracle.com> --- btrfs-convert.c | 6 ++

[PATCH 2/2] Btrfs-progs: convert: add hint bytenr when allocating free space

2016-05-26 Thread Liu Bo
Without proper hint, btrfs-convert always starts searching from the very first available block which usually belongs to SYSTEM block group, but we're not allowed to use any block in SYSTEM block group for metadata/data. This adds hint to make convert smarter. Signed-off-by: Liu Bo <bo

Re: [PATCH] Btrfs: fix unexpected return value of fiemap

2016-05-18 Thread Liu Bo
On Wed, May 18, 2016 at 11:41:05AM +0200, David Sterba wrote: > On Tue, May 17, 2016 at 05:21:48PM -0700, Liu Bo wrote: > > btrfs's fiemap is supposed to return 0 on success and > > return < 0 on error, however, ret becomes 1 after looking > > up the last file extent, and

[PATCH] Btrfs: fix unexpected return value of fiemap

2016-05-17 Thread Liu Bo
btrfs's fiemap is supposed to return 0 on success and return < 0 on error, however, ret becomes 1 after looking up the last file extent, and if the offset is beyond EOF, we can return 1. This may confuse applications using ioctl(FIEL_IOC_FIEMAP). Signed-off-by: Liu Bo <bo.li@orac

Re: [PATCH 3/7] Btrfs: check if extent buffer is aligned to sectorsize

2016-05-17 Thread Liu Bo
On Tue, May 17, 2016 at 11:39:52AM +0200, David Sterba wrote: > On Mon, May 16, 2016 at 11:01:41AM -0700, Liu Bo wrote: > > On Sat, May 14, 2016 at 06:30:52PM +0800, Qu Wenruo wrote: > > > Hi Liu, > > > > > > Thanks for your patch first. > > >

Re: [PATCH 5/7] Btrfs: replace BUG_ON with WARN in merge_bio

2016-05-17 Thread Liu Bo
On Tue, May 17, 2016 at 11:55:19AM +0200, David Sterba wrote: > On Mon, May 16, 2016 at 10:24:01AM -0700, Liu Bo wrote: > > On Mon, May 16, 2016 at 10:44:38AM +0200, David Sterba wrote: > > > On Fri, May 13, 2016 at 05:07:00PM -0700, Liu Bo wrote: > > > > We have two

Re: [PATCH 3/7] Btrfs: check if extent buffer is aligned to sectorsize

2016-05-16 Thread Liu Bo
On Sat, May 14, 2016 at 06:30:52PM +0800, Qu Wenruo wrote: > Hi Liu, > > Thanks for your patch first. > > On 05/14/2016 08:06 AM, Liu Bo wrote: > > Thanks to fuzz testing, we can pass an invalid bytenr to extent buffer > > via alloc_extent_buffer(). An unaligned

Re: [PATCH 5/7] Btrfs: replace BUG_ON with WARN in merge_bio

2016-05-16 Thread Liu Bo
On Mon, May 16, 2016 at 10:44:38AM +0200, David Sterba wrote: > On Fri, May 13, 2016 at 05:07:00PM -0700, Liu Bo wrote: > > We have two BUG_ON in merge_bio, but since it can gracefully return errors > > to callers, use WARN_ONCE to give error information and don't leave a >

[PATCH 1/7] Btrfs: replace BUG() with WARN_ONCE in raid56

2016-05-13 Thread Liu Bo
This BUG() has been triggered by a fuzz testing image, but in fact btrfs can handle this gracefully by returning -EIO. Thus, use WARN_ONCE for warning purpose and don't leave a possible kernel panic. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/raid56.c | 2 +- 1 file chan

[PATCH 3/7] Btrfs: check if extent buffer is aligned to sectorsize

2016-05-13 Thread Liu Bo
. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 4 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index d247fc0..e601e0f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -4868,6 +4868,10 @@ struct extent_

[PATCH 2/7] Btrfs: replace BUG_ON with WARN_ONCE in cow_file_range

2016-05-13 Thread Liu Bo
This BUG_ON is more like a warning since an invalid btrfs_super_total_bytes() doesn't affect other stuff. Thus, use WARN_ONCE for warning purpose and don't leave a possible kernel panic here. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/inode.c | 7 +-- 1 file chan

[PATCH 6/7] Btrfs: fix eb memory leak due to readpage failure

2016-05-13 Thread Liu Bo
bio(), it cannot decrease eb->io_pages via bio_endio, and ends up with a memory leak eventually. This adds the 'atomic_dec(>io_pages)' to the readpage error handling. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 24 1 file changed

[PATCH 7/7] Btrfs: fix memory leak due to invalid btree height

2016-05-13 Thread Liu Bo
Thanks to fuzz testing, we can have invalid btree root node height. Btrfs limits btree height to 7 and if the given height is 9, then btrfs will have problems in both releasing root node's lock and freeing the node. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/ctree.c | 7

[PATCH 4/7] Btrfs: free sys_array eb as soon as possible

2016-05-13 Thread Liu Bo
While reading sys_chunk_array in superblock, btrfs creates a temporary extent buffer. Since we don't use it after finishing reading sys_chunk_array, we don't need to keep it in memory. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 inse

[PATCH 5/7] Btrfs: replace BUG_ON with WARN in merge_bio

2016-05-13 Thread Liu Bo
We have two BUG_ON in merge_bio, but since it can gracefully return errors to callers, use WARN_ONCE to give error information and don't leave a possible panic. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 1 - fs/btrfs/inode.c | 6 -- 2 files chan

Re: [PATCH 2/2] Btrfs: add valid checks for chunk loading

2016-05-13 Thread Liu Bo
On Wed, May 04, 2016 at 03:56:26PM +0200, David Sterba wrote: > A few minor comments below > > On Mon, May 02, 2016 at 11:15:51AM -0700, Liu Bo wrote: > > --- a/fs/btrfs/volumes.c > > +++ b/fs/btrfs/volumes.c > > @@ -6206,27 +6206,23 @@ struct btrfs_device

Re: [PATCH 1/2] Btrfs: add more valid checks for superblock

2016-05-13 Thread Liu Bo
On Mon, May 09, 2016 at 09:31:37AM +0800, Qu Wenruo wrote: > > > David Sterba wrote on 2016/05/06 16:35 +0200: > > On Thu, May 05, 2016 at 09:08:54AM +0800, Qu Wenruo wrote: > > > > > An early check can compare against some reasonable value, but the > > > > > total_bytes value must be equal to

Re: [PATCH 2/3] Btrfs-progs: add three more valid checks for superblock

2016-05-11 Thread Liu Bo
On Wed, May 11, 2016 at 03:36:29PM +0200, David Sterba wrote: > On Mon, May 02, 2016 at 11:18:54AM -0700, Liu Bo wrote: > > This adds valid checks for super_total_bytes, super_bytes_used and > > super_stripesize. > > > > Since these checks are made after superblock fini

Re: [PATCH v3 2/2] Btrfs: don't do unnecessary delalloc flushes when relocating

2016-05-10 Thread Liu Bo
that semaphore and creating the ordered extent. > + */ > + down_write(_info->groups_sem); > + up_write(_info->groups_sem); > + > + wait_on_atomic_t(>reservations, > + btrfs_wait_bg_reservations_atomic_t, > + TASK

Re: [PATCH v2 1/2] Btrfs: don't wait for unrelated IO to finish before relocation

2016-05-10 Thread Liu Bo
waits for all ordered extents to complete. This last step includes > waiting for ordered extents destinated at extents allocated in other block > groups, making us waste unecessary time. > > So improve this by waiting only for ordered extents that fall into the > block group's range. Revie

Re: [PATCH 3/3] Btrfs: don't do unnecessary delalloc flushes when relocating

2016-05-09 Thread Liu Bo
On Mon, Apr 25, 2016 at 02:01:12AM +0100, fdman...@kernel.org wrote: > From: Filipe Manana > > Before we start the actual relocation process of a block group, we do > calls to flush delalloc of all inodes and then wait for ordered extents > to complete. However we do these

<    5   6   7   8   9   10   11   12   13   14   >