[PATCH 20/24] scsi: sd: add sd_mpath_to_disk()

John Garry john.g.garry at oracle.com
Wed Feb 25 07:36:23 PST 2026


Add a function to find associated mpath_disk for a request.

Signed-off-by: John Garry <john.g.garry at oracle.com>
---
 drivers/scsi/sd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f94a3b696dcab..9617878b53ec6 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -4081,6 +4081,14 @@ static int sd_mpath_ioctl(struct scsi_device *sdp, blk_mode_t mode,
 	return sd_ioctl(bdev, mode, cmd, arg);
 }
 
+static struct mpath_disk *sd_mpath_to_disk(struct request *req)
+{
+	struct scsi_disk *sdkp = req->part->bd_disk->private_data;
+	struct sd_mpath_disk *sd_mpath_disk = sdkp->sd_mpath_disk;
+
+	return sd_mpath_disk->mpath_disk;
+}
+
 static int sd_mpath_pr_register(struct scsi_device *sdp, u64 old_key,
 			u64 new_key, u32 flags)
 {
@@ -4592,6 +4600,7 @@ static struct scsi_driver sd_template = {
 	.mpath_end_cmd		= sd_mpath_end_command,
 	.mpath_ioctl		= sd_mpath_ioctl,
 	.mpath_pr_ops		= &sd_mpath_pr_ops,
+	.to_mpath_disk		= sd_mpath_to_disk,
 	#endif
 	.done			= sd_done,
 	.eh_action		= sd_eh_action,
-- 
2.43.5




More information about the Linux-nvme mailing list