Skip to contentSkip to conversation

dm mpath: switch paths in dm_blk_ioctl() code path

PATCH In review [email protected] 2 participants 2 messages Apr 20, 2020 – Apr 21, 2020 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm mpath: switch paths in dm_blk_ioctl() code path

From: Martin Wilck <[email protected]>

SCSI LUN passthrough code such as qemu's "scsi-block" device model pass every IO to the host via SG_IO ioctls. Currently, dm-multipath calls choose_pgpath() only in the block IO code path, not in the ioctl code path (unless current_pgpath is NULL). This has the effect that no path switching and thus no load balancing is done for SCSI-passthrough IO, unless the active path fails.

Fix this by using the same logic in multipath_prepare_ioctl() as in multipath_clone_and_map().

Note: The allegedly best path selection algorithm, service-time, still wouldn't work perfectly, because the io size of the current request is always set to 0. Changing that for the IO passthrough case would require the ioctl cmd and arg to be passed to dm's prepare_ioctl() method.

---
 drivers/md/dm-mpath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
index 58fd137..f9b6a7a 100644
@@ -1916,7 +1916,7 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
 	int r;
 
 	current_pgpath = READ_ONCE(m->current_pgpath);
-	if (!current_pgpath)
+	if (!current_pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
 		current_pgpath = choose_pgpath(m, 0);
 
 	if (current_pgpath) {
Signature · 1 line
2.26.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · On 4/20/20 10:29 PM, [email protected] wrote:

From: Martin Wilck <[email protected]>

SCSI LUN passthrough code such as qemu's "scsi-block" device model pass every IO to the host via SG_IO ioctls. Currently, dm-multipath calls choose_pgpath() only in the block IO code path, not in the ioctl code path (unless current_pgpath is NULL). This has the effect that no path switching and thus no load balancing is done for SCSI-passthrough IO, unless the active path fails.

Fix this by using the same logic in multipath_prepare_ioctl() as in multipath_clone_and_map().

Note: The allegedly best path selection algorithm, service-time, still wouldn't work perfectly, because the io size of the current request is always set to 0. Changing that for the IO passthrough case would require the ioctl cmd and arg to be passed to dm's prepare_ioctl() method.

---
  drivers/md/dm-mpath.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +0 -0
index 58fd137..f9b6a7a 100644

drivers/md/dm-mpath.c static int multipath_prepare_ioctl(struct dm_target *ti, · line 1922

Quoted 8 lines
drivers/md/dm-mpath.c +1 -1
@@ -1916,7 +1916,7 @@ static int multipath_prepare_ioctl(struct dm_target *ti,
  	int r;
 
  	current_pgpath = READ_ONCE(m->current_pgpath);
-	if (!current_pgpath)
+	if (!current_pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags))
  		current_pgpath = choose_pgpath(m, 0);
 
  	if (current_pgpath) {

Well spotted.

Cheers,

Hannes

Signature · 10 lines
Dr. Hannes Reinecke            Teamlead Storage & Networking
[email protected]                               +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer


--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel