[PATCH] libmultipath: use uint64_t for sg_id.lun

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Martin Wilck <mwilck@xxxxxxxx>

SCSI LUNs are 64bit unsigned integers, and have been exposed as such by
the kernel for years. Storage using the full 8 bytes is fortunately rare.
Still, we should handle this properly.

Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
---
 libmultipath/discovery.c                 | 10 +++++-----
 libmultipath/print.c                     |  2 +-
 libmultipath/prioritizers/weightedpath.c |  2 +-
 libmultipath/structs.c                   |  2 +-
 libmultipath/structs.h                   |  4 +++-
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index bfe2f56..e9f5703 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1427,7 +1427,7 @@ scsi_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable)
 			attr_path = udev_device_get_sysname(parent);
 			if (!attr_path)
 				break;
-			if (sscanf(attr_path, "%i:%i:%i:%i",
+			if (sscanf(attr_path, "%i:%i:%i:%" SCNu64,
 				   &pp->sg_id.host_no,
 				   &pp->sg_id.channel,
 				   &pp->sg_id.scsi_id,
@@ -1462,7 +1462,7 @@ scsi_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable)
 	/*
 	 * host / bus / target / lun
 	 */
-	condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
+	condlog(3, "%s: h:b:t:l = %i:%i:%i:%" PRIu64,
 			pp->dev,
 			pp->sg_id.host_no,
 			pp->sg_id.channel,
@@ -1577,7 +1577,7 @@ ccw_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable)
 		   &pp->sg_id.host_no,
 		   &pp->sg_id.channel,
 		   &pp->sg_id.scsi_id) == 3) {
-		condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
+		condlog(3, "%s: h:b:t:l = %i:%i:%i:%" PRIu64,
 			pp->dev,
 			pp->sg_id.host_no,
 			pp->sg_id.channel,
@@ -1636,7 +1636,7 @@ cciss_sysfs_pathinfo (struct path *pp, const struct _vector *hwtable)
 	 */
 	pp->sg_id.lun = 0;
 	pp->sg_id.channel = 0;
-	condlog(3, "%s: h:b:t:l = %i:%i:%i:%i",
+	condlog(3, "%s: h:b:t:l = %i:%i:%i:%" PRIu64,
 		pp->dev,
 		pp->sg_id.host_no,
 		pp->sg_id.channel,
@@ -1815,7 +1815,7 @@ scsi_ioctl_pathinfo (struct path * pp, int mask)
 			attr_path = udev_device_get_sysname(parent);
 			if (!attr_path)
 				break;
-			if (sscanf(attr_path, "%i:%i:%i:%i",
+			if (sscanf(attr_path, "%i:%i:%i:%" SCNu64,
 				   &pp->sg_id.host_no,
 				   &pp->sg_id.channel,
 				   &pp->sg_id.scsi_id,
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 3c69bf4..29ce499 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -392,7 +392,7 @@ snprint_hcil (char * buff, size_t len, const struct path * pp)
 	if (!pp || pp->sg_id.host_no < 0)
 		return snprintf(buff, len, "#:#:#:#");
 
-	return snprintf(buff, len, "%i:%i:%i:%i",
+	return snprintf(buff, len, "%i:%i:%i:%" PRIu64,
 			pp->sg_id.host_no,
 			pp->sg_id.channel,
 			pp->sg_id.scsi_id,
diff --git a/libmultipath/prioritizers/weightedpath.c b/libmultipath/prioritizers/weightedpath.c
index 916970d..650088b 100644
--- a/libmultipath/prioritizers/weightedpath.c
+++ b/libmultipath/prioritizers/weightedpath.c
@@ -101,7 +101,7 @@ int prio_path_weight(struct path *pp, char *prio_args)
 	}
 
 	if (!strcmp(regex, HBTL)) {
-		sprintf(path, "%d:%d:%d:%d", pp->sg_id.host_no,
+		sprintf(path, "%d:%d:%d:%" PRIu64, pp->sg_id.host_no,
 			pp->sg_id.channel, pp->sg_id.scsi_id, pp->sg_id.lun);
 	} else if (!strcmp(regex, DEV_NAME)) {
 		strcpy(path, pp->dev);
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 8751fc2..6e5a103 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -96,7 +96,7 @@ alloc_path (void)
 		pp->sg_id.host_no = -1;
 		pp->sg_id.channel = -1;
 		pp->sg_id.scsi_id = -1;
-		pp->sg_id.lun = -1;
+		pp->sg_id.lun = SCSI_INVALID_LUN;
 		pp->sg_id.proto_id = SCSI_PROTOCOL_UNSPEC;
 		pp->fd = -1;
 		pp->tpgs = TPGS_UNDEF;
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index c8447e5..c52bcee 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -178,6 +178,8 @@ enum scsi_protocol {
 	SCSI_PROTOCOL_UNSPEC = 0xf, /* No specific protocol */
 };
 
+#define SCSI_INVALID_LUN ~0ULL
+
 enum no_undef_states {
 	NU_NO = -1,
 	NU_UNDEF = 0,
@@ -258,7 +260,7 @@ struct sg_id {
 	int host_no;
 	int channel;
 	int scsi_id;
-	int lun;
+	uint64_t lun;
 	short h_cmd_per_lun;
 	short d_queue_depth;
 	enum scsi_protocol proto_id;
-- 
2.32.0


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux