mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 05:48:40 +00:00
btrfs: Skip scrubbing removed chunks to avoid -ENOENT.
When run scrub with balance, sometimes -ENOENT will be returned, since in scrub_enumerate_chunks() will search dev_extent in *COMMIT_ROOT*, but btrfs_lookup_block_group() will search block group in *MEMORY*, so if a chunk is removed but not committed, -ENOENT will be returned. However, there is no need to stop scrubbing since other chunks may be scrubbed without problem. So this patch changes the behavior to skip removed chunks and continue to scrub the rest. Signed-off-by: Qu Wenruo <quwenruo@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
e570fd27f2
commit
ced96edc48
1 changed files with 9 additions and 10 deletions
|
@ -2725,11 +2725,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
|||
dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);
|
||||
length = btrfs_dev_extent_length(l, dev_extent);
|
||||
|
||||
if (found_key.offset + length <= start) {
|
||||
key.offset = found_key.offset + length;
|
||||
btrfs_release_path(path);
|
||||
continue;
|
||||
}
|
||||
if (found_key.offset + length <= start)
|
||||
goto skip;
|
||||
|
||||
chunk_tree = btrfs_dev_extent_chunk_tree(l, dev_extent);
|
||||
chunk_objectid = btrfs_dev_extent_chunk_objectid(l, dev_extent);
|
||||
|
@ -2740,10 +2737,12 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
|||
* the chunk from going away while we scrub it
|
||||
*/
|
||||
cache = btrfs_lookup_block_group(fs_info, chunk_offset);
|
||||
if (!cache) {
|
||||
ret = -ENOENT;
|
||||
break;
|
||||
}
|
||||
|
||||
/* some chunks are removed but not committed to disk yet,
|
||||
* continue scrubbing */
|
||||
if (!cache)
|
||||
goto skip;
|
||||
|
||||
dev_replace->cursor_right = found_key.offset + length;
|
||||
dev_replace->cursor_left = found_key.offset;
|
||||
dev_replace->item_needs_writeback = 1;
|
||||
|
@ -2802,7 +2801,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
|||
|
||||
dev_replace->cursor_left = dev_replace->cursor_right;
|
||||
dev_replace->item_needs_writeback = 1;
|
||||
|
||||
skip:
|
||||
key.offset = found_key.offset + length;
|
||||
btrfs_release_path(path);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue