libmultipath: use uint64_t for sg_id.lun
PATCH 1/1 libmultipath: use uint64_t for sg_id.lun
From: Martin Wilck <[email protected]>
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 <[email protected]>
--- 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(-)
libmultipath/discovery.c +5 -5
@@ -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,
libmultipath/print.c +1 -1
@@ -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,
libmultipath/prioritizers/weightedpath.c +1 -1
@@ -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);
libmultipath/structs.c +1 -1
@@ -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 ;
libmultipath/structs.h +3 -1
@@ -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;
Signature · 7 lines
2.32.0 -- dm-devel mailing list [email protected] https://listman.redhat.com/mailman/listinfo/dm-devel
Quoted 6 lines · On Wed, Jun 30, 2021 at 10:01:35PM +0200, [email protected] wrote:
From: Martin Wilck <[email protected]>
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.
Reviewed-by Benjamin Marzinski <[email protected]>
Quoted 121 lines
Signed-off-by Martin Wilck <[email protected]>--- 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(-)libmultipath/discovery.c +5
-5@@ -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,libmultipath/print.c +1
-1@@ -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,libmultipath/prioritizers/weightedpath.c +1
-1@@ -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);libmultipath/structs.c +1
-1@@ -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 ;libmultipath/structs.h +3
-1@@ -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;Signature · 1 line
2.32.0
--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel