981c2a
From: Martin Wilck <mwilck@suse.com>
981c2a
Date: Mon, 20 Apr 2020 22:29:09 +0200
981c2a
Subject: dm mpath: switch paths in dm_blk_ioctl() code path
981c2a
Patch-mainline: v5.8-rc1
981c2a
Git-commit: 2361ae595352dec015d14292f1b539242d8446d6
981c2a
References: bsc#1167574, bsc#1175995, bsc#1184485
981c2a
981c2a
SCSI LUN passthrough code such as qemu's "scsi-block" device model
981c2a
pass every IO to the host via SG_IO ioctls. Currently, dm-multipath
981c2a
calls choose_pgpath() only in the block IO code path, not in the ioctl
981c2a
code path (unless current_pgpath is NULL). This has the effect that no
981c2a
path switching and thus no load balancing is done for SCSI-passthrough
981c2a
IO, unless the active path fails.
981c2a
981c2a
Fix this by using the same logic in multipath_prepare_ioctl() as in
981c2a
multipath_clone_and_map().
981c2a
981c2a
Note: The allegedly best path selection algorithm, service-time,
981c2a
still wouldn't work perfectly, because the io size of the current
981c2a
request is always set to 0. Changing that for the IO passthrough
981c2a
case would require the ioctl cmd and arg to be passed to dm's
981c2a
prepare_ioctl() method.
981c2a
981c2a
Signed-off-by: Martin Wilck <mwilck@suse.com>
981c2a
Reviewed-by: Hannes Reinecke <hare@suse.de>
981c2a
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
981c2a
---
981c2a
 drivers/md/dm-mpath.c |    2 +-
981c2a
 1 file changed, 1 insertion(+), 1 deletion(-)
981c2a
981c2a
--- a/drivers/md/dm-mpath.c
981c2a
+++ b/drivers/md/dm-mpath.c
981c2a
@@ -1862,7 +1862,7 @@ static int multipath_prepare_ioctl(struc
981c2a
 	int r;
981c2a
 
981c2a
 	current_pgpath = READ_ONCE(m->current_pgpath);
981c2a
-	if (!current_pgpath)
981c2a
+	if (!current_pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
981c2a
 		current_pgpath = choose_pgpath(m, 0);
981c2a
 
981c2a
 	if (current_pgpath) {