btrfs: split dev-replace locking helpers for read and write
The current calls are unclear in what way btrfs_dev_replace_lock takes the locks, so drop the argument, split the helpers and use similar naming as for read and write locks. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
@@ -3935,11 +3935,11 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
||||
break;
|
||||
}
|
||||
|
||||
btrfs_dev_replace_lock(&fs_info->dev_replace, 1);
|
||||
btrfs_dev_replace_write_lock(&fs_info->dev_replace);
|
||||
dev_replace->cursor_right = found_key.offset + length;
|
||||
dev_replace->cursor_left = found_key.offset;
|
||||
dev_replace->item_needs_writeback = 1;
|
||||
btrfs_dev_replace_unlock(&fs_info->dev_replace, 1);
|
||||
btrfs_dev_replace_write_unlock(&fs_info->dev_replace);
|
||||
ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length,
|
||||
found_key.offset, cache, is_dev_replace);
|
||||
|
||||
@@ -3975,10 +3975,10 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
||||
|
||||
scrub_pause_off(fs_info);
|
||||
|
||||
btrfs_dev_replace_lock(&fs_info->dev_replace, 1);
|
||||
btrfs_dev_replace_write_lock(&fs_info->dev_replace);
|
||||
dev_replace->cursor_left = dev_replace->cursor_right;
|
||||
dev_replace->item_needs_writeback = 1;
|
||||
btrfs_dev_replace_unlock(&fs_info->dev_replace, 1);
|
||||
btrfs_dev_replace_write_unlock(&fs_info->dev_replace);
|
||||
|
||||
if (ro_set)
|
||||
btrfs_dec_block_group_ro(cache);
|
||||
@@ -4194,16 +4194,16 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
btrfs_dev_replace_lock(&fs_info->dev_replace, 0);
|
||||
btrfs_dev_replace_read_lock(&fs_info->dev_replace);
|
||||
if (dev->scrub_ctx ||
|
||||
(!is_dev_replace &&
|
||||
btrfs_dev_replace_is_ongoing(&fs_info->dev_replace))) {
|
||||
btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
|
||||
btrfs_dev_replace_read_unlock(&fs_info->dev_replace);
|
||||
mutex_unlock(&fs_info->scrub_lock);
|
||||
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
btrfs_dev_replace_unlock(&fs_info->dev_replace, 0);
|
||||
btrfs_dev_replace_read_unlock(&fs_info->dev_replace);
|
||||
|
||||
ret = scrub_workers_get(fs_info, is_dev_replace);
|
||||
if (ret) {
|
||||
|
Reference in New Issue
Block a user