[PATCH v6 04/15] btrfs-progs: scrub: Introduce structures to support offline scrub for RAID56

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introuduce new local structures, scrub_full_stripe and scrub_stripe, for incoming offline RAID56 scrub support. For pure stripe/mirror based profiles, like raid0/1/10/dup/single, we will follow the original bytenr and mirror number based iteration, so they don't need any extra st

[PATCH v6 06/15] btrfs-progs: scrub: Introduce functions to scrub mirror based data blocks

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, check/recover_data_mirror(), to check and recover mirror based data blocks. Unlike tree block, data blocks must be recovered sector by sector, so we introduced corrupted_bitmap for check and recover. Signed-off-by: Qu Wenruo Signed-off-by: Su Yue Signed

[PATCH v6 14/15] btrfs-progs: scrub: Introduce function to check a whole block group

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, scrub_one_block_group(), to scrub a block group. For Single/DUP/RAID0/RAID1/RAID10, we use old mirror number based map_block, and check extent by extent. For parity based profile (RAID5/6), we use new map_block_v2() and check full stripe by full stripe.

[PATCH v6 15/15] btrfs-progs: scrub: Introduce offline scrub function

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Now, btrfs-progs has a kernel scrub equivalent. A new option, --offline is added to "btrfs scrub start". If --offline is given, btrfs scrub will just act like kernel scrub, to check every copy of extent and do a report on corrupted data and if it's recoverable. The advantage com

[PATCH v6 11/15] btrfs-progs: scrub: Introduce function to recover data parity

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce function, recover_from_parities(), to recover data stripes. It just wraps raid56_recov() with extra check functions to scrub_full_stripe structure. Signed-off-by: Qu Wenruo --- scrub.c | 51 +++ 1 file changed, 51 inser

[PATCH v6 12/15] btrfs-progs: scrub: Introduce helper to write a full stripe

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a internal helper, write_full_stripe() to calculate P/Q and write the whole full stripe. This is useful to recover RAID56 stripes. Signed-off-by: Qu Wenruo --- scrub.c | 44 1 file changed, 44 insertions(+) diff --git a/s

[PATCH v6 00/15] Btrfs-progs offline scrub

2017-07-19 Thread Gu Jinxiang
For any one who wants to try it, it can be get from my repo: https://github.com/gujx2017/btrfs-progs/tree/offline_scrub In this v6, fix for make error reported by Marco Lorenzo Crociani. Several reports on kernel scrub screwing up good data stripes are in ML for sometime. And since kernel scrub

[PATCH v6 08/15] btrfs-progs: scrub: Introduce function to scrub one data stripe

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, scrub_one_data_stripe(), to check all data and tree blocks inside the data stripe. This function will not try to recovery any error, but only check if any data/tree blocks has mismatch csum. If data missing csum, which is completely valid for case like no

[PATCH v6 09/15] btrfs-progs: scrub: Introduce function to verify parities

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, verify_parities(), to check whether parities match with full stripe, whose data stripes match with their csum. Caller should fill the scrub_full_stripe structure properly before calling this function. Signed-off-by: Qu Wenruo Signed-off-by: Gu Jinxiang

[PATCH v6 10/15] btrfs-progs: extent-tree: Introduce function to check if there is any extent in given range.

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, btrfs_check_extent_exists(), to check if there is any extent in the range specified by user. The parameter can be a large range, and if any extent exists in the range, it will return >0 (in fact it will return 1). Or return 0 if no extent is found. Sign

[PATCH v6 02/15] btrfs-progs: Allow __btrfs_map_block_v2 to remove unrelated stripes

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo For READ, caller normally hopes to get what they request, other than full stripe map. In this case, we should remove unrelated stripe map, just like the following case: 32K 96K |<-request range->| 0 64k 1

[PATCH v6 13/15] btrfs-progs: scrub: Introduce a function to scrub one full stripe

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, scrub_one_full_stripe(), to check a full stripe. It handles the full stripe scrub in the following steps: 0) Check if we need to check full stripe If full stripe contains no extent, why waste our CPU and IO? 1) Read out full stripe Then we know ho

[PATCH v6 07/15] btrfs-progs: scrub: Introduce function to scrub one mirror-based extent

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, scrub_one_extent(), as a wrapper to check one mirror-based extent. It will accept a btrfs_path parameter @path, which must point to a META/EXTENT_ITEM. And @start, @len, which must be a subset of META/EXTENT_ITEM. Signed-off-by: Qu Wenruo Signed-off-by

[PATCH v6 01/15] btrfs-progs: Introduce new btrfs_map_block function which returns more unified result.

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, __btrfs_map_block_v2(). Unlike old btrfs_map_block(), which needs different parameter to handle different RAID profile, this new function uses unified btrfs_map_block structure to handle all RAID profile in a more meaningful method: Return physical addr

[PATCH v6 05/15] btrfs-progs: scrub: Introduce functions to scrub mirror based tree block

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce new functions, check/recover_tree_mirror(), to check and recover mirror-based tree blocks (Single/DUP/RAID0/1/10). check_tree_mirror() can also be used on in-memory tree blocks using @data parameter. This is very handy for RAID5/6 case, either checking the data stripe t

[PATCH v6 03/15] btrfs-progs: csum: Introduce function to read out data csums

2017-07-19 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function: btrfs_read_data_csums(), to read out csums for sectors in range. This is quite useful for read out data csum so we don't need to do it using open code. Signed-off-by: Qu Wenruo Signed-off-by: Su Yue Signed-off-by: Gu Jinxiang --- Makefile | 2

[PATCH] btrfs-progs: Specify C standard to gnu90 explicitly

2017-07-19 Thread Qu Wenruo
Different C compilers have different default language standard. This sometimes causes problem on different system. For distribution like CentOS/RHEL7, its gcc is still 4.8 and will report error for c90 style declaration, while most developers are using newer gcc which will just ignore it. This mak

Re: [PATCH 00/15] Btrfs-progs offline scrub

2017-07-19 Thread Qu Wenruo
On 2017年07月20日 00:45, Marco Lorenzo Crociani wrote: On 18/07/2017 08:33, Gu Jinxiang wrote: For any one who wants to try it, it can be get from my repo: https://github.com/gujx2017/btrfs-progs/tree/offline_scrub Hi, I'm getting this error during make: [CC] csum.o csum.c: In functi

[PATCH] btrfs: fix lockup in find_free_extent with read-only block groups

2017-07-19 Thread Jeff Mahoney
If we have a block group that is all of the following: 1) uncached in memory 2) is read-only 3) has a disk cache state that indicates we need to recreate the cache AND the file system has enough free space fragmentation such that the request for an extent of a given size can't be honored; AND hav

Re: [PATCH] btrfs: make use of inode_need_compress()

2017-07-19 Thread Anand Jain
On 07/18/2017 11:01 PM, David Sterba wrote: On Tue, Jul 18, 2017 at 05:37:47PM +0800, Anand Jain wrote: Its better to have the policy enforcement going through a function, so that we have better control and visibility of the decision logic. Signed-off-by: Anand Jain --- fs/btrfs/inode.c |

Re: [bug report] btrfs: get fs_info from eb in btrfs_print_leaf, remove argument

2017-07-19 Thread David Sterba
On Wed, Jul 19, 2017 at 04:13:07PM +0300, Dan Carpenter wrote: > Hello David Sterba, > > This is a semi-automatic email about new static checker warnings. > > The patch c042dd070450: "btrfs: get fs_info from eb in > btrfs_print_leaf, remove argument" from Jun 29, 2017, leads to the > following Sm

[PATCH] btrfs: account that we're waiting for IO in scrub_submit_raid56_bio_wait

2017-07-19 Thread David Sterba
Correctly account for IO when waiting for a submitted bio in scrub. This only for the accounting purposes and should not change other behaviour. Signed-off-by: David Sterba --- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.

[PATCH] btrfs: account that we're waiting for DIO read

2017-07-19 Thread David Sterba
Correctly account for IO when waiting for a submitted DIO read, the case when we're retrying. This only for the accounting purposes and should not change other behaviour. Signed-off-by: David Sterba --- fs/btrfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/

Re: [PATCH 00/15] Btrfs-progs offline scrub

2017-07-19 Thread Marco Lorenzo Crociani
On 18/07/2017 08:33, Gu Jinxiang wrote: For any one who wants to try it, it can be get from my repo: https://github.com/gujx2017/btrfs-progs/tree/offline_scrub Hi, I'm getting this error during make: [CC] csum.o csum.c: In function ‘btrfs_read_data_csums’: csum.c:119:3: error: ‘for’ l

Re: [PATCH] Btrfs: fix dir item validation when replaying xattr deletes

2017-07-19 Thread David Sterba
On Tue, Jul 18, 2017 at 08:34:02PM +0100, fdman...@kernel.org wrote: > From: Filipe Manana > > We were passing an incorrect slot number to the function that validates > directory items when we are replaying xattr deletes from a log tree. The > correct slot is stored at variable 'i' and not at 'pa

[PATCH] Btrfs: fix dir item validation when replaying xattr deletes

2017-07-19 Thread fdmanana
From: Filipe Manana We were passing an incorrect slot number to the function that validates directory items when we are replaying xattr deletes from a log tree. The correct slot is stored at variable 'i' and not at 'path->slots[0]', so the call to the validation function was only correct for the

[bug report] btrfs: get fs_info from eb in btrfs_print_leaf, remove argument

2017-07-19 Thread Dan Carpenter
Hello David Sterba, This is a semi-automatic email about new static checker warnings. The patch c042dd070450: "btrfs: get fs_info from eb in btrfs_print_leaf, remove argument" from Jun 29, 2017, leads to the following Smatch complaint: fs/btrfs/print-tree.c:181 btrfs_print_leaf() warn: v

[PATCH v2] btrfs: Remove unused variables

2017-07-19 Thread Nikolay Borisov
clear_super - usage was removed in commit cea67ab92d3d ("btrfs: clean the old superblocks before freeing the device") but that change forgot to remove the actual variable. max_key - commit 6174d3cb43aa ("Btrfs: remove unused max_key arg from btrfs_search_forward") removed the max_key parameter but

[PATCH v2] btrfs: Remove unused parameters from volume.c functions

2017-07-19 Thread Nikolay Borisov
This also adjusts the respective callers in other files. Those were found with -Wunused-parameter. btrfs_full_stripe_len's mapping_tree - introduced by 53b381b3abeb ("Btrfs: RAID5 and RAID6") but it was never really used even in that commit btrfs_is_parity_mirror's mirror_num - same as above chu