diff options
author | David Sterba <dsterba@suse.com> | 2018-03-20 10:37:08 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-05-28 12:07:23 -0400 |
commit | 6fc4749d25738e1a5e5b02d04a0a60bbae516652 (patch) | |
tree | 4f740bceb00bc2e9a28a52ff2840b7bef21610b2 | |
parent | 00251a527a6fae93ccd4322619b23db56ed82986 (diff) |
btrfs: make success path out of btrfs_init_dev_replace_tgtdev more clear
This is a preparatory cleanup that will make clear that the only
successful way out of btrfs_init_dev_replace_tgtdev will also set the
device_out to a valid pointer. With this guarantee, the callers can be
simplified.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/dev-replace.c | 1 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index db4d08c65131..e3ec0eb5789b 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -358,7 +358,6 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, | |||
358 | dev_replace->cont_reading_from_srcdev_mode = read_src; | 358 | dev_replace->cont_reading_from_srcdev_mode = read_src; |
359 | WARN_ON(!src_device); | 359 | WARN_ON(!src_device); |
360 | dev_replace->srcdev = src_device; | 360 | dev_replace->srcdev = src_device; |
361 | WARN_ON(!tgt_device); | ||
362 | dev_replace->tgtdev = tgt_device; | 361 | dev_replace->tgtdev = tgt_device; |
363 | 362 | ||
364 | btrfs_info_in_rcu(fs_info, | 363 | btrfs_info_in_rcu(fs_info, |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 70a87d4fe5fe..a8f8a2e39da6 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2612,6 +2612,12 @@ error: | |||
2612 | return ret; | 2612 | return ret; |
2613 | } | 2613 | } |
2614 | 2614 | ||
2615 | /* | ||
2616 | * Initialize a new device for device replace target from a given source dev | ||
2617 | * and path. | ||
2618 | * | ||
2619 | * Return 0 and new device in @device_out, otherwise return < 0 | ||
2620 | */ | ||
2615 | int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, | 2621 | int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, |
2616 | const char *device_path, | 2622 | const char *device_path, |
2617 | struct btrfs_device *srcdev, | 2623 | struct btrfs_device *srcdev, |
@@ -2698,7 +2704,7 @@ int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, | |||
2698 | mutex_unlock(&fs_info->fs_devices->device_list_mutex); | 2704 | mutex_unlock(&fs_info->fs_devices->device_list_mutex); |
2699 | 2705 | ||
2700 | *device_out = device; | 2706 | *device_out = device; |
2701 | return ret; | 2707 | return 0; |
2702 | 2708 | ||
2703 | error: | 2709 | error: |
2704 | blkdev_put(bdev, FMODE_EXCL); | 2710 | blkdev_put(bdev, FMODE_EXCL); |