diff mbox

[6/7] dm-mpath: Avoid code duplication in __multipath_map()

Message ID 4e810e44-8fd9-014e-d40d-12e895867096@sandisk.com (mailing list archive)
State Rejected, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Bart Van Assche Nov. 15, 2016, 11:34 p.m. UTC
Move common code out of if (clone) { ... } else { ... }.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 drivers/md/dm-mpath.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Mike Snitzer Nov. 16, 2016, 12:39 a.m. UTC | #1
On Tue, Nov 15 2016 at  6:34pm -0500,
Bart Van Assche <bart.vanassche@sandisk.com> wrote:

> Move common code out of if (clone) { ... } else { ... }.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> ---
>  drivers/md/dm-mpath.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
> index 5c73818..7559537 100644
> --- a/drivers/md/dm-mpath.c
> +++ b/drivers/md/dm-mpath.c
> @@ -574,8 +574,6 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
>  		 * Used by: .request_fn stacked on .request_fn path(s).
>  		 */
>  		clone->q = bdev_get_queue(bdev);
> -		clone->rq_disk = bdev->bd_disk;
> -		clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
>  	} else {
>  		/*
>  		 * blk-mq request-based interface; used by both:
> @@ -591,9 +589,9 @@ static int __multipath_map(struct dm_target *ti, struct request *clone,
>  		}
>  		*__clone = clone;
>  		clone->bio = clone->biotail = NULL;
> -		clone->rq_disk = bdev->bd_disk;
> -		clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
>  	}
> +	clone->rq_disk = bdev->bd_disk;
> +	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
>  
>  	if (pgpath->pg->ps.type->start_io)
>  		pgpath->pg->ps.type->start_io(&pgpath->pg->ps,
> -- 
> 2.10.1

I conciously left this duplication to avoid sprawling setup of the clone
request.  This isn't a lot of duplication here...

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 5c73818..7559537 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -574,8 +574,6 @@  static int __multipath_map(struct dm_target *ti, struct request *clone,
 		 * Used by: .request_fn stacked on .request_fn path(s).
 		 */
 		clone->q = bdev_get_queue(bdev);
-		clone->rq_disk = bdev->bd_disk;
-		clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
 	} else {
 		/*
 		 * blk-mq request-based interface; used by both:
@@ -591,9 +589,9 @@  static int __multipath_map(struct dm_target *ti, struct request *clone,
 		}
 		*__clone = clone;
 		clone->bio = clone->biotail = NULL;
-		clone->rq_disk = bdev->bd_disk;
-		clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
 	}
+	clone->rq_disk = bdev->bd_disk;
+	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
 
 	if (pgpath->pg->ps.type->start_io)
 		pgpath->pg->ps.type->start_io(&pgpath->pg->ps,