[PATCH 1/6] Btrfs: use bio_clone_fast to clone our bio

2017-04-17 Thread Liu Bo
For raid1 and raid10, we clone the original bio to the bios which are then sent to different disks. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 2

Re: Remounting read-write after error is not allowed

2017-04-17 Thread Liu Bo
On Mon, Apr 17, 2017 at 02:00:45PM -0400, Alexandru Guzu wrote: > Not sure if anyone is looking into that segfault, but I have an update. > I disconnected the USB drive for a while and today I reconnected it > and it auto-mounted with no issue. > > What is interesting is that the drive letter

Re: compressing nocow files

2017-04-17 Thread Liu Bo
On Mon, Apr 17, 2017 at 11:36:17AM -0600, Chris Murphy wrote: > HI, > > > /dev/nvme0n1p8 on / type btrfs > (rw,relatime,seclabel,ssd,space_cache,subvolid=258,subvol=/root) > > I've got a test folder with +C set and then copied a test file into it. > > $ lsattr > C-- >

[PATCH] Btrfs: tolerate errors if we have retried successfully

2017-04-13 Thread Liu Bo
With raid1 profile, dio read isn't tolerating IO errors if read length is less than the stripe length (64K). This fixes the problem by setting bio's error to 0 if a good copy has been found. Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/inode.c | 5 - 1 file chan

[PATCH] Btrfs: skip checksum verification if IO error occurs

2017-04-13 Thread Liu Bo
-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/inode.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5e71f1e..632b616 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8030,6 +8030,7 @@ stat

Re: [PATCH v4 1/7] btrfs: use blkdev_issue_flush to flush the device cache

2017-04-13 Thread Liu Bo
(bio); > + int ret; > + struct btrfs_device *device; > + > + device = container_of(work, struct btrfs_device, flush_work); > + > + /* we are in the commit thread */ What is the above comment trying to explain? Others look good. Reviewed-by: Liu Bo <bo.li@oracle.c

Re: [PATCH] fstests: regression test for btrfs dio read repair

2017-04-12 Thread Liu Bo
On Wed, Apr 12, 2017 at 10:42:47AM +0100, Filipe Manana wrote: > On Wed, Apr 12, 2017 at 2:27 AM, Liu Bo <bo.li@oracle.com> wrote: > > This case tests whether dio read can repair the bad copy if we have > > a good copy. > > Regardless of being a test we sho

[PATCH] fstests: regression test for btrfs buffered read's repair

2017-04-11 Thread Liu Bo
This case tests whether buffered read can repair the bad copy if we have a good copy. Signed-off-by: Liu Bo <bo.li@oracle.com> --- tests/btrfs/141 | 152 tests/btrfs/141.out | 39 ++ tests/btrfs/group | 1 + 3

[PATCH] fstests: regression test for btrfs dio read repair

2017-04-11 Thread Liu Bo
This case tests whether dio read can repair the bad copy if we have a good copy. Signed-off-by: Liu Bo <bo.li@oracle.com> --- tests/btrfs/140 | 152 tests/btrfs/140.out | 39 ++ tests/btrfs/group | 1 + 3 files c

[PATCH] fstests: introduce btrfs-map-logical

2017-04-11 Thread Liu Bo
A typical use case of 'btrfs-map-logical' is to translate btrfs logical address to physical address on each disk. Signed-off-by: Liu Bo <bo.li@oracle.com> --- common/config | 1 + 1 file changed, 1 insertion(+) diff --git a/common/config b/common/config index 59041a3..b7c06bf

[PATCH] fstests: remove snapshot aware defrag test

2017-04-11 Thread Liu Bo
Since snapshot aware defrag has been disabled in kernel, and we all have learned to ignore the failure of btrfs/010, lets just remove it. Signed-off-by: Liu Bo <bo.li@oracle.com> --- tests/btrfs/010 | 93 - tests/btrfs/010.ou

[PATCH] Btrfs: fix potential use-after-free for cloned bio

2017-04-10 Thread Liu Bo
cloned bios are likely to be freed by its endio. Reported-by: Diego <dieg...@gmail.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 73d56ee..ab

Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division

2017-04-10 Thread Liu Bo
On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote: > Unbreaks ARM and possibly other 32-bit architectures. > Thanks a lot for the fix. Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Fixes: 7d0ef8b4d: Btrfs: update scrub_parity to use u64 stripe

Re: [PATCH] Btrfs: fix segment fault when doing dio read

2017-04-10 Thread Liu Bo
On Sun, Apr 09, 2017 at 08:08:05PM +0300, Nikolay Borisov wrote: > > > On 7.04.2017 23:11, Liu Bo wrote: > > Commit 2dabb3248453 ("Btrfs: Direct I/O read: Work on sectorsized blocks") > > introduced this bug during iterating bio pages in dio read's endi

Re: BUG: KASAN: use-after-free in btrfs_map_bio

2017-04-10 Thread Liu Bo
On Mon, Apr 10, 2017 at 07:13:46PM +0200, Diego wrote: > In the latest git, with KASAN enabled: > > [ 180.560145] BUG: KASAN: use-after-free in btrfs_map_bio+0x994/0x10b0 at > addr 8803801a76fc > [ 180.560151] Read of size 4 by task localStorage DB/924 > [ 180.560160] CPU: 0 PID: 924

[PATCH] Btrfs: fix segment fault when doing dio read

2017-04-07 Thread Liu Bo
ere is one more block in the same page, so page offset is increased and the bio which is created to repair the bad block then has an incorrect bvec.bv_offset, and a later access of the page content would throw a segment fault. This also adds ASSERT to check page offset against page size. Signed-o

Re: [PATCH] Btrfs: fix invalid dereference in btrfs_retry_endio

2017-04-06 Thread Liu Bo
On Thu, Apr 06, 2017 at 04:21:50PM +0200, David Sterba wrote: > On Wed, Apr 05, 2017 at 02:04:19PM -0700, Liu Bo wrote: > > When doing directIO repair, we have this oops > > > > [ 1458.532816] general protection fault: [#1] SMP > > ... > > [ 1458.5362

[PATCH] Btrfs: fix invalid dereference in btrfs_retry_endio

2017-04-05 Thread Liu Bo
ate patch). Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/inode.c | 14 -- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3ec5a05..8e71ed7 100644 --- a/fs/btrfs/inode.c

Re: [PATCH] Btrfs: cleanup submit_one_bio

2017-04-04 Thread Liu Bo
On Mon, Apr 03, 2017 at 01:45:47PM -0700, Liu Bo wrote: > @bio_offset is passed into submit_bio_hook and is used at > btrfs_wq_submit_bio(), but only dio code makes use of @bio_offset, so > remove other dead code. > Please ignore this one. Thanks, -liubo > Cc: David Sterba &

[PATCH] Btrfs: cleanup submit_one_bio

2017-04-03 Thread Liu Bo
@bio_offset is passed into submit_bio_hook and is used at btrfs_wq_submit_bio(), but only dio code makes use of @bio_offset, so remove other dead code. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 7 +-- 1 fil

[PATCH] Btrfs: update scrub_parity to use u64 stripe_len

2017-04-03 Thread Liu Bo
z> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/scrub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index b9525ca..fab351c 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -140,7 +140,7 @@ struct scrub_

[PATCH] Btrfs: switch to div64_u64 if with a u64 divisor

2017-04-03 Thread Liu Bo
This is fixing code pieces where we use div_u64 when passing a u64 divisor. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/scrub.c | 4 ++-- fs/btrfs/volumes.c | 8 3 files changed, 7 inse

Re: [PATCH v4 1/5] btrfs: scrub: Introduce full stripe lock for RAID56

2017-03-31 Thread Liu Bo
On Fri, Mar 31, 2017 at 09:29:20AM +0800, Qu Wenruo wrote: > > > At 03/31/2017 12:49 AM, Liu Bo wrote: > > On Thu, Mar 30, 2017 at 02:32:47PM +0800, Qu Wenruo wrote: > > > Unlike mirror based profiles, RAID5/6 recovery needs to read out the > > > whole full str

Re: [PATCH v4 2/5] btrfs: scrub: Fix RAID56 recovery race condition

2017-03-30 Thread Liu Bo
On Thu, Mar 30, 2017 at 02:32:48PM +0800, Qu Wenruo wrote: > When scrubbing a RAID5 which has recoverable data corruption (only one > data stripe is corrupted), sometimes scrub will report more csum errors > than expected. Sometimes even unrecoverable error will be reported. > > The problem can

Re: [PATCH v4 1/5] btrfs: scrub: Introduce full stripe lock for RAID56

2017-03-30 Thread Liu Bo
: lock_full_stripe() and unlock_full_stripe() > for RAID5/6. > Which stores a rb_tree of mutex for full stripes, so scrub callers can > use them to lock a full stripe to avoid race. > > Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com> > Reviewed-by: Liu Bo <bo.li@oracle.com> > -

Re: [PATCH v3 2/5] btrfs: scrub: Fix RAID56 recovery race condition

2017-03-29 Thread Liu Bo
On Wed, Mar 29, 2017 at 09:33:19AM +0800, Qu Wenruo wrote: [...] > > Reported-by: Goffredo Baroncelli > Signed-off-by: Qu Wenruo > --- > fs/btrfs/scrub.c | 14 ++ > 1 file changed, 14 insertions(+) > > diff --git a/fs/btrfs/scrub.c

Re: [PATCH v3 1/5] btrfs: scrub: Introduce full stripe lock for RAID56

2017-03-29 Thread Liu Bo
return -ENOENT; Ditto. > + if (!(bg_cache->flags & BTRFS_BLOCK_GROUP_RAID56_MASK)) > + goto out; > + > + locks_root = _cache->full_stripe_locks_root; > + ret = get_full_stripe_logical(fs_info, bytenr, _start); > + if (ret < 0) >

Re: [PATCH v3 5/5] btrfs: Prevent scrub recheck from racing with dev replace

2017-03-29 Thread Liu Bo
ds/lead/ > Fix it by increasing bio_counter before calling btrfs_map_sblock() and > decrease the bio_counter when corresponding recover is finished. > *decreasing Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Cc: Liu Bo <bo.li....@oracle.com> > Reported-by:

Re: [PATCH v3 4/5] btrfs: Wait flighting bio before freeing target device for raid56

2017-03-29 Thread Liu Bo
least 2 places are calling > btrfs_map_sblock() without protection of bio_counter, leading to the > problem. > > This patch fixes the problen by typo: *problem" > 1) Wait bio_counter before freeing target device when canceling replace > 2) When calling btrfs_map_sblock() fo

Re: [PATCH v3 3/5] btrfs: scrub: Don't append on-disk pages for raid56 scrub

2017-03-29 Thread Liu Bo
ages[], which contains old on-disk > data. > s/appending/append/ > And when we submit parity data to disk, we calculate parity using > rbio->bio_pages[] first, if rbio->bio_pages[] not found, then fallback > to rbio->stripe_pages[]. > *is not found > The patch fix it b

[PATCH v2] Btrfs: set scrub page's io_error if failing to submit io

2017-03-29 Thread Liu Bo
skip this page when repairing bad copy from good copy. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: Put more details in changelog. fs/btrfs/scrub.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/scrub.

[PATCH v2] Btrfs: fix wrong failed mirror_num of read-repair on raid56

2017-03-29 Thread Liu Bo
In raid56 scenario, after trying parity recovery, we didn't set mirror_num for btrfs_bio with failed mirror_num, hence end_bio_extent_readpage() will report a random mirror_num in dmesg log. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: Se

[PATCH v2] Btrfs: enable repair during read for raid56 profile

2017-03-29 Thread Liu Bo
ock during read. The trick is to use BTRFS_MAP_READ instead of BTRFS_MAP_WRITE to get the device and position on it. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: Fix typo and add comments for why BTRFS_MAP_READ is used. fs/btrfs/e

[PATCH v3] Btrfs: bring back repair during read

2017-03-29 Thread Liu Bo
the index in the checksum array and inode's readpage_io_failed_hook doesn't offer that offset. Cc: David Sterba <dste...@suse.cz> Reviewed-by: David Sterba <dste...@suse.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: fix grammar typos and additional details about th

Re: [PATCH] Btrfs: fix wrong failed mirror_num of read-repair on raid56

2017-03-28 Thread Liu Bo
On Mon, Mar 27, 2017 at 07:07:15PM +0200, David Sterba wrote: > On Fri, Mar 24, 2017 at 12:13:42PM -0700, Liu Bo wrote: > > In raid56 senario, after trying parity recovery, we didn't set > > mirror_num for btrfs_bio with failed mirror_num, hence > > end_bio_extent_readpage()

Re: [PATCH] Btrfs: enable repair during read for raid56 profile

2017-03-28 Thread Liu Bo
On Mon, Mar 27, 2017 at 06:59:44PM +0200, David Sterba wrote: > On Fri, Mar 24, 2017 at 12:13:35PM -0700, Liu Bo wrote: > > Now that scrub can fix data errors with the help of parity for raid56 > > profile, repair during read is able to as well. > > > > Although the m

Re: [PATCH v2] Btrfs: fix unexpected file hole after disk errors

2017-03-28 Thread Liu Bo
On Tue, Mar 28, 2017 at 02:50:06PM +0200, David Sterba wrote: > On Mon, Mar 06, 2017 at 12:23:30PM -0800, Liu Bo wrote: > > Btrfs creates hole extents to cover any unwritten section right before > > doing buffer writes after commit 3ac0d7b96a26 ("btrfs: Change the expandin

[PATCH] Btrfs: set scrub page's io_error if failing to submit io

2017-03-24 Thread Liu Bo
Otherwise, we may later skip this page when repairing bad copy from good copy. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/scrub.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/b

Re: [PATCH v2 5/5] btrfs: raid56: Use bio_counter to protect scrub

2017-03-24 Thread Liu Bo
sblock(), until rbio endio. > > Liu Bo <bo.li@oracle.com> > Signed-off-by: Qu Wenruo <quwen...@cn.fujitsu.com> > --- > fs/btrfs/raid56.c | 2 ++ > fs/btrfs/scrub.c | 5 + > 2 files changed, 7 insertions(+) > > diff --git a/fs/btrfs/raid56.c b/fs/bt

Re: [PATCH v2 3/5] btrfs: scrub: Don't append on-disk pages for raid56 scrub

2017-03-24 Thread Liu Bo
es[], which contains old on-disk > data. > > And when we submit parity data to disk, we calculate parity using > rbio->bio_pages[] first, if rbio->bio_pages[] not found, then fallback > to rbio->stripe_pages[]. > > The patch fix it by not appending pages from sparity->

[PATCH v2] Btrfs: bring back repair during read

2017-03-24 Thread Liu Bo
the index in the checksum array and inode's readpage_io_failed_hook doesn't offer that offset. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: fix grammar typos and additional details about the change. fs/

[PATCH] Btrfs: fix wrong failed mirror_num of read-repair on raid56

2017-03-24 Thread Liu Bo
In raid56 senario, after trying parity recovery, we didn't set mirror_num for btrfs_bio with failed mirror_num, hence end_bio_extent_readpage() will report a random mirror_num in dmesg log. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/v

[PATCH] Btrfs: enable repair during read for raid56 profile

2017-03-24 Thread Liu Bo
ock during read. The trick is to use BTRFS_MAP_READ instead of BTRFS_MAP_WRITE to get the device and position on it. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 35 ++- 1 file changed, 22 in

[PATCH] Btrfs: bring back repair during read

2017-03-24 Thread Liu Bo
the index in the checksum array. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 46 -- fs/btrfs/inode.c | 7 +++ 2 files changed, 31 insertions(+), 22 deletions(-) diff --git

Re: [PATCH RFC] btrfs: introduce a separate mutex for caching_block_groups list

2017-03-21 Thread Liu Bo
On Sun, Mar 19, 2017 at 07:18:59PM +0200, Alex Lyakas wrote: > We have a commit_root_sem, which is a read-write semaphore that protects the > commit roots. > But it is also used to protect the list of caching block groups. > > As a result, while doing "slow" caching, the following issue is seen:

Re: [PATCH 4/5] btrfs: raid56: Don't keep rbio for later steal

2017-03-21 Thread Liu Bo
On Tue, Mar 21, 2017 at 10:23:56AM +0800, Qu Wenruo wrote: > > > At 03/21/2017 10:08 AM, Liu Bo wrote: > > On Tue, Mar 21, 2017 at 08:44:18AM +0800, Qu Wenruo wrote: > > > > > > > > > At 03/21/2017 04:23 AM, Liu Bo wrote: > > > > On

Re: [PATCH 4/5] btrfs: raid56: Don't keep rbio for later steal

2017-03-20 Thread Liu Bo
On Tue, Mar 21, 2017 at 08:44:18AM +0800, Qu Wenruo wrote: > > > At 03/21/2017 04:23 AM, Liu Bo wrote: > > On Mon, Mar 20, 2017 at 02:21:48PM +0800, Qu Wenruo wrote: > > > > > > > > > At 03/18/2017 10:03 AM, Liu Bo wrote: > > > > On

Re: [PATCH 6/7] btrfs: remove redundant parameter from reada_start_machine_dev

2017-03-20 Thread Liu Bo
On Wed, Mar 15, 2017 at 05:02:39PM +0100, David Sterba wrote: > We can read fs_info from dev. > Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/reada.c | 7 +++ > 1 file changed

Re: [PATCH 5/7] btrfs: remove redundant parameter from reada_find_zone

2017-03-20 Thread Liu Bo
On Wed, Mar 15, 2017 at 05:02:36PM +0100, David Sterba wrote: > We can read fs_info from dev. > Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/reada.c | 6 +++--- > 1 file changed

Re: [PATCH 7/7] btrfs: remove local blocksize variable in reada_find_extent

2017-03-20 Thread Liu Bo
On Wed, Mar 15, 2017 at 05:02:42PM +0100, David Sterba wrote: > The name is misleading and the local variable serves no purpose. Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/reada.c | 6

Re: [PATCH 4/7] btrfs: remove redundant parameter from btree_readahead_hook

2017-03-20 Thread Liu Bo
On Wed, Mar 15, 2017 at 05:02:33PM +0100, David Sterba wrote: > We can read fs_info from eb. Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/ctree.h | 3 +-- > fs/btrfs/disk-io.c | 4

Re: [PATCH 3/7] btrfs: preallocate radix tree node for global readahead tree

2017-03-20 Thread Liu Bo
ecause readahead is optional and not on any > critical writeout path. Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/disk-io.c | 2 +- > fs/btrfs/reada.c | 7 +++ > 2 files changed, 8

Re: [PATCH 2/7] btrfs: use simpler readahead zone lookups

2017-03-20 Thread Liu Bo
On Wed, Mar 15, 2017 at 05:02:26PM +0100, David Sterba wrote: > No point using radix_tree_gang_lookup if we're looking up just one slot. > Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Signed-off-by: David Sterba <dste...@suse.com> > ---

Re: [PATCH 1/7] btrfs: preallocate radix tree node for readahead

2017-03-20 Thread Liu Bo
as an allocation above anyway, but also > because readahead is optional and not on any critical writeout path. > Reviewed-by: Liu Bo <bo.li@oracle.com> Thanks, -liubo > Signed-off-by: David Sterba <dste...@suse.com> > --- > fs/btrfs/reada.c | 7 +++ > f

Re: [PATCH 4/5] btrfs: raid56: Don't keep rbio for later steal

2017-03-20 Thread Liu Bo
On Mon, Mar 20, 2017 at 02:21:48PM +0800, Qu Wenruo wrote: > > > At 03/18/2017 10:03 AM, Liu Bo wrote: > > On Fri, Mar 17, 2017 at 01:28:45PM +0800, Qu Wenruo wrote: > > > > > > > > > At 03/17/2017 12:44 PM, Liu Bo wrote: > > > > On

Re: [PATCH 5/5] btrfs: replace: Use ref counts to avoid destroying target device when canceled

2017-03-20 Thread Liu Bo
On Mon, Mar 20, 2017 at 02:30:48PM +0800, Qu Wenruo wrote: > > > At 03/18/2017 10:12 AM, Liu Bo wrote: > > On Fri, Feb 03, 2017 at 04:20:23PM +0800, Qu Wenruo wrote: > > > When dev-replace and scrub are run at the same time, dev-replace can be > > > canceled by s

Re: [PATCH 5/5] btrfs: replace: Use ref counts to avoid destroying target device when canceled

2017-03-17 Thread Liu Bo
On Fri, Feb 03, 2017 at 04:20:23PM +0800, Qu Wenruo wrote: > When dev-replace and scrub are run at the same time, dev-replace can be > canceled by scrub. It's quite common for btrfs/069. > > The backtrace would be like: > general protection fault: [#1] SMP > Workqueue: btrfs-endio-raid56

Re: [PATCH 4/5] btrfs: raid56: Don't keep rbio for later steal

2017-03-17 Thread Liu Bo
On Fri, Mar 17, 2017 at 01:28:45PM +0800, Qu Wenruo wrote: > > > At 03/17/2017 12:44 PM, Liu Bo wrote: > > On Fri, Feb 03, 2017 at 04:20:22PM +0800, Qu Wenruo wrote: > > > Before this patch, btrfs raid56 will keep raid56 rbio even all its IO is > > > do

Re: [PATCH 3/5] btrfs: raid56: Use correct stolen pages to calculate P/Q

2017-03-17 Thread Liu Bo
On Fri, Mar 17, 2017 at 02:31:08PM +0800, Qu Wenruo wrote: > > > At 03/16/2017 01:36 PM, Liu Bo wrote: > > On Fri, Feb 03, 2017 at 04:20:21PM +0800, Qu Wenruo wrote: > > > In the following situation, scrub will calculate wrong parity to > > > overwrite correct on

Re: [PATCH 4/5] btrfs: raid56: Don't keep rbio for later steal

2017-03-16 Thread Liu Bo
On Fri, Feb 03, 2017 at 04:20:22PM +0800, Qu Wenruo wrote: > Before this patch, btrfs raid56 will keep raid56 rbio even all its IO is > done. > This may save some time allocating rbio, but it can cause deadly > use-after-free bug, for the following case: > > Original fs: 4 devices RAID5 > >

Re: help!!! error when mount a btrfs file system

2017-03-16 Thread Liu Bo
On Thu, Mar 16, 2017 at 08:23:05PM +0800, 李云甫 wrote: > hi, buddy > >I have a file server with btrfs file system, it's work well for several > months. > > but after last system reboot, the /dev/sdb become not mountable. > > below is the details. is there any advise? > > > ##Version 

Re: [PATCH 3/5] btrfs: raid56: Use correct stolen pages to calculate P/Q

2017-03-15 Thread Liu Bo
On Fri, Feb 03, 2017 at 04:20:21PM +0800, Qu Wenruo wrote: > In the following situation, scrub will calculate wrong parity to > overwrite correct one: > > RAID5 full stripe: > > Before > | Dev 1 | Dev 2 | Dev 3 | > | Data stripe 1 | Data stripe 2 | Parity Stripe | >

Re: [PATCH 4/4] btrfs: add dummy callback for readpage_io_failed and drop checks

2017-03-15 Thread Liu Bo
On Mon, Feb 20, 2017 at 07:31:33PM +0100, David Sterba wrote: > Make extent_io_ops::readpage_io_failed_hook callback mandatory and > define a dummy function for btrfs_extent_io_ops. As the failed IO > callback is not performance critical, the branch vs extra trade off does > not hurt. > >

Re: [PATCH v2 0/7] cleanup __btrfs_map_block

2017-03-15 Thread Liu Bo
On Wed, Mar 15, 2017 at 02:07:53PM +0100, David Sterba wrote: > On Tue, Mar 14, 2017 at 01:33:54PM -0700, Liu Bo wrote: > > This is attempting to make __btrfs_map_block less scary :) > > > > The major changes are > > > > 1) split operations for discard out of __

Re: [PATCH v2 1/7] Btrfs: create a helper for getting chunk map

2017-03-14 Thread Liu Bo
On Wed, Mar 15, 2017 at 08:57:09AM +0800, Qu Wenruo wrote: > > > At 03/15/2017 04:33 AM, Liu Bo wrote: > > We have similar code here and there, this merges them into a helper. > > > > Signed-off-by: Liu Bo <bo.li@oracle.com> > > I really hate to dela

[PATCH v2 7/7] Btrfs: convert BUG_ON to WARN_ON

2017-03-14 Thread Liu Bo
These two BUG_ON()s would never be true, ensured by callers' logic. Reviewed-by: Qu Wenruo <quwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btr

[PATCH v2 3/7] Btrfs: introduce a function to get extra mirror from replace

2017-03-14 Thread Liu Bo
As the part of getting extra mirror in __btrfs_map_block is self-independent, this puts it into a separate function. Reviewed-by: Qu Wenruo <quwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 161 +---

[PATCH v2 6/7] Btrfs: helper for ops that requires full stripe

2017-03-14 Thread Liu Bo
This adds a helper to show directly whether ops require full stripe. Reviewed-by: Qu Wenruo <quwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/btrfs

[PATCH v2 4/7] Btrfs: handle operations for device replace separately

2017-03-14 Thread Liu Bo
Since this part is mostly self-independent, this moves it to a separate function. Reviewed-by: Qu Wenruo <quwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 179 + 1 file changed, 98 inser

[PATCH v2 1/7] Btrfs: create a helper for getting chunk map

2017-03-14 Thread Liu Bo
We have similar code here and there, this merges them into a helper. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: add @length to the error message in get_chunk_map. fs/btrfs/extent_io.c | 3 +- fs/btrfs/volumes.c | 163 +-- fs

[PATCH v2 2/7] Btrfs: separate DISCARD from __btrfs_map_block

2017-03-14 Thread Liu Bo
Since DISCARD is not as important as an operation like write, we don't copy it to target device during replace, and it makes __btrfs_map_block less complex. Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: - use the helper get_chunk_map to simplify code - use round_up instead of ALIGN

[PATCH v2 0/7] cleanup __btrfs_map_block

2017-03-14 Thread Liu Bo
since they're basically self-independant. v2: - add length to error handling output. - use helper get_chunk_map to simplify the code. Liu Bo (7): Btrfs: create a helper for getting chunk map Btrfs: separate DISCARD from __btrfs_map_block Btrfs: introduce a function to get extra mirror from

[PATCH v2 5/7] Btrfs: do not add extra mirror when dev_replace target dev is not available

2017-03-14 Thread Liu Bo
With this, we can avoid allocating memory for dev replace copies if the target dev is not available. Reviewed-by: Qu Wenruo <quwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/volumes.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) dif

[PATCH v2] Btrfs: add file item tracepoint

2017-03-10 Thread Liu Bo
less than the regular one. This adds four tracepoints: - btrfs_get_extent_show_fi_regular - btrfs_get_extent_show_fi_inline - btrfs_truncate_show_fi_regular - btrfs_truncate_show_fi_inline Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: follow th

Re: [PATCH] Btrfs: add file item tracepoint

2017-03-09 Thread Liu Bo
On Thu, Mar 09, 2017 at 01:52:22PM +0100, David Sterba wrote: > On Tue, Mar 07, 2017 at 08:49:42AM -0800, Liu Bo wrote: > > On Tue, Mar 07, 2017 at 04:48:24PM +0100, David Sterba wrote: > > > On Fri, Mar 03, 2017 at 06:41:27PM -0800, Liu Bo wrote: > > >

Re: [PATCH v7 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

2017-03-09 Thread Liu Bo
after increasing the iteration offset, so that > cleanup range won't cover any created ordered extent. > > |<-- delalloc range --->| > | OE 1 | OE 2 | ... | OE n | > |<--- --->|<-- cleanup range ->| >

Re: [PATCH v7 2/2] btrfs: Handle delalloc error correctly to avoid ordered extent hang

2017-03-09 Thread Liu Bo
handled like: > > |<-- delalloc range --->| > | OE 1 | OE 2 | ... | OE n | > |<>|< --->|<------ old error handler ->| > || || > || \_=> Cleaned up by cleanup_ordered_extents() > \_=> F

Re: assertion failed: last_size == new_size, file: fs/btrfs/inode.c

2017-03-09 Thread Liu Bo
On Thu, Mar 09, 2017 at 03:24:21PM +0100, David Sterba wrote: > On Thu, Mar 02, 2017 at 06:04:33PM -0800, Liu Bo wrote: > > On Thu, Mar 02, 2017 at 07:58:01AM -0800, Liu Bo wrote: > > > On Wed, Mar 01, 2017 at 03:03:19PM -0500, Dave Jones wrote: > > > > On Tue, Fe

Re: [PATCH v2] Btrfs: fix invalid attempt to free reserved space on failure to cow range

2017-03-08 Thread Liu Bo
On Tue, Mar 07, 2017 at 04:24:49AM +, fdman...@kernel.org wrote: > From: Filipe Manana > > When attempting to COW a file range (we are starting writeback and doing > COW), if we manage to reserve an extent for the range we will write into > but fail after reserving it and

Re: [PATCH v2] btrfs: fix a bogus warning when converting only data or metadata

2017-03-07 Thread Liu Bo
ek=4095 of=ra > dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb > mkfs.btrfs ra rb # defaults to -draid0 -mraid1 > losetup -f ra > losetup -f rb > mount /dev/loop0 /mnt/vol1 > btrfs balance start -dconvert=raid1 /mnt/vol1 > > > On Tue, Mar 07, 2017 at 12:34:07PM

Re: [PATCH v3] Btrfs: fix invalid attempt to free reserved space on failure to cow range

2017-03-07 Thread Liu Bo
R15: > 7f5b054be740 > [ 847.648601] ? trace_hardirqs_off_caller+0x3f/0xaa > [ 847.685787] ---[ end trace 2a4a3e15382508e8 ]--- > > So fix this by not attempting to decrement the data space info's > bytes_may_use counter if we already reserved the extent and an error >

Re: [PATCH v6 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

2017-03-07 Thread Liu Bo
On Wed, Mar 08, 2017 at 12:17:16AM +, Filipe Manana wrote: > On Tue, Mar 7, 2017 at 8:59 PM, Liu Bo <bo.li@oracle.com> wrote: > > On Tue, Mar 07, 2017 at 12:49:58PM -0800, Liu Bo wrote: > >> On Mon, Mar 06, 2017 at 10:55:46AM +0800, Qu Wenruo wrote:

Re: [PATCH] btrfs: fix hole read corruption for compressed inline extents

2017-03-07 Thread Liu Bo
006d 0001760 5f74 6f43 7400 435f 0053 5f74 7363 7400 0002000 435f 0056 5f74 6164 7400 645f 0062 5f74 (...) Regarding to this patch, - Although pg_offset is assumed to be zero, using (PAGE_SIZE - pg_offset) makes the code look saner, could you please add pg_offset to the check? - Could you please wr

Re: [PATCH v6 2/2] btrfs: Handle delalloc error correctly to avoid ordered extent hang

2017-03-07 Thread Liu Bo
btrfs_cleanup_ordered_extents(inode, start, end - start + 1); > return ret; > } > > @@ -8142,17 +8168,26 @@ static void btrfs_endio_direct_read(struct bio *bio) > bio_put(bio); > } > > -static void btrfs_endio_direct_write_update_ordered(struct

Re: [PATCH] btrfs: fix a bogus warning when converting only data or metadata

2017-03-07 Thread Liu Bo
On Tue, Mar 07, 2017 at 06:42:51AM +0100, Adam Borowski wrote: > If your filesystem has, eg, data:raid0 metadata:raid1, and you run "btrfs > balance -dconvert=raid1", the meta.target field will be uninitialized. > That's otherwise ok, as it's unused except for this warning. > > Thus, let's use

Re: [PATCH v6 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

2017-03-07 Thread Liu Bo
On Tue, Mar 07, 2017 at 12:49:58PM -0800, Liu Bo wrote: > On Mon, Mar 06, 2017 at 10:55:46AM +0800, Qu Wenruo wrote: > > [BUG] > > When btrfs_reloc_clone_csum() reports error, it can underflow metadata > > and leads to kernel assertion on outstanding extents in &

Re: [PATCH v6 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

2017-03-07 Thread Liu Bo
On Tue, Mar 07, 2017 at 06:32:23PM +0100, David Sterba wrote: > On Mon, Mar 06, 2017 at 11:19:32PM +, Filipe Manana wrote: > > On Mon, Mar 6, 2017 at 2:55 AM, Qu Wenruo wrote: > > > [BUG] > > > When btrfs_reloc_clone_csum() reports error, it can underflow metadata > >

Re: [PATCH v6 1/2] btrfs: Fix metadata underflow caused by btrfs_reloc_clone_csum error

2017-03-07 Thread Liu Bo
On Mon, Mar 06, 2017 at 10:55:46AM +0800, Qu Wenruo wrote: > [BUG] > When btrfs_reloc_clone_csum() reports error, it can underflow metadata > and leads to kernel assertion on outstanding extents in > run_delalloc_nocow() and cow_file_range(). > > BTRFS info (device vdb5): relocating block group

Re: [PATCH] Btrfs: fix regression in lock_delalloc_pages

2017-03-07 Thread Liu Bo
On Tue, Mar 07, 2017 at 01:54:31PM +0800, Qu Wenruo wrote: > > > At 03/07/2017 10:20 AM, Liu Bo wrote: > > The bug is a regression after commit > > (da2c7009f6ca "btrfs: teach __process_pages_contig about PAGE_LOCK > > operation") > > and commit >

Re: [PATCH] Btrfs: add file item tracepoint

2017-03-07 Thread Liu Bo
On Tue, Mar 07, 2017 at 04:48:24PM +0100, David Sterba wrote: > On Fri, Mar 03, 2017 at 06:41:27PM -0800, Liu Bo wrote: > > + TP_printk_btrfs( > > + "root %llu(%s) ino %llu sz 0x%llx disk_isz 0x%llx " > > + "file extent range [0x%llx 0x%l

Re: [PATCH 1/2] Btrfs: fix unexpected file hole after disk errors

2017-03-06 Thread Liu Bo
On Wed, Mar 01, 2017 at 10:44:53AM +0800, Qu Wenruo wrote: > > > At 03/01/2017 09:04 AM, Liu Bo wrote: > > Btrfs creates hole extents to cover any unwritten section right before > > doing buffer writes after commit 3ac0d7b96a26 ("btrfs: Change the expanding > >

[PATCH] Btrfs: fix regression in lock_delalloc_pages

2017-03-06 Thread Liu Bo
om> Reported-by: Dave Jones <da...@codemonkey.org.uk> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 28e8192..8df7974 100644 --- a/fs/bt

Re: assertion failed: page_ops & PAGE_LOCK

2017-03-06 Thread Liu Bo
On Sun, Mar 05, 2017 at 11:59:17AM -0500, Dave Jones wrote: > After commenting out the assertion that Liu bo pointed out was bogus, > my trinity runs last a little longer.. This is a new one I think.. > Could you please try this patch? Thanks, -liubo diff --git a/fs/btrfs/extent_

Re: [PATCH 2/2] Btrfs: remove start_pos

2017-03-06 Thread Liu Bo
On Wed, Mar 01, 2017 at 04:48:20PM +0800, Qu Wenruo wrote: > > > At 03/01/2017 09:04 AM, Liu Bo wrote: > > @pos, not aligned @start_pos, should be used to check whether the eof page > > needs to be marked as readonly, thus @start_pos can be removed. > > >

[PATCH v2] Btrfs: fix unexpected file hole after disk errors

2017-03-06 Thread Liu Bo
uwen...@cn.fujitsu.com> Signed-off-by: Liu Bo <bo.li@oracle.com> --- v2: update comments to be precise. fs/btrfs/file.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 520cb72..dcf0286 100644 --- a/fs/btrfs/file.c ++

[PATCH] Btrfs: update comments in cache_save_setup

2017-03-06 Thread Liu Bo
We also don't bother to flush free space cache while with free space tree. Cc: David Sterba <dste...@suse.cz> Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/

Re: assertion failed: page_ops & PAGE_LOCK

2017-03-06 Thread Liu Bo
On Sun, Mar 05, 2017 at 11:59:17AM -0500, Dave Jones wrote: > After commenting out the assertion that Liu bo pointed out was bogus, > my trinity runs last a little longer.. This is a new one I think.. I hit this once, haven't got enough info. to check what went wrong, but I'm w

Re: [PATCH 2/7] Btrfs: separate DISCARD from __btrfs_map_block

2017-03-06 Thread Liu Bo
On Mon, Feb 20, 2017 at 11:54:31AM +0800, Qu Wenruo wrote: > > > At 02/18/2017 09:28 AM, Liu Bo wrote: > > Since DISCARD is not as important as an operation like write, we don't > > copy it to target device during replace, and it makes __btrfs_map_block > > less comp

Re: [PATCH] btrfs: Change s_flags instead of returning -EBUSY

2017-03-06 Thread Liu Bo
n remount, we set > s_flags &= MS_RDONLY when we see a conflict in s_flags and passed parameter > flags and let mount continue as it is. This will allow the first mount attempt > to succeed, and we can get rid of the re-kern_mount() and remount sequence > altogether. Reviewed-by:

[PATCH] Btrfs: add file item tracepoint

2017-03-03 Thread Liu Bo
less than the regular one. This adds four tracepoints: - btrfs_get_extent_show_fi_regular - btrfs_get_extent_show_fi_inline - btrfs_truncate_show_fi_regular - btrfs_truncate_show_fi_inline Signed-off-by: Liu Bo <bo.li@oracle.com> --- fs/btrfs/inode.c | 15 + include

<    2   3   4   5   6   7   8   9   10   11   >