Browse Source

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>
David Sterba 7 years ago
parent
commit
6fc4749d25
2 changed files with 7 additions and 2 deletions
  1. 0 1
      fs/btrfs/dev-replace.c
  2. 7 1
      fs/btrfs/volumes.c

+ 0 - 1
fs/btrfs/dev-replace.c

@@ -358,7 +358,6 @@ int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
 	dev_replace->cont_reading_from_srcdev_mode = read_src;
 	dev_replace->cont_reading_from_srcdev_mode = read_src;
 	WARN_ON(!src_device);
 	WARN_ON(!src_device);
 	dev_replace->srcdev = src_device;
 	dev_replace->srcdev = src_device;
-	WARN_ON(!tgt_device);
 	dev_replace->tgtdev = tgt_device;
 	dev_replace->tgtdev = tgt_device;
 
 
 	btrfs_info_in_rcu(fs_info,
 	btrfs_info_in_rcu(fs_info,

+ 7 - 1
fs/btrfs/volumes.c

@@ -2612,6 +2612,12 @@ error:
 	return ret;
 	return ret;
 }
 }
 
 
+/*
+ * Initialize a new device for device replace target from a given source dev
+ * and path.
+ *
+ * Return 0 and new device in @device_out, otherwise return < 0
+ */
 int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 				  const char *device_path,
 				  const char *device_path,
 				  struct btrfs_device *srcdev,
 				  struct btrfs_device *srcdev,
@@ -2698,7 +2704,7 @@ int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
 	mutex_unlock(&fs_info->fs_devices->device_list_mutex);
 
 
 	*device_out = device;
 	*device_out = device;
-	return ret;
+	return 0;
 
 
 error:
 error:
 	blkdev_put(bdev, FMODE_EXCL);
 	blkdev_put(bdev, FMODE_EXCL);