device-mapper-multipath/0016-libmultipath-use-uint64_t-for-sg_id.lun.patch
Benjamin Marzinski 2d373b6820 device-mapper-multipath-0.8.6-5
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0016-0018 are from the upstream staging branch
  * Patches 0019-0024 have been submitted upstream
Rename files
  * Previous patches 0016-0025 are now patches 0024-0033
2021-07-30 13:07:22 -05:00

129 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 30 Jun 2021 21:51:53 +0200
Subject: [PATCH] libmultipath: use uint64_t for sg_id.lun
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: Benjamin Marzinski <bmarzins@redhat.com>
---
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 bfe2f56c..e9f5703c 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 3c69bf48..29ce499d 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 916970df..650088b4 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 8751fc2b..6e5a1038 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 c8447e56..c52bcee1 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;