[PATCH] btrfs: Simplify offset calculation method for ctree.h

2009-12-17 Thread Zhaolei
Use simple struct operation instead of address calculation. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/ctree.h | 46 ++ 1 files changed, 14 insertions(+), 32 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index

Re: Re: [PATCH 09/18] btrfs: Fix return value of read_extent_buffer_pages() when lock page failed

2010-03-30 Thread Zhaolei
. Thanks Zhaolei Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/extent_io.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index bdfbfa6..3194c79 100644

Re: Re: [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages()

2010-03-30 Thread Zhaolei
, but with the existing code the calculation is only done when there is an IO error. We could use a check for num_copies == 0 before calling the calc function. -chris Hello, chris I'll modify this patch to read num_copies only in IO error. Thanks Zhaolei Signed-off-by: Zhao Lei zhao

Re: Re: [PATCH 01/18] btrfs: Remove u64 conversion for PAGE_CACHE_SIZE

2010-03-30 Thread Zhaolei
:(PAGE_CACHE_SIZE - 1); inode.c:~(PAGE_CACHE_SIZE - 1); inode.c:if ((end (PAGE_CACHE_SIZE - 1)) == 0) Thanks Zhaolei -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo

[PATCH v2] btrfs: Fix out-of-space bug

2015-02-07 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space 3: Delete above file 4: Wait about 100s to let chunk removed 5: goto 2 Script

[PATCH 2/2] btrfs: Set hole_size to free space in case of contains_pending_extent

2015-02-06 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space 3: Delete above file 4: Wait about 100s to let chunk removed 5: goto 2 Script

[PATCH 1/2] btrfs: Fix out-of-space bug caused by searching commit_root in find_free_dev_extent()

2015-02-06 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space 3: Delete above file 4: Wait about 100s to let chunk removed 5: goto 2 Script

[PATCH 0/2] btrfs: Fix out-of-space bug

2015-02-06 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space 3: Delete above file 4: Wait about 100s to let chunk removed 5: goto 2 Script

[PATCH] btrfs: cleanup: remove no-used alloc_chunk in btrfs_check_data_free_space()

2015-02-08 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com int alloc_chunk is never used in this function, remove it. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c

[PATCH] btrfs: cleanup: remove no-used alloc_chunk in btrfs_check_data_free_space()

2015-02-08 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com int alloc_chunk is never used in this function, remove it. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c

[PATCH 11/15] Btrfs: Combine per-page recover in dev-replace and scrub

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com The code are similar, combine them to make code clean and easy to maintenance. Some lost condition are also completed with benefit of this combination. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 08/15] Btrfs: btrfs_rm_dev_replace_blocked(): Use wait_event()

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index

[PATCH 15/15] Rename all ref_count to refs in struct

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com refs is better than ref_count to record a struct's ref count. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Suggested-by: David Sterba dste...@suse.cz --- fs/btrfs/scrub.c | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-)

[PATCH 05/15] Btrfs: Fix a jump typo of nodatasum_case to avoid wrong WARN_ON()

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com if (sctx-is_dev_replace !is_metadata !have_csum) { ... goto nodatasum_case; } ... nodatasum_case: WARN_ON(sctx-is_dev_replace); In above code, nodatasum_case marker should be moved after WARN_ON(). Signed-off-by: Zhao Lei

[PATCH 06/15] Btrfs: Remove noneed force_write in scrub_write_block_to_dev_replace

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is always 1 in this place, because !1 case was already jumped out in previous code. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/scrub.c | 19 +++ 1 file changed, 7

[PATCH 13/15] Btrfs: Include map_type in raid_bio

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Corrent code use many kinds of clever way to determine operation target's raid type, as: raid_map != NULL or raid_map[MAX_NR] == RAID[56]_Q_STRIPE To make code easy to maintenance, this patch put raid type into bbio, and we can always get raid type

[PATCH 14/15] Btrfs: Introduce BTRFS_BLOCK_GROUP_RAID56_MASK to check raid56 simply

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com So we can check raid56 with: (map-type BTRFS_BLOCK_GROUP_RAID56_MASK) instead of long: (map-type (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH v3 00/15] Btrfs: Cleanup for raid56 scrub

2015-01-19 Thread Zhaolei
Sterba dste...@suse.cz 3: bbio-ref_count - bbio-refs Suggested by: David Sterba dste...@suse.cz 4: all ref_count - refs in other code(new PATCH 16/16) Suggested by: David Sterba dste...@suse.cz Many thanks for above people for review these patch. Thanks Zhaolei Zhao Lei (15): Btrfs: fix a out

[PATCH 12/15] Btrfs: Simplify scrub_setup_recheck_block()'s argument

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com scrub_setup_recheck_block() have many arguments but most of them can be get from one of them, we can remove them to make code clean. Some other cleanup for that function also included in this patch. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com

[PATCH 01/15] Btrfs: fix a out-of-bound access of raid_map

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com We add the number of stripes on target devices into bbio-num_stripes if we are under device replacement, and we just sort the raid_map of those stripes that not on the target devices, so if when we need real raid_map, we need skip the stripes on the target

[PATCH 03/15] Btrfs: Make raid_map array be inlined in btrfs_bio structure

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can make code more simple and clear, we need not care about free bbio and raid_map together. Signed-off-by: Miao Xie mi...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/raid56.c | 77

[PATCH 04/15] Btrfs: add ref_count and free function for btrfs_bio

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: ref_count is simple than current RBIO_HOLD_BBIO_MAP_BIT flag to keep btrfs_bio's memory in raid56 recovery implement. 2: free function for bbio will make code clean and flexible, plus forced data type checking in compile. Changelog v1-v2: Rename

[PATCH 02/15] Btrfs: sort raid_map before adding tgtdev stripes

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can avoid complex calculation of real stripes in sort, moreover, we can clean up code of sorting tgtdev_map because it will be in order initially. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 04/16] Btrfs: add ref_count and free function for btrfs_bio

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: ref_count is simple than current RBIO_HOLD_BBIO_MAP_BIT flag to keep btrfs_bio's memory in raid56 recovery implement. 2: free function for bbio will make code clean and flexible, plus forced data type checking in compile. Changelog v1-v2: Rename

[PATCH 02/16] Btrfs: sort raid_map before adding tgtdev stripes

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can avoid complex calculation of real stripes in sort, moreover, we can clean up code of sorting tgtdev_map because it will be in order initially. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 10/16] Btrfs: Avoid trustless page-level-repair in dev-replace

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Current code of page level repair for dev-replace can only support io-error, we can't use it in checksum-fail case. We can skip this kind of repair in dev-replace just as we in scrub. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie

[PATCH 05/16] Btrfs: Fix a jump typo of nodatasum_case to avoid wrong WARN_ON()

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com if (sctx-is_dev_replace !is_metadata !have_csum) { ... goto nodatasum_case; } ... nodatasum_case: WARN_ON(sctx-is_dev_replace); In above code, nodatasum_case marker should be moved after WARN_ON(). Signed-off-by: Zhao Lei

[PATCH 06/16] Btrfs: Remove noneed force_write in scrub_write_block_to_dev_replace

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is always 1 in this place, because !1 case was already jumped out in previous code. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/scrub.c | 19 +++ 1 file changed, 7

[PATCH 08/16] Btrfs: btrfs_rm_dev_replace_blocked(): Use wait_event()

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index

[PATCH v2 00/16] Btrfs: Cleanup for raid56 scrub

2015-01-19 Thread Zhaolei
) Suggested by: David Sterba dste...@suse.cz Many thanks for above people for review these patch. Thanks Zhaolei Zhao Lei (16): Btrfs: fix a out-of-bound access of raid_map Btrfs: sort raid_map before adding tgtdev stripes Btrfs: Make raid_map array be inlined in btrfs_bio structure Btrfs

[PATCH 07/16] Btrfs: Cleanup btrfs_bio_counter_inc_blocked()

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove no-need DEFINE_WAIT(wait) 2: Add likely() for BTRFS_FS_STATE_DEV_REPLACING condition 3: Use while loop instead of goto Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 12

[PATCH 14/16] Btrfs: Include map_type in raid_bio

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Corrent code use many kinds of clever way to determine operation target's raid type, as: raid_map != NULL or raid_map[MAX_NR] == RAID[56]_Q_STRIPE To make code easy to maintenance, this patch put raid type into bbio, and we can always get raid type

[PATCH 01/16] Btrfs: fix a out-of-bound access of raid_map

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com We add the number of stripes on target devices into bbio-num_stripes if we are under device replacement, and we just sort the raid_map of those stripes that not on the target devices, so if when we need real raid_map, we need skip the stripes on the target

[PATCH 13/16] Btrfs: Simplify scrub_setup_recheck_block()'s argument

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com scrub_setup_recheck_block() have many arguments but most of them can be get from one of them, we can remove them to make code clean. Some other cleanup for that function also included in this patch. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com

[PATCH 03/16] Btrfs: Make raid_map array be inlined in btrfs_bio structure

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can make code more simple and clear, we need not care about free bbio and raid_map together. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/raid56.c | 77

[PATCH 12/16] Btrfs: Combine per-page recover in dev-replace and scrub

2015-01-19 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com The code are similar, combine them to make code clean and easy to maintenance. Some lost condition are also completed with benefit of this combination. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH v2 1/3] btrfs: cleanup: remove unuesd DEDINE_WAIT() in btrfs_bio_counter_inc_blocked()

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove unused DEFINE_WAIT(wait) 2: Add likely() for BTRFS_FS_STATE_DEV_REPLACING condition 3: Use a loop instead of goto Changelog v1-v2: s/look/loop in description. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 12

[PATCH 01/10] btrfs: Adjust commit-transaction condition to avoid NO_SPACE more

2015-02-17 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com If we have any chance to make a successful write, we should not give up. This patch adjust commit-transaction condition from: pinned = wanted to left + pinned = wanted Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 3 ++- 1

[PATCH] btrfs: Adjust commit-transaction condition to avoid NO_SPACE more

2015-02-17 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com If we have any chance to make a successful write, we should not give up. This patch adjust commit-transaction condition from: pinned = wanted to left + pinned = wanted Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 3 ++- 1

[PATCH 06/15] Btrfs: Remove noneed force_write in scrub_write_block_to_dev_replace

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is always 1 in this place, because !1 case was already jumped out in previous code. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/scrub.c | 19 +++ 1 file changed, 7

[PATCH 05/15] Btrfs: Fix a jump typo of nodatasum_case to avoid wrong WARN_ON()

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com if (sctx-is_dev_replace !is_metadata !have_csum) { ... goto nodatasum_case; } ... nodatasum_case: WARN_ON(sctx-is_dev_replace); In above code, nodatasum_case marker should be moved after WARN_ON(). Signed-off-by: Zhao Lei

[PATCH 04/15] Btrfs: add ref_count and free function for btrfs_bio

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: ref_count is simple than current RBIO_HOLD_BBIO_MAP_BIT flag to keep btrfs_bio's memory in raid56 recovery implement. 2: free function for bbio will make code clean and flexible, plus forced data type checking in compile. Signed-off-by: Zhao Lei

[PATCH 03/15] Btrfs: Make raid_map array be inlined in btrfs_bio structure

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can make code more simple and clear, we need not care about free bbio and raid_map together. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/raid56.c | 77

[PATCH 09/15] Btrfs: Break loop when reach BTRFS_MAX_MIRRORS in scrub_setup_recheck_block()

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Use break instead of useless loop should be more suitable in this case. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH 11/15] Btrfs: Separate finding-right-mirror and writing-to-target's process in scrub_handle_errored_block()

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com In corrent code, code of finding-right-mirror and writing-to-target are mixed in logic, if we find a right mirror but failed in writing to target, it will treat as hadn't found right block, and fill the target with sblock_bad. Actually, failed in writing to

[PATCH 10/15] Btrfs: Avoid trustless page-level-repair in dev-replace

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Current code of page level repair for dev-replace can only support io-error, we can't use it in checksum-fail case. We can skip this kind of repair in dev-replace just as we in scrub. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie

[PATCH 02/15] Btrfs: sort raid_map before adding tgtdev stripes

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It can avoid complex calculation of real stripes in sort, moreover, we can clean up code of sorting tgtdev_map because it will be in order initially. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 15/15] Btrfs: Introduce BTRFS_BLOCK_GROUP_RAID56_MASK to check raid56 simply

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com So we can check raid56 with: (map-type BTRFS_BLOCK_GROUP_RAID56_MASK) instead of long: (map-type (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 12/15] Btrfs: Combine per-page recover in dev-replace and scrub

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com The code are similar, combine them to make code clean and easy to maintenance. Some lost condition are also completed with benefit of this combination. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com ---

[PATCH 13/15] Btrfs: Simplify scrub_setup_recheck_block()'s argument

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com scrub_setup_recheck_block() have many arguments but most of them can be get from one of them, we can remove them to make code clean. Some other cleanup for that function also included in this patch. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com

[PATCH 14/15] Btrfs: Include map_type in raid_bio

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Corrent code use many kinds of clever way to determine operation target's raid type, as: raid_map != NULL or raid_map[MAX_NR] == RAID[56]_Q_STRIPE To make code easy to maintenance, this patch put raid type into bbio, and we can always get raid type

[PATCH 01/15] Btrfs: fix a out-of-bound access of raid_map

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com We add the number of stripes on target devices into bbio-num_stripes if we are under device replacement, and we just sort the raid_map of those stripes that not on the target devices, so if when we need real raid_map, we need skip the stripes on the target

[PATCH 00/15] Btrfs: Cleanup for raid56 scrib

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Hi, everyone, These are cleanup patchs for raid56's scrib functions, it is based on review for new-developed raid56's scrub code. Some small typo-fix and cleanup for other functions are also included in this patchset. Thanks Zhaolei Zhao Lei (15): Btrfs

[PATCH 08/15] Btrfs: btrfs_rm_dev_replace_blocked(): Use wait_event()

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index

[PATCH 07/15] Btrfs: Cleanup btrfs_bio_counter_inc_blocked()

2015-01-13 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove no-need DEFINE_WAIT(wait) 2: Add likely() for BTRFS_FS_STATE_DEV_REPLACING condition 3: Use while loop instead of goto Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Miao Xie mi...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 12

[PATCH] btrfs: fix condition of commit transaction

2015-02-14 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Old code bypass commit transaction when we don't have enough pinned space, but another case is there exist freed bgs in current transction, it have possibility to make alloc_chunk success. This patch modify the condition to: if (have_free_bg ||

[PATCH] btrfs: cleanup unused alloc_chunk varible

2015-02-14 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Remove int alloc_chunk in btrfs_check_data_free_space() for not necessary. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c

[PATCH] btrfs: Fix out-of-space bug

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times, and we can't write to filesystem until mount it again. Steps to reproduce: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space

[PATCH v3] btrfs: Fix out-of-space bug

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times, and we can't write to filesystem until mount it again. Steps to reproduce: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space

[PATCH] btrfs: remove unused chunk_tree argument in several functions

2015-02-09 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com There functions include unused chunk_tree argument from the begining, it is time to remove them and clean up relative code to prepare value of this argument in caller. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/volumes.c | 20

[PATCH v4] btrfs: Fix out-of-space bug

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Btrfs will report NO_SPACE when we create and remove files for several times, and we can't write to filesystem until mount it again. Steps to reproduce: 1: Create a single-dev btrfs fs with default option 2: Write a file into it to take up most fs space

[PATCH 2/3] btrfs: cleanup: use wait_event() for btrfs_rm_dev_replace_blocked()

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com wait_event() is just suit for these hand-made code. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c

[PATCH 1/3] btrfs: cleanup: remove unuesd DEDINE_WAIT() in btrfs_bio_counter_inc_blocked()

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove unused DEFINE_WAIT(wait) 2: Add likely() for BTRFS_FS_STATE_DEV_REPLACING condition 3: Use a look instead of goto Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 12 ++-- 1 file changed, 6 insertions(+), 6

[PATCH 3/3] btrfs: cleanup: use for() loop in btrfs_map_bio()

2015-02-11 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com for() is obviously better in these code block, and remove noused init-value to reduce about 6 bytes binary size. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/volumes.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git

[PATCH 3/3] btrfs: cleanup: use for() loop in btrfs_map_bio()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com for() is obviously better in these code block, and remove noused init-value to reduce about 6 bytes binary size. Reviewed-by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/volumes.c | 9 +++-- 1 file changed, 3

[PATCH v2 1/3] btrfs: cleanup: remove unuesd DEDINE_WAIT() in btrfs_bio_counter_inc_blocked()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove unused DEFINE_WAIT(wait) 2: Use a look instead of goto Changelog v1-v2: Remove likely() in v1 because it is not a performance sensitive path, suggesed by: David Sterba dste...@suse.cz Acked-by: David Sterba dste...@suse.cz Signed-off-by: Zhao

[PATCH 2/3] btrfs: cleanup: use wait_event() for btrfs_rm_dev_replace_blocked()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com wait_event() is just suit for these hand-made code. Reviewed-by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git

[PATCH 3/3] btrfs: cleanup: use for() loop in btrfs_map_bio()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com for() is obviously better in these code block, and remove noused init-value to reduce about 6 bytes binary size. Reviewed-by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/volumes.c | 9 +++-- 1 file changed, 3

[PATCH v3 1/3] btrfs: cleanup: remove unuesd DEDINE_WAIT() in btrfs_bio_counter_inc_blocked()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com 1: Remove unused DEFINE_WAIT(wait) 2: Use a loop instead of goto Changelog v2-v3: s/look/loop in description. Changelog v1-v2: Remove likely() in v1 because it is not a performance sensitive path, suggesed by: David Sterba dste...@suse.cz Acked-by:

[PATCH 2/3] btrfs: cleanup: use wait_event() for btrfs_rm_dev_replace_blocked()

2015-02-15 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com wait_event() is just suit for these hand-made code. Reviewed-by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/dev-replace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git

[PATCH] btrfs: Fix tail space processing in find_free_dev_extent()

2015-02-16 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is another reason of NO_SPACE bug. When we found enough free space in loop and saved them to max_hole_start/size before, and tail space contains pending extent, origional innocent max_hole_start/size data are reset in retry. As a result,

[PATCH] btrfs: wait for delayed iputs on no space

2015-03-27 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com btrfs will report no_space when we run following write and delete file loop: # FILE_SIZE_M=[ 75% of fs space ] # DEV=[ some dev ] # MNT=[ some dir ] # # mkfs.btrfs -f $DEV # mount -o nodatacow $DEV $MNT # for ((i = 0; i 100; i++)); do dd if=/dev/zero

[PATCH] btrfs: wait for delayed iputs on no space

2015-03-27 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com This is another fix of no_space case. All patchs for fix no_space bug are available at fix_no_space branch on: git://github.com/zhaoleidd/btrfs Any suggestions are welcome. Zhao Lei (1): btrfs: wait for delayed iputs on no space

[PATCH] btrfs: Support busy loop of write and delete

2015-03-02 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Reproduce: while true; do dd if=/dev/zero of=/mnt/btrfs/file count=[75% fs_size] rm /mnt/btrfs/file done Then we can see above loop failed on NO_SPACE. It it long-term problem since very beginning, because delayed-iput after rm are not run. We

[PATCH 6/6] btrfs: Remove unused err = 0 line for raid_rmw_end_io()

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/raid56.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 2285e78..c087870 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1464,7 +1464,6 @@

[PATCH 1/6] btrfs: Fix calculation of rbio-dbitmap's size calculation

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Current code is trying to calculate rbio-dbitmap's size to make it align to sizeof(long), but implement haven't achived this object, it is align to sizeof(char) instead. This patch fixed above calculation, and use sizeof(long) instead of fixed 8 to increate

[PATCH 4/6] btrfs: Clear PageUptodate bit in alloc_rbio_parity_pages()

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/raid56.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 0d902ac..0a40d07 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1049,6 +1049,7 @@

[PATCH 3/6] btrfs: use rbio-nr_pages to reduce calculation

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com We can use rbio-stripe_npages to reduce unnecessary calculation in many code place. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/raid56.c | 19 +++ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git

[PATCH 2/6] btrfs: Use unified stripe_page's index calculation

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com We are using different index calculation method for stripe_page in current code: 1: (rbio-stripe_len / PAGE_CACHE_SIZE) * stripe_index + page_index 2: DIV_ROUND_UP(rbio-stripe_len, PAGE_CACHE_SIZE) * stripe_index + page_index 3: DIV_ROUND_UP(rbio-stripe_len *

[PATCH 5/6] btrfs: Use raid_write_end_io for scrub

2015-03-04 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com No need to create additional end_io function for scrub, it can use existing raid_write_end_io() instead. This patch also fixed some wrong comments. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/raid56.c | 36

[PATCH 3/3] btrfs: Remove BUG_ON() when failed searching block_group_cache in unpin_extent_range()

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Above BUG_ON() was triggered only one time in my test, but hadn't happened again in same env. The reason maybe: A block group which include pinned space was removed before unpin_extent_range(), and no other block_group_cache after start pos, so the code

[PATCH 1/3] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Bug1: space_info-bytes_readonly was set to very large(negative) value in btrfs_remove_block_group(). Reason: Current code set block_group_cache-pinned = 0 in btrfs_delete_unused_bgs(), but above space was not counted to space_info-bytes_readonly.

[PATCH 2/3] btrfs: add WARN_ON() to check is space_info op current

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com space_info's value calculation is some complex and easy to cause bug, add WARN_ON() to help debug. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/extent-tree.c

[PATCH 0/1] btrfs: Fix NO_SPACE bug caused by delayed-iput

2015-02-25 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is the last patch to fix following write fail case: while true; do write a file to 75% fs size delete above file sync or sleep done Above issue is caused by several reason, and fixed in following patch respectively: Btrfs: fix

[PATCH 1/1] btrfs: Fix NO_SPACE bug caused by delayed-iput

2015-02-25 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Steps to reproduce: while true; do dd if=/dev/zero of=/btrfs_dir/file count=[fs_size * 75%] rm /btrfs_dir/file sync done And we'll see dd failed because btrfs return NO_SPACE. Reason: Normally, btrfs_commit_transaction() call

[PATCH v3 0/2] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-02-25 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Changelog v1-v2: [PATCH 2/2] btrfs: add WARN_ON() to check is space_info op current Put WARN_ON()s under the ENOSPC_DEBUG mount option. Suggested by: David Sterba dste...@suse.cz Changelog v1-v2: drop patch of: Remove BUG_ON() when failed searching

[PATCH v3 1/2] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-02-25 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Bug1: space_info-bytes_readonly was set to very large(negative) value in btrfs_remove_block_group(). Reason: Current code set block_group_cache-pinned = 0 in btrfs_delete_unused_bgs(), but above space was not counted to space_info-bytes_readonly.

[PATCH v3 2/2] btrfs: add WARN_ON() to check is space_info op current

2015-02-25 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com space_info's value calculation is some complex and easy to cause bug, add WARN_ON() to help debug. Changelog v1-v2: Put WARN_ON()s under the ENOSPC_DEBUG mount option. Suggested by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei

[PATCH 2/2] btrfs: add WARN_ON() to check is space_info op current

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com space_info's value calculation is some complex and easy to cause bug, add WARN_ON() to help debug. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/extent-tree.c

[PATCH 1/2] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Bug1: space_info-bytes_readonly was set to very large(negative) value in btrfs_remove_block_group(). Reason: Current code set block_group_cache-pinned = 0 in btrfs_delete_unused_bgs(), but above space was not counted to space_info-bytes_readonly.

[PATCH v2 0/2] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-02-24 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Changelog v1-v2: drop patch of: Remove BUG_ON() when failed searching block_group_cache in unpin_extent_range() because Filipe Manana fdman...@suse.com already fixed it with better way. Zhao Lei (2): btrfs: Set relative data on clear

[PATCH 3/9] btrfs: Adjust commit-transaction condition to avoid NO_SPACE more

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com If we have any chance to make a successful write, we should not give up. This patch adjust commit-transaction condition from: pinned = wanted to left + pinned = wanted Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 3 ++- 1

[PATCH 5/9] btrfs: add WARN_ON() to check is space_info op current

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com space_info's value calculation is some complex and easy to cause bug, add WARN_ON() to help debug. Changelog v1-v2: Put WARN_ON()s under the ENOSPC_DEBUG mount option. Suggested by: David Sterba dste...@suse.cz Signed-off-by: Zhao Lei

[PATCH 7/9] btrfs: Support busy loop of write and delete

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Reproduce: while true; do dd if=/dev/zero of=/mnt/btrfs/file count=[75% fs_size] rm /mnt/btrfs/file done Then we can see above loop failed on NO_SPACE. It it long-term problem since very beginning, because delayed-iput after rm are not run. We

[PATCH 4/9] btrfs: Set relative data on clear btrfs_block_group_cache-pinned

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Bug1: space_info-bytes_readonly was set to very large(negative) value in btrfs_remove_block_group(). Reason: Current code set block_group_cache-pinned = 0 in btrfs_delete_unused_bgs(), but above space was not counted to space_info-bytes_readonly.

[PATCH 1/9] btrfs: fix condition of commit transaction

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Old code bypass commit transaction when we don't have enough pinned space, but another case is there exist freed bgs in current transction, it have possibility to make alloc_chunk success. This patch modify the condition to: if (have_free_bg ||

[PATCH 9/9] btrfs: cleanup unused alloc_chunk varible

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Remove int alloc_chunk in btrfs_check_data_free_space() for not necessary. Signed-off-by: Zhao Lei zhao...@cn.fujitsu.com --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c

[PATCH 8/9] btrfs: wait for delayed iputs on no space

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com btrfs will report no_space when we run following write and delete file loop: # FILE_SIZE_M=[ 75% of fs space ] # DEV=[ some dev ] # MNT=[ some dir ] # # mkfs.btrfs -f $DEV # mount -o nodatacow $DEV $MNT # for ((i = 0; i 100; i++)); do dd if=/dev/zero

[PATCH 2/9] btrfs: Fix tail space processing in find_free_dev_extent()

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com It is another reason for NO_SPACE case. When we found enough free space in loop and saved them to max_hole_start/size before, and tail space contains pending extent, origional innocent max_hole_start/size are reset in retry. As a result,

[PATCH 6/9] btrfs: Fix NO_SPACE bug caused by delayed-iput

2015-04-03 Thread Zhaolei
From: Zhao Lei zhao...@cn.fujitsu.com Steps to reproduce: while true; do dd if=/dev/zero of=/btrfs_dir/file count=[fs_size * 75%] rm /btrfs_dir/file sync done And we'll see dd failed because btrfs return NO_SPACE. Reason: Normally, btrfs_commit_transaction() call

  1   2   >