[PATCH 11/13] libmultipath: Add support for block device IOCTL

John Garry john.g.garry at oracle.com
Thu Apr 9 08:20:52 PDT 2026


On 27/02/2026 19:52, Benjamin Marzinski wrote:
>> diff --git a/include/linux/multipath.h b/include/linux/multipath.h
>> index 3846ea8cfd319..40dda6a914c5f 100644
>> --- a/include/linux/multipath.h
>> +++ b/include/linux/multipath.h
>> @@ -72,6 +72,9 @@ struct mpath_head_template {
>>   	bool (*is_disabled)(struct mpath_device *);
>>   	bool (*is_optimized)(struct mpath_device *);
>>   	enum mpath_access_state (*get_access_state)(struct mpath_device *);
>> +	int (*bdev_ioctl)(struct block_device *bdev, struct mpath_device *,
>> +			blk_mode_t mode, unsigned int cmd, unsigned long arg,
>> +			int srcu_idx);
> I don't know that this API is going to work out. SCSI persistent
> reservations need access to all the mpath_devices, not just one, and
> they are commonly handled via SG_IO ioctls. Unless you want to disallow
> SCSI persistent reservations via SG_IO, you need to be able to detect
> them, and handle them using the persistent reservation code with the
> mpath_head.

I'm just coming back to this ... so I am thinking of not supporting PR 
for scsi initially - like you mentioned, scsi pr has lots of nuances.

I am thinking of something like this:

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ded9cb8c57ea..c82adfc6871c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1295,6 +1295,12 @@ static blk_status_t scsi_setup_scsi_cmnd(struct 
scsi_device *sdev,
  {
  	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);

+	if (sdev->scsi_mpath_dev) {
+		blk_status_t ret = scsi_mpath_setup_scsi_cmnd(cmd);
+		if (ret)
+			return ret;
+	}
+
  	/*
  	 * Passthrough requests may transfer data, in which case they must
  	 * a bio attached to them.  Or they might contain a SCSI command
diff --git a/drivers/scsi/scsi_multipath.c b/drivers/scsi/scsi_multipath.c
index 1489c7e97916..1daa62361dac 100644
--- a/drivers/scsi/scsi_multipath.c
+++ b/drivers/scsi/scsi_multipath.c
@@ -280,6 +280,18 @@ static int scsi_multipath_sdev_init(struct 
scsi_device *sdev)
  	return 0;
  }

+
+blk_status_t scsi_mpath_setup_scsi_cmnd(struct scsi_cmnd *scmd)
+{
+	switch (scmd->cmnd[0]) {
+	/* Special handling required which is not yet supported */
+	case PERSISTENT_RESERVE_IN:
+	case PERSISTENT_RESERVE_OUT:
+		return BLK_STS_NOTSUPP;
+	}
+	return BLK_STS_OK;
+}
+

Which should catch SG_IO PR-related commands.



More information about the Linux-nvme mailing list