Linux Kernels

dm: do not return target from dm_get_live_table_for_ioctl()

This change “dm: do not return target from dm_get_live_table_for_ioctl()” (commit 6648202) in Linux kernel is authored by Mike Snitzer <snitzer [at] redhat.com> on Thu Feb 18 15:44:39 2016 -0500.

Description of "dm: do not return target from dm_get_live_table_for_ioctl()"

The change “dm: do not return target from dm_get_live_table_for_ioctl()” introduces changes as follows.

dm: do not return target from dm_get_live_table_for_ioctl()

None of the callers actually used the returned target.
Also, just reuse bdev pointer passed to dm_blk_ioctl().

Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Linux kernel releases containing commit 6648202

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "dm: do not return target from dm_get_live_table_for_ioctl()"

There are 33 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/md/dm.c | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)
 
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index dd834927bc66..e9e74e6274d4 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -557,9 +557,10 @@ static int dm_blk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 }
 
 static int dm_get_live_table_for_ioctl(struct mapped_device *md,
-		struct dm_target **tgt, struct block_device **bdev,
-		fmode_t *mode, int *srcu_idx)
+				       struct block_device **bdev,
+				       fmode_t *mode, int *srcu_idx)
 {
+	struct dm_target *tgt;
 	struct dm_table *map;
 	int r;
 
@@ -573,9 +574,8 @@ static int dm_get_live_table_for_ioctl(struct mapped_device *md,
 	if (dm_table_get_num_targets(map) != 1)
 		goto out;
 
-	*tgt = dm_table_get_target(map, 0);
-
-	if (!(*tgt)->type->prepare_ioctl)
+	tgt = dm_table_get_target(map, 0);
+	if (!tgt->type->prepare_ioctl)
 		goto out;
 
 	if (dm_suspended_md(md)) {
@@ -583,7 +583,7 @@ static int dm_get_live_table_for_ioctl(struct mapped_device *md,
 		goto out;
 	}
 
-	r = (*tgt)->type->prepare_ioctl(*tgt, bdev, mode);
+	r = tgt->type->prepare_ioctl(tgt, bdev, mode);
 	if (r < 0)
 		goto out;
 
@@ -602,11 +602,9 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
 			unsigned int cmd, unsigned long arg)
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
-	struct dm_target *tgt;
-	struct block_device *tgt_bdev = NULL;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &tgt_bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 
@@ -621,7 +619,7 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
 			goto out;
 	}
 
-	r =  __blkdev_driver_ioctl(tgt_bdev, mode, cmd, arg);
+	r =  __blkdev_driver_ioctl(bdev, mode, cmd, arg);
 out:
 	dm_put_live_table(md, srcu_idx);
 	return r;
@@ -3558,11 +3556,10 @@ static int dm_pr_register(struct block_device *bdev, u64 old_key, u64 new_key,
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
 	const struct pr_ops *ops;
-	struct dm_target *tgt;
 	fmode_t mode;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 
@@ -3581,11 +3578,10 @@ static int dm_pr_reserve(struct block_device *bdev, u64 key, enum pr_type type,
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
 	const struct pr_ops *ops;
-	struct dm_target *tgt;
 	fmode_t mode;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 
@@ -3603,11 +3599,10 @@ static int dm_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
 	const struct pr_ops *ops;
-	struct dm_target *tgt;
 	fmode_t mode;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 
@@ -3626,11 +3621,10 @@ static int dm_pr_preempt(struct block_device *bdev, u64 old_key, u64 new_key,
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
 	const struct pr_ops *ops;
-	struct dm_target *tgt;
 	fmode_t mode;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 
@@ -3648,11 +3642,10 @@ static int dm_pr_clear(struct block_device *bdev, u64 key)
 {
 	struct mapped_device *md = bdev->bd_disk->private_data;
 	const struct pr_ops *ops;
-	struct dm_target *tgt;
 	fmode_t mode;
 	int srcu_idx, r;
 
-	r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
+	r = dm_get_live_table_for_ioctl(md, &bdev, &mode, &srcu_idx);
 	if (r < 0)
 		return r;
 

The commit for this change in Linux stable tree is 6648202 (patch).

Last modified: 2020/01/11 09:46