提交 32934280 编写于 作者: O Omar Sandoval 提交者: David Sterba

Btrfs: clean up scrub is_dev_replace parameter

struct scrub_ctx has an ->is_dev_replace member, so there's no point in
passing around is_dev_replace where sctx is available.
Signed-off-by: NOmar Sandoval <osandov@fb.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 1da73967
...@@ -3022,8 +3022,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx, ...@@ -3022,8 +3022,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
struct map_lookup *map, struct map_lookup *map,
struct btrfs_device *scrub_dev, struct btrfs_device *scrub_dev,
int num, u64 base, u64 length, int num, u64 base, u64 length)
int is_dev_replace)
{ {
struct btrfs_path *path, *ppath; struct btrfs_path *path, *ppath;
struct btrfs_fs_info *fs_info = sctx->fs_info; struct btrfs_fs_info *fs_info = sctx->fs_info;
...@@ -3299,7 +3298,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx, ...@@ -3299,7 +3298,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
extent_physical = extent_logical - logical + physical; extent_physical = extent_logical - logical + physical;
extent_dev = scrub_dev; extent_dev = scrub_dev;
extent_mirror_num = mirror_num; extent_mirror_num = mirror_num;
if (is_dev_replace) if (sctx->is_dev_replace)
scrub_remap_extent(fs_info, extent_logical, scrub_remap_extent(fs_info, extent_logical,
extent_len, &extent_physical, extent_len, &extent_physical,
&extent_dev, &extent_dev,
...@@ -3397,8 +3396,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, ...@@ -3397,8 +3396,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
struct btrfs_device *scrub_dev, struct btrfs_device *scrub_dev,
u64 chunk_offset, u64 length, u64 chunk_offset, u64 length,
u64 dev_offset, u64 dev_offset,
struct btrfs_block_group_cache *cache, struct btrfs_block_group_cache *cache)
int is_dev_replace)
{ {
struct btrfs_fs_info *fs_info = sctx->fs_info; struct btrfs_fs_info *fs_info = sctx->fs_info;
struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree;
...@@ -3435,8 +3433,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, ...@@ -3435,8 +3433,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
if (map->stripes[i].dev->bdev == scrub_dev->bdev && if (map->stripes[i].dev->bdev == scrub_dev->bdev &&
map->stripes[i].physical == dev_offset) { map->stripes[i].physical == dev_offset) {
ret = scrub_stripe(sctx, map, scrub_dev, i, ret = scrub_stripe(sctx, map, scrub_dev, i,
chunk_offset, length, chunk_offset, length);
is_dev_replace);
if (ret) if (ret)
goto out; goto out;
} }
...@@ -3449,8 +3446,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, ...@@ -3449,8 +3446,7 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
static noinline_for_stack static noinline_for_stack
int scrub_enumerate_chunks(struct scrub_ctx *sctx, int scrub_enumerate_chunks(struct scrub_ctx *sctx,
struct btrfs_device *scrub_dev, u64 start, u64 end, struct btrfs_device *scrub_dev, u64 start, u64 end)
int is_dev_replace)
{ {
struct btrfs_dev_extent *dev_extent = NULL; struct btrfs_dev_extent *dev_extent = NULL;
struct btrfs_path *path; struct btrfs_path *path;
...@@ -3544,7 +3540,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, ...@@ -3544,7 +3540,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
*/ */
scrub_pause_on(fs_info); scrub_pause_on(fs_info);
ret = btrfs_inc_block_group_ro(cache); ret = btrfs_inc_block_group_ro(cache);
if (!ret && is_dev_replace) { if (!ret && sctx->is_dev_replace) {
/* /*
* If we are doing a device replace wait for any tasks * If we are doing a device replace wait for any tasks
* that started dellaloc right before we set the block * that started dellaloc right before we set the block
...@@ -3609,7 +3605,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, ...@@ -3609,7 +3605,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
dev_replace->item_needs_writeback = 1; dev_replace->item_needs_writeback = 1;
btrfs_dev_replace_write_unlock(&fs_info->dev_replace); btrfs_dev_replace_write_unlock(&fs_info->dev_replace);
ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length, ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length,
found_key.offset, cache, is_dev_replace); found_key.offset, cache);
/* /*
* flush, submit all pending read and write bios, afterwards * flush, submit all pending read and write bios, afterwards
...@@ -3670,7 +3666,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, ...@@ -3670,7 +3666,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
btrfs_put_block_group(cache); btrfs_put_block_group(cache);
if (ret) if (ret)
break; break;
if (is_dev_replace && if (sctx->is_dev_replace &&
atomic64_read(&dev_replace->num_write_errors) > 0) { atomic64_read(&dev_replace->num_write_errors) > 0) {
ret = -EIO; ret = -EIO;
break; break;
...@@ -3893,8 +3889,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start, ...@@ -3893,8 +3889,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
} }
if (!ret) if (!ret)
ret = scrub_enumerate_chunks(sctx, dev, start, end, ret = scrub_enumerate_chunks(sctx, dev, start, end);
is_dev_replace);
wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0); wait_event(sctx->list_wait, atomic_read(&sctx->bios_in_flight) == 0);
atomic_dec(&fs_info->scrubs_running); atomic_dec(&fs_info->scrubs_running);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册