mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 09:59:32 +00:00
Btrfs: Separate finding-right-mirror and writing-to-target's process in scrub_handle_errored_block()
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 target" does not mean "source block is wrong", this patch separate above two condition in logic, and do some cleanup to make code clean. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
dc5f7a3bd8
commit
8d6738c1bd
1 changed files with 17 additions and 27 deletions
|
@ -1114,35 +1114,21 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
|
||||||
success = 1;
|
success = 1;
|
||||||
for (page_num = 0; page_num < sblock_bad->page_count;
|
for (page_num = 0; page_num < sblock_bad->page_count;
|
||||||
page_num++) {
|
page_num++) {
|
||||||
int sub_success;
|
struct scrub_block *sblock_other = NULL;
|
||||||
|
|
||||||
sub_success = 0;
|
|
||||||
for (mirror_index = 0;
|
for (mirror_index = 0;
|
||||||
mirror_index < BTRFS_MAX_MIRRORS &&
|
mirror_index < BTRFS_MAX_MIRRORS &&
|
||||||
sblocks_for_recheck[mirror_index].page_count > 0;
|
sblocks_for_recheck[mirror_index].page_count > 0;
|
||||||
mirror_index++) {
|
mirror_index++) {
|
||||||
struct scrub_block *sblock_other =
|
if (!sblocks_for_recheck[mirror_index].
|
||||||
sblocks_for_recheck + mirror_index;
|
pagev[page_num]->io_error) {
|
||||||
struct scrub_page *page_other =
|
sblock_other = sblocks_for_recheck +
|
||||||
sblock_other->pagev[page_num];
|
mirror_index;
|
||||||
|
break;
|
||||||
if (!page_other->io_error) {
|
|
||||||
ret = scrub_write_page_to_dev_replace(
|
|
||||||
sblock_other, page_num);
|
|
||||||
if (ret == 0) {
|
|
||||||
/* succeeded for this page */
|
|
||||||
sub_success = 1;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
btrfs_dev_replace_stats_inc(
|
|
||||||
&sctx->dev_root->
|
|
||||||
fs_info->dev_replace.
|
|
||||||
num_write_errors);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sub_success) {
|
if (!sblock_other) {
|
||||||
/*
|
/*
|
||||||
* did not find a mirror to fetch the page
|
* did not find a mirror to fetch the page
|
||||||
* from. scrub_write_page_to_dev_replace()
|
* from. scrub_write_page_to_dev_replace()
|
||||||
|
@ -1150,13 +1136,17 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
|
||||||
* filling the block with zeros before
|
* filling the block with zeros before
|
||||||
* submitting the write request
|
* submitting the write request
|
||||||
*/
|
*/
|
||||||
|
sblock_other = sblock_bad;
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scrub_write_page_to_dev_replace(sblock_other,
|
||||||
|
page_num) != 0) {
|
||||||
|
btrfs_dev_replace_stats_inc(
|
||||||
|
&sctx->dev_root->
|
||||||
|
fs_info->dev_replace.
|
||||||
|
num_write_errors);
|
||||||
success = 0;
|
success = 0;
|
||||||
ret = scrub_write_page_to_dev_replace(
|
|
||||||
sblock_bad, page_num);
|
|
||||||
if (ret)
|
|
||||||
btrfs_dev_replace_stats_inc(
|
|
||||||
&sctx->dev_root->fs_info->
|
|
||||||
dev_replace.num_write_errors);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue