device-mapper-multipath-0.9.0-3

Update to the head of the upstream staging branch
  * Patches 0005-0042 are from the upstream staging branch
  * Previous patches 0005 & 0006 are now patches 0023 & 0005
Rename redhat patches
  * Previous patches 0007-0017 are now patches 0043-0053
Change from using readline to libedit
  * readline is licensed GPL v3, and multipathd includes code
    licensed gpl v2.
Remove README.alua
  * information moved to README.md
This commit is contained in:
Benjamin Marzinski 2022-08-19 12:48:04 -05:00
parent ca605574d1
commit ef9089f4e8
52 changed files with 3580 additions and 30 deletions

View File

@ -19,6 +19,7 @@ Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com> Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com> Reviewed-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
--- ---
libmultipath/hwtable.c | 2 +- libmultipath/hwtable.c | 2 +-

View File

@ -12,6 +12,7 @@ Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com> Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com> Reviewed-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
--- ---
libmultipath/hwtable.c | 2 +- libmultipath/hwtable.c | 2 +-

View File

@ -1,13 +1,15 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com> From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 28 Jun 2022 15:38:28 -0500 Date: Tue, 12 Jul 2022 17:02:51 -0500
Subject: [PATCH] libmultipath: fix find_multipaths_timeout for unknown Subject: [PATCH] libmultipath: fix find_multipaths_timeout for unknown
hardware hardware
pp->hwe is now a vector that will always be allocated for all path pp->hwe is now a vector that will always be allocated for all path
devices. Instead of checking if it is NULL, check if it is empty. devices. Instead of checking if it is NULL, check if it is empty.
Fixes: f0462f0 ("libmultipath: use vector for for pp->hwe and mp->hwe")
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
--- ---
libmultipath/propsel.c | 2 +- libmultipath/propsel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)

View File

@ -0,0 +1,52 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Thu, 14 Jul 2022 21:05:39 +0200
Subject: [PATCH] multipath-tools: update devel repo info in README.md
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
README.md | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index f06f8cea..dcf51f20 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,6 @@
multipath-tools for Linux
=========================
-
https://github.com/opensvc/multipath-tools
This package provides the following binaries to drive the Device Mapper multipathing driver:
@@ -42,14 +41,12 @@ Go to: https://github.com/opensvc/multipath-tools/tags
Select a release-tag and then click on "zip" or "tar.gz".
-Source code
-===========
+Devel code
+==========
To get latest devel code:
- git clone https://github.com/opensvc/multipath-tools.git
-
-Github page: https://github.com/opensvc/multipath-tools
+ git clone -b queue https://github.com/openSUSE/multipath-tools
Building multipath-tools
@@ -149,4 +146,3 @@ The multipath-tools source code is covered by several different licences.
Refer to the individual source files for details.
Source files which do not specify a licence are shipped under LGPL-2.0
(see `LICENSES/LGPL-2.0`).
-

View File

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Thu, 14 Jul 2022 21:05:40 +0200
Subject: [PATCH] multipath-tools: delete README.alua
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
README.alua | 24 ------------------------
1 file changed, 24 deletions(-)
delete mode 100644 README.alua
diff --git a/README.alua b/README.alua
deleted file mode 100644
index 5d2b1c64..00000000
--- a/README.alua
+++ /dev/null
@@ -1,24 +0,0 @@
-This is a rough guide, consult your storage device manufacturer documentation.
-
-ALUA is supported in some devices, but usually it's disabled by default.
-To enable ALUA, the following options should be changed:
-
-- EMC CLARiiON/VNX:
- "Failover Mode" should be changed to "4" or "Active-Active mode(ALUA)-failover mode 4"
-
-- HPE 3PAR, Primera, and Alletra 9000:
- "Host:" should be changed to "Generic-ALUA Persona 2 (UARepLun, SESLun, ALUA)".
-
-- Promise VTrak/Vess:
- "LUN Affinity" and "ALUA" should be changed to "Enable", "Redundancy Type"
- must be "Active-Active".
-
-- LSI/Engenio/NetApp RDAC class, as NetApp SANtricity E/EF Series and OEM arrays:
- "Select operating system:" should be changed to "Linux DM-MP (Kernel 3.10 or later)".
-
-- NetApp ONTAP:
- To check ALUA state: "igroup show -v <igroup_name>", and to enable ALUA:
- "igroup set <igroup_name> alua yes".
-
-- Huawei OceanStor:
- "Host Access Mode" should be changed to "Asymmetric".

View File

@ -0,0 +1,53 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Thu, 14 Jul 2022 23:14:31 +0200
Subject: [PATCH] multipath-tools: add ALUA info to README.md
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
README.md | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/README.md b/README.md
index dcf51f20..2322082c 100644
--- a/README.md
+++ b/README.md
@@ -146,3 +146,31 @@ The multipath-tools source code is covered by several different licences.
Refer to the individual source files for details.
Source files which do not specify a licence are shipped under LGPL-2.0
(see `LICENSES/LGPL-2.0`).
+
+
+ALUA
+====
+This is a rough guide, consult your storage device manufacturer documentation.
+
+ALUA is supported in some devices, but usually it's disabled by default.
+To enable ALUA, the following options should be changed:
+
+- EMC CLARiiON/VNX:
+ "Failover Mode" should be changed to "4" or "Active-Active mode(ALUA)-failover mode 4"
+
+- HPE 3PAR, Primera, and Alletra 9000:
+ "Host:" should be changed to "Generic-ALUA Persona 2 (UARepLun, SESLun, ALUA)".
+
+- Promise VTrak/Vess:
+ "LUN Affinity" and "ALUA" should be changed to "Enable", "Redundancy Type"
+ must be "Active-Active".
+
+- LSI/Engenio/NetApp RDAC class, as NetApp SANtricity E/EF Series and OEM arrays:
+ "Select operating system:" should be changed to "Linux DM-MP (Kernel 3.10 or later)".
+
+- NetApp ONTAP:
+ To check ALUA state: "igroup show -v <igroup_name>", and to enable ALUA:
+ "igroup set <igroup_name> alua yes".
+
+- Huawei OceanStor:
+ "Host Access Mode" should be changed to "Asymmetric".

View File

@ -0,0 +1,95 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 6 Jul 2022 15:57:21 +0200
Subject: [PATCH] libmultipath: alua: remove get_sysfs_pg83()
Since b72e753 ("libmultipath: alua: try to retrieve inquiry data from sysfs"),
we fetch inquiry and VPD data from sysfs anyway. No need to do this twice.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/prioritizers/alua_rtpg.c | 57 ++++++++-------------------
1 file changed, 16 insertions(+), 41 deletions(-)
diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c
index 3f9c0e73..4db13c20 100644
--- a/libmultipath/prioritizers/alua_rtpg.c
+++ b/libmultipath/prioritizers/alua_rtpg.c
@@ -228,25 +228,6 @@ get_target_port_group_support(const struct path *pp, unsigned int timeout)
return rc;
}
-static int
-get_sysfs_pg83(const struct path *pp, unsigned char *buff, int buflen)
-{
- struct udev_device *parent = pp->udev;
-
- while (parent) {
- const char *subsys = udev_device_get_subsystem(parent);
- if (subsys && !strncmp(subsys, "scsi", 4))
- break;
- parent = udev_device_get_parent(parent);
- }
-
- if (!parent || sysfs_get_vpd(parent, 0x83, buff, buflen) <= 0) {
- PRINT_DEBUG("failed to read sysfs vpd pg83");
- return -1;
- }
- return 0;
-}
-
int
get_target_port_group(const struct path * pp, unsigned int timeout)
{
@@ -265,32 +246,26 @@ get_target_port_group(const struct path * pp, unsigned int timeout)
}
memset(buf, 0, buflen);
+ rc = do_inquiry(pp, 1, 0x83, buf, buflen, timeout);
+ if (rc < 0)
+ goto out;
- rc = get_sysfs_pg83(pp, buf, buflen);
-
- if (rc < 0) {
+ scsi_buflen = get_unaligned_be16(&buf[2]) + 4;
+ if (scsi_buflen >= USHRT_MAX)
+ scsi_buflen = USHRT_MAX;
+ if (buflen < scsi_buflen) {
+ free(buf);
+ buf = (unsigned char *)malloc(scsi_buflen);
+ if (!buf) {
+ PRINT_DEBUG("malloc failed: could not allocate"
+ "%u bytes", scsi_buflen);
+ return -RTPG_RTPG_FAILED;
+ }
+ buflen = scsi_buflen;
+ memset(buf, 0, buflen);
rc = do_inquiry(pp, 1, 0x83, buf, buflen, timeout);
if (rc < 0)
goto out;
-
- scsi_buflen = get_unaligned_be16(&buf[2]) + 4;
- /* Paranoia */
- if (scsi_buflen >= USHRT_MAX)
- scsi_buflen = USHRT_MAX;
- if (buflen < scsi_buflen) {
- free(buf);
- buf = (unsigned char *)malloc(scsi_buflen);
- if (!buf) {
- PRINT_DEBUG("malloc failed: could not allocate"
- "%u bytes", scsi_buflen);
- return -RTPG_RTPG_FAILED;
- }
- buflen = scsi_buflen;
- memset(buf, 0, buflen);
- rc = do_inquiry(pp, 1, 0x83, buf, buflen, timeout);
- if (rc < 0)
- goto out;
- }
}
vpd83 = (struct vpd83_data *) buf;

View File

@ -0,0 +1,77 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 10:54:02 +0200
Subject: [PATCH] libmultipath: remove sysfs_get_binary()
This function adds no value on top of sysfs_bin_attr_get_value().
Remove it.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/discovery.c | 26 ++------------------------
tests/test-lib.c | 1 -
2 files changed, 2 insertions(+), 25 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 0d8a558c..7e09e4e2 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -263,41 +263,19 @@ declare_sysfs_get_str(vendor);
declare_sysfs_get_str(model);
declare_sysfs_get_str(rev);
-static ssize_t
-sysfs_get_binary (struct udev_device * udev, const char *attrname,
- unsigned char *buff, size_t len)
-{
- ssize_t attr_len;
- const char * devname;
-
- if (!udev) {
- condlog(3, "No udev device given\n");
- return -ENOSYS;
- }
-
- devname = udev_device_get_sysname(udev);
- attr_len = sysfs_bin_attr_get_value(udev, attrname, buff, len);
- if (attr_len < 0) {
- condlog(3, "%s: attribute %s not found in sysfs",
- devname, attrname);
- return attr_len;
- }
- return attr_len;
-}
-
ssize_t sysfs_get_vpd(struct udev_device * udev, unsigned char pg,
unsigned char *buff, size_t len)
{
char attrname[9];
snprintf(attrname, sizeof(attrname), "vpd_pg%02x", pg);
- return sysfs_get_binary(udev, attrname, buff, len);
+ return sysfs_bin_attr_get_value(udev, attrname, buff, len);
}
ssize_t sysfs_get_inquiry(struct udev_device * udev,
unsigned char *buff, size_t len)
{
- return sysfs_get_binary(udev, "inquiry", buff, len);
+ return sysfs_bin_attr_get_value(udev, "inquiry", buff, len);
}
int
diff --git a/tests/test-lib.c b/tests/test-lib.c
index 6dd3ee88..0bc49d53 100644
--- a/tests/test-lib.c
+++ b/tests/test-lib.c
@@ -334,7 +334,6 @@ void mock_pathinfo(int mask, const struct mocked_path *mp)
if (mask & DI_SERIAL) {
will_return(__wrap_udev_device_get_subsystem, "scsi");
will_return(__wrap_udev_device_get_sysname, hbtl);
- will_return(__wrap_udev_device_get_sysname, hbtl);
}
if (mask & DI_WWID) {

View File

@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 10:47:51 +0200
Subject: [PATCH] libmultipath: sysfs_bin_attr_get_value(): no error if buffer
is filled
sysfs_bin_attr_get_value() sets the length of bytes read to 0
when the provided buffer was too small, truncating potentially
useful data. This is harmful e.g. in do_inquiry(), if the "inquiry"
sysfs attribute contains more than 96 bytes (which is possible).
Actually, binary attributes don't need to be 0-terminated. Thus,
unlike for string attributes, it's not an error if the requested number of
bytes is exactly equal to the number of bytes read. We expect that
the caller knows how many bytes it needs to read.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/discovery.c | 10 ++++++----
libmultipath/sysfs.c | 5 +----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 7e09e4e2..f5b8401c 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1341,13 +1341,15 @@ static int
get_vpd_sysfs (struct udev_device *parent, int pg, char * str, int maxlen)
{
int len;
- size_t buff_len;
+ ssize_t buff_len;
unsigned char buff[VPD_BUFLEN];
memset(buff, 0x0, VPD_BUFLEN);
- if (!parent || sysfs_get_vpd(parent, pg, buff, VPD_BUFLEN) <= 0) {
- condlog(3, "failed to read sysfs vpd pg%02x", pg);
- return -EINVAL;
+ buff_len = sysfs_get_vpd(parent, pg, buff, VPD_BUFLEN);
+ if (buff_len < 0) {
+ condlog(3, "failed to read sysfs vpd pg%02x: %s",
+ pg, strerror(-buff_len));
+ return buff_len;
}
if (buff[1] != pg) {
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index f45dbee1..3ec92512 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -146,10 +146,7 @@ ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
if (size < 0) {
condlog(4, "read from %s failed: %s", devpath, strerror(errno));
size = -errno;
- } else if (size == (ssize_t)value_len) {
- condlog(4, "overflow while reading from %s", devpath);
- size = 0;
- }
+ };
close(fd);
return size;

View File

@ -0,0 +1,115 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 11:14:30 +0200
Subject: [PATCH] libmultipath: common code path for sysfs_attr_get_value()
The code for sysfs_attr_get_value and sysfs_bin_attr_get_value() was
almost identical. Use a common code path.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/sysfs.c | 70 +++++++++++---------------------------------
1 file changed, 17 insertions(+), 53 deletions(-)
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 3ec92512..4db911cc 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -44,8 +44,8 @@
* as libudev lacks the capability to update an attribute value.
* So for modified attributes we need to implement our own function.
*/
-ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
- char * value, size_t value_len)
+static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
+ char *value, size_t value_len, bool binary)
{
char devpath[PATH_SIZE];
struct stat statbuf;
@@ -87,12 +87,14 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
if (size < 0) {
condlog(4, "read from %s failed: %s", devpath, strerror(errno));
size = -errno;
- value[0] = '\0';
- } else if (size == (ssize_t)value_len) {
+ if (!binary)
+ value[0] = '\0';
+ } else if (!binary && size == (ssize_t)value_len) {
+ condlog(3, "%s: overflow reading from %s (required len: %zu)",
+ __func__, devpath, size);
value[size - 1] = '\0';
- condlog(4, "overflow while reading from %s", devpath);
size = 0;
- } else {
+ } else if (!binary) {
value[size] = '\0';
size = strchop(value);
}
@@ -101,55 +103,17 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
return size;
}
-ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
- unsigned char * value, size_t value_len)
+ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
+ char *value, size_t value_len)
{
- char devpath[PATH_SIZE];
- struct stat statbuf;
- int fd;
- ssize_t size = -1;
-
- if (!dev || !attr_name || !value)
- return 0;
-
- snprintf(devpath, PATH_SIZE, "%s/%s", udev_device_get_syspath(dev),
- attr_name);
- condlog(4, "open '%s'", devpath);
- /* read attribute value */
- fd = open(devpath, O_RDONLY);
- if (fd < 0) {
- condlog(4, "attribute '%s' can not be opened: %s",
- devpath, strerror(errno));
- return -errno;
- }
- if (fstat(fd, &statbuf) != 0) {
- condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
- close(fd);
- return -ENXIO;
- }
-
- /* skip directories */
- if (S_ISDIR(statbuf.st_mode)) {
- condlog(4, "%s is a directory", devpath);
- close(fd);
- return -EISDIR;
- }
-
- /* skip non-writeable files */
- if ((statbuf.st_mode & S_IRUSR) == 0) {
- condlog(4, "%s is not readable", devpath);
- close(fd);
- return -EPERM;
- }
-
- size = read(fd, value, value_len);
- if (size < 0) {
- condlog(4, "read from %s failed: %s", devpath, strerror(errno));
- size = -errno;
- };
+ return __sysfs_attr_get_value(dev, attr_name, value, value_len, false);
+}
- close(fd);
- return size;
+ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
+ unsigned char *value, size_t value_len)
+{
+ return __sysfs_attr_get_value(dev, attr_name, (char *)value,
+ value_len, true);
}
ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,

View File

@ -0,0 +1,165 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 11:41:40 +0200
Subject: [PATCH] libmultipath: sanitize error checking in sysfs accessors
udev_device_get_syspath() may return NULL; check for it, and check
for pathname overflow. Disallow a zero buffer length. The fstat()
calls were superfluous, as a read() or write() on the fd would
return the respective error codes depending on file type or permissions,
the extra system call and code complexity adds no value.
Log levels should be moderate in sysfs.c, because it depends
on the caller whether errors getting/setting certain attributes are
fatal.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/sysfs.c | 94 ++++++++++++++++++--------------------------
1 file changed, 39 insertions(+), 55 deletions(-)
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 4db911cc..1f0f2074 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -47,46 +47,38 @@
static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
char *value, size_t value_len, bool binary)
{
+ const char *syspath;
char devpath[PATH_SIZE];
- struct stat statbuf;
int fd;
ssize_t size = -1;
- if (!dev || !attr_name || !value)
- return 0;
+ if (!dev || !attr_name || !value || !value_len) {
+ condlog(1, "%s: invalid parameters", __func__);
+ return -EINVAL;
+ }
- snprintf(devpath, PATH_SIZE, "%s/%s", udev_device_get_syspath(dev),
- attr_name);
+ syspath = udev_device_get_syspath(dev);
+ if (!syspath) {
+ condlog(3, "%s: invalid udevice", __func__);
+ return -EINVAL;
+ }
+ if (safe_sprintf(devpath, "%s/%s", syspath, attr_name)) {
+ condlog(3, "%s: devpath overflow", __func__);
+ return -EOVERFLOW;
+ }
condlog(4, "open '%s'", devpath);
/* read attribute value */
fd = open(devpath, O_RDONLY);
if (fd < 0) {
- condlog(4, "attribute '%s' can not be opened: %s",
- devpath, strerror(errno));
+ condlog(3, "%s: attribute '%s' can not be opened: %s",
+ __func__, devpath, strerror(errno));
return -errno;
}
- if (fstat(fd, &statbuf) < 0) {
- condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
- close(fd);
- return -ENXIO;
- }
- /* skip directories */
- if (S_ISDIR(statbuf.st_mode)) {
- condlog(4, "%s is a directory", devpath);
- close(fd);
- return -EISDIR;
- }
- /* skip non-writeable files */
- if ((statbuf.st_mode & S_IRUSR) == 0) {
- condlog(4, "%s is not readable", devpath);
- close(fd);
- return -EPERM;
- }
-
size = read(fd, value, value_len);
if (size < 0) {
- condlog(4, "read from %s failed: %s", devpath, strerror(errno));
size = -errno;
+ condlog(3, "%s: read from %s failed: %s", __func__, devpath,
+ strerror(errno));
if (!binary)
value[0] = '\0';
} else if (!binary && size == (ssize_t)value_len) {
@@ -119,51 +111,43 @@ ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
const char * value, size_t value_len)
{
+ const char *syspath;
char devpath[PATH_SIZE];
- struct stat statbuf;
int fd;
ssize_t size = -1;
- if (!dev || !attr_name || !value || !value_len)
- return 0;
+ if (!dev || !attr_name || !value || !value_len) {
+ condlog(1, "%s: invalid parameters", __func__);
+ return -EINVAL;
+ }
+
+ syspath = udev_device_get_syspath(dev);
+ if (!syspath) {
+ condlog(3, "%s: invalid udevice", __func__);
+ return -EINVAL;
+ }
+ if (safe_sprintf(devpath, "%s/%s", syspath, attr_name)) {
+ condlog(3, "%s: devpath overflow", __func__);
+ return -EOVERFLOW;
+ }
- snprintf(devpath, PATH_SIZE, "%s/%s", udev_device_get_syspath(dev),
- attr_name);
condlog(4, "open '%s'", devpath);
/* write attribute value */
fd = open(devpath, O_WRONLY);
if (fd < 0) {
- condlog(4, "attribute '%s' can not be opened: %s",
- devpath, strerror(errno));
- return -errno;
- }
- if (fstat(fd, &statbuf) != 0) {
- condlog(4, "stat '%s' failed: %s", devpath, strerror(errno));
- close(fd);
+ condlog(2, "%s: attribute '%s' can not be opened: %s",
+ __func__, devpath, strerror(errno));
return -errno;
}
- /* skip directories */
- if (S_ISDIR(statbuf.st_mode)) {
- condlog(4, "%s is a directory", devpath);
- close(fd);
- return -EISDIR;
- }
-
- /* skip non-writeable files */
- if ((statbuf.st_mode & S_IWUSR) == 0) {
- condlog(4, "%s is not writeable", devpath);
- close(fd);
- return -EPERM;
- }
-
size = write(fd, value, value_len);
if (size < 0) {
- condlog(4, "write to %s failed: %s", devpath, strerror(errno));
size = -errno;
+ condlog(3, "%s: write to %s failed: %s", __func__,
+ devpath, strerror(errno));
} else if (size < (ssize_t)value_len) {
- condlog(4, "tried to write %ld to %s. Wrote %ld",
- (long)value_len, devpath, (long)size);
+ condlog(3, "%s: underflow writing %zu bytes to %s. Wrote %zd bytes",
+ __func__, value_len, devpath, size);
size = 0;
}

View File

@ -0,0 +1,115 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 11:52:42 +0200
Subject: [PATCH] libmultipath: get rid of PATH_SIZE
replace PATH_SIZE with the system limit PATH_MAX. In some places,
PATH_SIZE was used for file names. Use FILE_NAME_SIZE in these cases.
Also, use a constant for "multipathd.service" in systemd_service_enabled_in().
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/structs.h | 3 ---
libmultipath/sysfs.c | 8 ++++----
libmultipath/util.c | 8 +++++---
multipathd/cli_handlers.c | 2 +-
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index a6a09441..dfa12ff9 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -17,7 +17,6 @@
#define FILE_NAME_SIZE 256
#define CALLOUT_MAX_SIZE 256
#define BLK_DEV_SIZE 33
-#define PATH_SIZE 512
#define NAME_SIZE 512
#define HOST_NAME_LEN 16
#define SLOT_NAME_SIZE 40
@@ -519,6 +518,4 @@ int pathcmp (const struct pathgroup *, const struct pathgroup *);
int add_feature (char **, const char *);
int remove_feature (char **, const char *);
-extern char sysfs_path[PATH_SIZE];
-
#endif /* _STRUCTS_H */
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 1f0f2074..e48b05ec 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -48,7 +48,7 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_
char *value, size_t value_len, bool binary)
{
const char *syspath;
- char devpath[PATH_SIZE];
+ char devpath[PATH_MAX];
int fd;
ssize_t size = -1;
@@ -112,7 +112,7 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
const char * value, size_t value_len)
{
const char *syspath;
- char devpath[PATH_SIZE];
+ char devpath[PATH_MAX];
int fd;
ssize_t size = -1;
@@ -184,7 +184,7 @@ sysfs_get_size (struct path *pp, unsigned long long * size)
int sysfs_check_holders(char * check_devt, char * new_devt)
{
unsigned int major, new_minor, table_minor;
- char path[PATH_MAX], check_dev[PATH_SIZE];
+ char path[PATH_MAX], check_dev[FILE_NAME_SIZE];
char * table_name;
DIR *dirfd;
struct dirent *holder;
@@ -194,7 +194,7 @@ int sysfs_check_holders(char * check_devt, char * new_devt)
return 0;
}
- if (devt2devname(check_dev, PATH_SIZE, check_devt)) {
+ if (devt2devname(check_dev, sizeof(check_dev), check_devt)) {
condlog(1, "can't get devname for %s", check_devt);
return 0;
}
diff --git a/libmultipath/util.c b/libmultipath/util.c
index ce5ea73e..e7e7d4c1 100644
--- a/libmultipath/util.c
+++ b/libmultipath/util.c
@@ -242,13 +242,15 @@ setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached)
int systemd_service_enabled_in(const char *dev, const char *prefix)
{
- char path[PATH_SIZE], file[PATH_MAX], service[PATH_SIZE];
+ static const char service[] = "multipathd.service";
+ char path[PATH_MAX], file[PATH_MAX];
DIR *dirfd;
struct dirent *d;
int found = 0;
- snprintf(service, PATH_SIZE, "multipathd.service");
- snprintf(path, PATH_SIZE, "%s/systemd/system", prefix);
+ if (safe_sprintf(path, "%s/systemd/system", prefix))
+ return 0;
+
condlog(3, "%s: checking for %s in %s", dev, service, path);
dirfd = opendir(path);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index d79cdd7c..db4d4412 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -688,7 +688,7 @@ cli_add_map (void * v, struct strbuf *reply, void * data)
struct vectors * vecs = (struct vectors *)data;
char * param = get_keyparam(v, MAP);
int major = -1, minor = -1;
- char dev_path[PATH_SIZE];
+ char dev_path[FILE_NAME_SIZE];
char *refwwid, *alias = NULL;
int rc, count = 0;
struct config *conf;

View File

@ -0,0 +1,172 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 13:33:51 +0200
Subject: [PATCH] libmultipath: sysfs_attr_get_value(): don't return 0 if
buffer too small
If the passed read buffer is too small to hold the value read plus
terminating 0 byte, return the given size value rather than 0.
This way we get similar semantics as for sysfs_bin_attr_get_get_value(),
except that sysfs_attr_get_value() must always 0-terminate the value;
thus a return value equal to the length parameter is an error for
the non-binary case.
Provide a helper macro to test this "overflow" condition.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/configure.c | 2 +-
libmultipath/discovery.c | 14 +++++++-------
libmultipath/propsel.c | 6 +++++-
libmultipath/sysfs.c | 3 +--
libmultipath/sysfs.h | 13 +++++++++++++
multipathd/main.c | 2 +-
6 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 09ae708d..467bbaa6 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -589,7 +589,7 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload)
ret = sysfs_attr_get_value(udd, "queue/max_sectors_kb", buff,
sizeof(buff));
udev_device_unref(udd);
- if (ret <= 0) {
+ if (!sysfs_attr_value_ok(ret, sizeof(buff))) {
condlog(1, "failed to get current max_sectors_kb from %s", mpp->alias);
return 1;
}
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index f5b8401c..54b1caf0 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -560,10 +560,10 @@ sysfs_get_asymmetric_access_state(struct path *pp, char *buff, int buflen)
if (!parent)
return -1;
- if (sysfs_attr_get_value(parent, "access_state", buff, buflen) <= 0)
+ if (!sysfs_attr_get_value_ok(parent, "access_state", buff, buflen))
return -1;
- if (sysfs_attr_get_value(parent, "preferred_path", value, 16) <= 0)
+ if (!sysfs_attr_get_value_ok(parent, "preferred_path", value, sizeof(value)))
return 0;
preferred = strtoul(value, &eptr, 0);
@@ -638,8 +638,8 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
/*
* read the current dev_loss_tmo value from sysfs
*/
- ret = sysfs_attr_get_value(rport_dev, "dev_loss_tmo", value, 16);
- if (ret <= 0) {
+ ret = sysfs_attr_get_value(rport_dev, "dev_loss_tmo", value, sizeof(value));
+ if (!sysfs_attr_value_ok(ret, sizeof(value))) {
condlog(0, "%s: failed to read dev_loss_tmo value, "
"error %d", rport_id, -ret);
goto out;
@@ -1737,8 +1737,8 @@ path_offline (struct path * pp)
}
memset(buff, 0x0, SCSI_STATE_SIZE);
- err = sysfs_attr_get_value(parent, "state", buff, SCSI_STATE_SIZE);
- if (err <= 0) {
+ err = sysfs_attr_get_value(parent, "state", buff, sizeof(buff));
+ if (!sysfs_attr_value_ok(err, sizeof(buff))) {
if (err == -ENXIO)
return PATH_REMOVED;
else
@@ -2142,7 +2142,7 @@ static ssize_t uid_fallback(struct path *pp, int path_state,
return -1;
len = sysfs_attr_get_value(pp->udev, "wwid", value,
sizeof(value));
- if (len <= 0)
+ if (!sysfs_attr_value_ok(len, sizeof(value)))
return -1;
len = strlcpy(pp->wwid, value, WWID_SIZE);
if (len >= WWID_SIZE) {
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index f782f251..98e3aad1 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -435,6 +435,7 @@ out:
static int get_dh_state(struct path *pp, char *value, size_t value_len)
{
struct udev_device *ud;
+ ssize_t rc;
if (pp->udev == NULL)
return -1;
@@ -444,7 +445,10 @@ static int get_dh_state(struct path *pp, char *value, size_t value_len)
if (ud == NULL)
return -1;
- return sysfs_attr_get_value(ud, "dh_state", value, value_len);
+ rc = sysfs_attr_get_value(ud, "dh_state", value, value_len);
+ if (!sysfs_attr_value_ok(rc, value_len))
+ return -1;
+ return rc;
}
int select_hwhandler(struct config *conf, struct multipath *mp)
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index e48b05ec..125f1c2b 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -85,7 +85,6 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_
condlog(3, "%s: overflow reading from %s (required len: %zu)",
__func__, devpath, size);
value[size - 1] = '\0';
- size = 0;
} else if (!binary) {
value[size] = '\0';
size = strchop(value);
@@ -165,7 +164,7 @@ sysfs_get_size (struct path *pp, unsigned long long * size)
return 1;
attr[0] = '\0';
- if (sysfs_attr_get_value(pp->udev, "size", attr, 255) <= 0) {
+ if (!sysfs_attr_get_value_ok(pp->udev, "size", attr, sizeof(attr))) {
condlog(3, "%s: No size attribute in sysfs", pp->dev);
return 1;
}
diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h
index 72b39ab2..cdc84e40 100644
--- a/libmultipath/sysfs.h
+++ b/libmultipath/sysfs.h
@@ -12,6 +12,19 @@ ssize_t sysfs_attr_get_value(struct udev_device *dev, const char *attr_name,
char * value, size_t value_len);
ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
unsigned char * value, size_t value_len);
+#define sysfs_attr_value_ok(rc, value_len) \
+ ({ \
+ ssize_t __r = rc; \
+ __r >= 0 && (size_t)__r < (size_t)value_len; \
+ })
+
+#define sysfs_attr_get_value_ok(dev, attr, val, len) \
+ ({ \
+ size_t __l = (len); \
+ ssize_t __rc = sysfs_attr_get_value(dev, attr, val, __l); \
+ sysfs_attr_value_ok(__rc, __l); \
+ })
+
int sysfs_get_size (struct path *pp, unsigned long long * size);
int sysfs_check_holders(char * check_devt, char * new_devt);
bool sysfs_is_multipathed(struct path *pp, bool set_wwid);
diff --git a/multipathd/main.c b/multipathd/main.c
index 2f2b9d4c..68eca925 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1126,7 +1126,7 @@ sysfs_get_ro (struct path *pp)
if (!pp->udev)
return -1;
- if (sysfs_attr_get_value(pp->udev, "ro", buff, sizeof(buff)) <= 0) {
+ if (!sysfs_attr_get_value_ok(pp->udev, "ro", buff, sizeof(buff))) {
condlog(3, "%s: Cannot read ro attribute in sysfs", pp->dev);
return -1;
}

View File

@ -0,0 +1,251 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 17:51:41 +0200
Subject: [PATCH] libmultipath: sysfs_attr_set_value(): don't return 0 on
partial write
sysfs_attr_set_value() returned 0 if not all requested bytes were written.
Change this to return the number of bytes written. Error checking is now
somewhat more involved; provide a helper macro for it.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/configure.c | 10 ++++--
libmultipath/discovery.c | 74 +++++++++++++++++++++++++---------------
libmultipath/sysfs.c | 6 ++--
libmultipath/sysfs.h | 10 ++++++
4 files changed, 66 insertions(+), 34 deletions(-)
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 467bbaa6..0607dbac 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -568,6 +568,7 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload)
struct pathgroup * pgp;
struct path *pp;
char buff[11];
+ ssize_t len;
int i, j, ret, err = 0;
struct udev_device *udd;
int max_sectors_kb;
@@ -600,14 +601,17 @@ sysfs_set_max_sectors_kb(struct multipath *mpp, int is_reload)
}
}
snprintf(buff, 11, "%d", max_sectors_kb);
+ len = strlen(buff);
vector_foreach_slot (mpp->pg, pgp, i) {
vector_foreach_slot(pgp->paths, pp, j) {
ret = sysfs_attr_set_value(pp->udev,
"queue/max_sectors_kb",
- buff, strlen(buff));
- if (ret < 0) {
- condlog(1, "failed setting max_sectors_kb on %s : %s", pp->dev, strerror(-ret));
+ buff, len);
+ if (ret != len) {
+ log_sysfs_attr_set_value(1, ret,
+ "failed setting max_sectors_kb on %s",
+ pp->dev);
err = 1;
}
}
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 54b1caf0..ee290093 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -598,13 +598,15 @@ sysfs_set_eh_deadline(struct path *pp)
len = sprintf(value, "%d", pp->eh_deadline);
ret = sysfs_attr_set_value(hostdev, "eh_deadline",
- value, len + 1);
+ value, len);
/*
* not all scsi drivers support setting eh_deadline, so failing
* is totally reasonable
*/
- if (ret <= 0)
- condlog(3, "%s: failed to set eh_deadline to %s, error %d", udev_device_get_sysname(hostdev), value, -ret);
+ if (ret != len)
+ log_sysfs_attr_set_value(3, ret,
+ "%s: failed to set eh_deadline to %s",
+ udev_device_get_sysname(hostdev), value);
udev_device_unref(hostdev);
return (ret <= 0);
@@ -667,19 +669,22 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
pp->fast_io_fail != MP_FAST_IO_FAIL_OFF) {
/* Check if we need to temporarily increase dev_loss_tmo */
if ((unsigned int)pp->fast_io_fail >= tmo) {
+ ssize_t len;
+
/* Increase dev_loss_tmo temporarily */
snprintf(value, sizeof(value), "%u",
(unsigned int)pp->fast_io_fail + 1);
+ len = strlen(value);
ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
- value, strlen(value));
- if (ret <= 0) {
+ value, len);
+ if (ret != len) {
if (ret == -EBUSY)
condlog(3, "%s: rport blocked",
rport_id);
else
- condlog(0, "%s: failed to set "
- "dev_loss_tmo to %s, error %d",
- rport_id, value, -ret);
+ log_sysfs_attr_set_value(0, ret,
+ "%s: failed to set dev_loss_tmo to %s",
+ rport_id, value);
goto out;
}
}
@@ -691,32 +696,39 @@ sysfs_set_rport_tmo(struct multipath *mpp, struct path *pp)
pp->dev_loss = DEFAULT_DEV_LOSS_TMO;
}
if (pp->fast_io_fail != MP_FAST_IO_FAIL_UNSET) {
+ ssize_t len;
+
if (pp->fast_io_fail == MP_FAST_IO_FAIL_OFF)
sprintf(value, "off");
else if (pp->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
sprintf(value, "0");
else
snprintf(value, 16, "%u", pp->fast_io_fail);
+ len = strlen(value);
ret = sysfs_attr_set_value(rport_dev, "fast_io_fail_tmo",
- value, strlen(value));
- if (ret <= 0) {
+ value, len);
+ if (ret != len) {
if (ret == -EBUSY)
condlog(3, "%s: rport blocked", rport_id);
else
- condlog(0, "%s: failed to set fast_io_fail_tmo to %s, error %d",
- rport_id, value, -ret);
+ log_sysfs_attr_set_value(0, ret,
+ "%s: failed to set fast_io_fail_tmo to %s",
+ rport_id, value);
}
}
if (pp->dev_loss != DEV_LOSS_TMO_UNSET) {
+ ssize_t len;
+
snprintf(value, 16, "%u", pp->dev_loss);
- ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo",
- value, strlen(value));
- if (ret <= 0) {
+ len = strlen(value);
+ ret = sysfs_attr_set_value(rport_dev, "dev_loss_tmo", value, len);
+ if (ret != len) {
if (ret == -EBUSY)
condlog(3, "%s: rport blocked", rport_id);
else
- condlog(0, "%s: failed to set dev_loss_tmo to %s, error %d",
- rport_id, value, -ret);
+ log_sysfs_attr_set_value(0, ret,
+ "%s: failed to set dev_loss_tmo to %s",
+ rport_id, value);
}
}
out:
@@ -754,12 +766,16 @@ sysfs_set_session_tmo(struct path *pp)
condlog(3, "%s: can't set fast_io_fail_tmo to '0'"
"on iSCSI", pp->dev);
} else {
+ ssize_t len, ret;
+
snprintf(value, 11, "%u", pp->fast_io_fail);
- if (sysfs_attr_set_value(session_dev, "recovery_tmo",
- value, strlen(value)) <= 0) {
- condlog(3, "%s: Failed to set recovery_tmo, "
- " error %d", pp->dev, errno);
- }
+ len = strlen(value);
+ ret = sysfs_attr_set_value(session_dev, "recovery_tmo",
+ value, len);
+ if (ret != len)
+ log_sysfs_attr_set_value(3, ret,
+ "%s: Failed to set recovery_tmo to %s",
+ pp->dev, value);
}
}
udev_device_unref(session_dev);
@@ -802,12 +818,16 @@ sysfs_set_nexus_loss_tmo(struct path *pp)
pp->sg_id.channel, pp->sg_id.scsi_id, end_dev_id);
if (pp->dev_loss != DEV_LOSS_TMO_UNSET) {
+ ssize_t len, ret;
+
snprintf(value, 11, "%u", pp->dev_loss);
- if (sysfs_attr_set_value(sas_dev, "I_T_nexus_loss_timeout",
- value, strlen(value)) <= 0)
- condlog(3, "%s: failed to update "
- "I_T Nexus loss timeout, error %d",
- pp->dev, errno);
+ len = strlen(value);
+ ret = sysfs_attr_set_value(sas_dev, "I_T_nexus_loss_timeout",
+ value, len);
+ if (ret != len)
+ log_sysfs_attr_set_value(3, ret,
+ "%s: failed to update I_T Nexus loss timeout",
+ pp->dev);
}
udev_device_unref(sas_dev);
return;
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 125f1c2b..9c84af70 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -134,7 +134,7 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
/* write attribute value */
fd = open(devpath, O_WRONLY);
if (fd < 0) {
- condlog(2, "%s: attribute '%s' can not be opened: %s",
+ condlog(3, "%s: attribute '%s' can not be opened: %s",
__func__, devpath, strerror(errno));
return -errno;
}
@@ -144,11 +144,9 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
size = -errno;
condlog(3, "%s: write to %s failed: %s", __func__,
devpath, strerror(errno));
- } else if (size < (ssize_t)value_len) {
+ } else if (size < (ssize_t)value_len)
condlog(3, "%s: underflow writing %zu bytes to %s. Wrote %zd bytes",
__func__, value_len, devpath, size);
- size = 0;
- }
close(fd);
return size;
diff --git a/libmultipath/sysfs.h b/libmultipath/sysfs.h
index cdc84e40..799f68e9 100644
--- a/libmultipath/sysfs.h
+++ b/libmultipath/sysfs.h
@@ -5,6 +5,7 @@
#ifndef _LIBMULTIPATH_SYSFS_H
#define _LIBMULTIPATH_SYSFS_H
#include <stdbool.h>
+#include "strbuf.h"
ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
const char * value, size_t value_len);
@@ -25,6 +26,15 @@ ssize_t sysfs_bin_attr_get_value(struct udev_device *dev, const char *attr_name,
sysfs_attr_value_ok(__rc, __l); \
})
+#define log_sysfs_attr_set_value(prio, rc, fmt, __args...) \
+do { \
+ STRBUF_ON_STACK(__buf); \
+ if (print_strbuf(&__buf, fmt, ##__args) >= 0 && \
+ print_strbuf(&__buf, ": %s", rc < 0 ? strerror(-rc) : \
+ "write underflow") >= 0) \
+ condlog(prio, "%s", get_strbuf_str(&__buf)); \
+} while(0)
+
int sysfs_get_size (struct path *pp, unsigned long long * size);
int sysfs_check_holders(char * check_devt, char * new_devt);
bool sysfs_is_multipathed(struct path *pp, bool set_wwid);

View File

@ -0,0 +1,71 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 18:07:57 +0200
Subject: [PATCH] libmultipath: sysfs: cleanup file descriptors on
pthread_cancel()
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/sysfs.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c
index 9c84af70..64946385 100644
--- a/libmultipath/sysfs.c
+++ b/libmultipath/sysfs.c
@@ -49,7 +49,7 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_
{
const char *syspath;
char devpath[PATH_MAX];
- int fd;
+ long fd;
ssize_t size = -1;
if (!dev || !attr_name || !value || !value_len) {
@@ -74,6 +74,8 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_
__func__, devpath, strerror(errno));
return -errno;
}
+ pthread_cleanup_push(close_fd, (void *)fd);
+
size = read(fd, value, value_len);
if (size < 0) {
size = -errno;
@@ -90,7 +92,7 @@ static ssize_t __sysfs_attr_get_value(struct udev_device *dev, const char *attr_
size = strchop(value);
}
- close(fd);
+ pthread_cleanup_pop(1);
return size;
}
@@ -112,7 +114,7 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
{
const char *syspath;
char devpath[PATH_MAX];
- int fd;
+ long fd;
ssize_t size = -1;
if (!dev || !attr_name || !value || !value_len) {
@@ -138,6 +140,7 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
__func__, devpath, strerror(errno));
return -errno;
}
+ pthread_cleanup_push(close_fd, (void *)fd);
size = write(fd, value, value_len);
if (size < 0) {
@@ -148,7 +151,7 @@ ssize_t sysfs_attr_set_value(struct udev_device *dev, const char *attr_name,
condlog(3, "%s: underflow writing %zu bytes to %s. Wrote %zd bytes",
__func__, value_len, devpath, size);
- close(fd);
+ pthread_cleanup_pop(1);
return size;
}

View File

@ -0,0 +1,168 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 18:45:11 +0200
Subject: [PATCH] libmultipath, multipathd: log failure setting sysfs
attributes
Failure to set a sysfs attribute is worth noting, normally.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/configure.c | 18 ++++++++++++++---
multipathd/fpin_handlers.c | 11 +++++++++--
multipathd/main.c | 40 ++++++++++++++++++++++++++++++--------
3 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 0607dbac..4427f910 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -489,9 +489,15 @@ void trigger_partitions_udev_change(struct udev_device *dev,
devtype = udev_device_get_devtype(part);
if (devtype && !strcmp("partition", devtype)) {
+ ssize_t ret;
+
condlog(4, "%s: triggering %s event for %s", __func__,
action, syspath);
- sysfs_attr_set_value(part, "uevent", action, len);
+ ret = sysfs_attr_set_value(part, "uevent", action, len);
+ if (ret != len)
+ log_sysfs_attr_set_value(2, ret,
+ "%s: failed to trigger %s uevent",
+ syspath, action);
}
udev_device_unref(part);
}
@@ -510,6 +516,7 @@ trigger_path_udev_change(struct path *pp, bool is_mpath)
*/
const char *action = is_mpath ? "change" : "add";
const char *env;
+ ssize_t len, ret;
if (!pp->udev)
return;
@@ -536,8 +543,13 @@ trigger_path_udev_change(struct path *pp, bool is_mpath)
condlog(3, "triggering %s uevent for %s (is %smultipath member)",
action, pp->dev, is_mpath ? "" : "no ");
- sysfs_attr_set_value(pp->udev, "uevent",
- action, strlen(action));
+
+ len = strlen(action);
+ ret = sysfs_attr_set_value(pp->udev, "uevent", action, len);
+ if (ret != len)
+ log_sysfs_attr_set_value(2, ret,
+ "%s: failed to trigger %s uevent",
+ pp->dev, action);
trigger_partitions_udev_change(pp->udev, action,
strlen(action));
}
diff --git a/multipathd/fpin_handlers.c b/multipathd/fpin_handlers.c
index 384ae318..00195721 100644
--- a/multipathd/fpin_handlers.c
+++ b/multipathd/fpin_handlers.c
@@ -172,8 +172,15 @@ fpin_els_add_li_frame(struct fc_nl_event *fc_event)
/*Sets the rport port_state to marginal*/
static void fpin_set_rport_marginal(struct udev_device *rport_dev)
{
- sysfs_attr_set_value(rport_dev, "port_state",
- "Marginal", strlen("Marginal"));
+ static const char marginal[] = "Marginal";
+ ssize_t ret;
+
+ ret = sysfs_attr_set_value(rport_dev, "port_state",
+ marginal, sizeof(marginal) - 1);
+ if (ret != sizeof(marginal) - 1)
+ log_sysfs_attr_set_value(2, ret,
+ "%s: failed to set port_state to marginal",
+ udev_device_get_syspath(rport_dev));
}
/*Add the marginal devices info into the list*/
diff --git a/multipathd/main.c b/multipathd/main.c
index 68eca925..a160c824 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -911,14 +911,22 @@ rescan_path(struct udev_device *ud)
{
ud = udev_device_get_parent_with_subsystem_devtype(ud, "scsi",
"scsi_device");
- if (ud)
- sysfs_attr_set_value(ud, "rescan", "1", strlen("1"));
+ if (ud) {
+ ssize_t ret =
+ sysfs_attr_set_value(ud, "rescan", "1", strlen("1"));
+ if (ret != strlen("1"))
+ log_sysfs_attr_set_value(1, ret,
+ "%s: failed to trigger rescan",
+ udev_device_get_syspath(ud));
+ }
}
void
handle_path_wwid_change(struct path *pp, struct vectors *vecs)
{
struct udev_device *udd;
+ static const char add[] = "add";
+ ssize_t ret;
if (!pp || !pp->udev)
return;
@@ -929,8 +937,12 @@ handle_path_wwid_change(struct path *pp, struct vectors *vecs)
dm_fail_path(pp->mpp->alias, pp->dev_t);
}
rescan_path(udd);
- sysfs_attr_set_value(udd, "uevent", "add", strlen("add"));
+ ret = sysfs_attr_set_value(udd, "uevent", add, sizeof(add) - 1);
udev_device_unref(udd);
+ if (ret != sizeof(add) - 1)
+ log_sysfs_attr_set_value(1, ret,
+ "%s: failed to trigger add event",
+ pp->dev);
}
bool
@@ -2003,9 +2015,14 @@ partial_retrigger_tick(vector pathvec)
--pp->partial_retrigger_delay == 0) {
const char *msg = udev_device_get_is_initialized(pp->udev) ?
"change" : "add";
-
- sysfs_attr_set_value(pp->udev, "uevent", msg,
- strlen(msg));
+ ssize_t len = strlen(msg);
+ ssize_t ret = sysfs_attr_set_value(pp->udev, "uevent", msg,
+ len);
+
+ if (len != ret)
+ log_sysfs_attr_set_value(2, ret,
+ "%s: failed to trigger %s event",
+ pp->dev, msg);
}
}
}
@@ -2245,12 +2262,19 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks)
if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV) {
if (pp->retriggers < retrigger_tries) {
+ static const char change[] = "change";
+ ssize_t ret;
+
condlog(2, "%s: triggering change event to reinitialize",
pp->dev);
pp->initialized = INIT_REQUESTED_UDEV;
pp->retriggers++;
- sysfs_attr_set_value(pp->udev, "uevent", "change",
- strlen("change"));
+ ret = sysfs_attr_set_value(pp->udev, "uevent", change,
+ sizeof(change) - 1);
+ if (ret != sizeof(change) - 1)
+ log_sysfs_attr_set_value(1, ret,
+ "%s: failed to trigger change event",
+ pp->dev);
return 0;
} else {
condlog(1, "%s: not initialized after %d udev retriggers",

View File

@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 23:18:07 +0200
Subject: [PATCH] multipath tests: expect_condlog: skip depending on verbosity
otherwise we'll get failures if verbosity level is low.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
tests/test-log.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/test-log.c b/tests/test-log.c
index 14f25b9b..0c17cd96 100644
--- a/tests/test-log.c
+++ b/tests/test-log.c
@@ -6,6 +6,8 @@
#include <cmocka.h>
#include "log.h"
#include "test-log.h"
+#include "debug.h"
+
__attribute__((format(printf, 2, 0)))
void __wrap_dlog (int prio, const char * fmt, ...)
@@ -24,6 +26,8 @@ void __wrap_dlog (int prio, const char * fmt, ...)
void expect_condlog(int prio, char *string)
{
+ if (prio > MAX_VERBOSITY || prio > libmp_verbosity)
+ return;
expect_value(__wrap_dlog, prio, prio);
will_return(__wrap_dlog, string);
}

View File

@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 6 Jul 2022 11:15:27 +0200
Subject: [PATCH] multipath tests: __wrap_dlog: print log message
This makes it easier to analyze errors from __wrap_dlog().
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
tests/test-log.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test-log.c b/tests/test-log.c
index 0c17cd96..c1745872 100644
--- a/tests/test-log.c
+++ b/tests/test-log.c
@@ -20,6 +20,7 @@ void __wrap_dlog (int prio, const char * fmt, ...)
va_start(ap, fmt);
vsnprintf(buff, MAX_MSG_SIZE, fmt, ap);
va_end(ap);
+ fprintf(stderr, "%s(%d): %s", __func__, prio, buff);
expected = mock_ptr_type(char *);
assert_memory_equal(buff, expected, strlen(expected));
}

View File

@ -0,0 +1,538 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 5 Jul 2022 23:19:30 +0200
Subject: [PATCH] multipath tests: add sysfs test
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
tests/Makefile | 5 +-
tests/sysfs.c | 494 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 498 insertions(+), 1 deletion(-)
create mode 100644 tests/sysfs.c
diff --git a/tests/Makefile b/tests/Makefile
index d20ef236..95a99908 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -16,7 +16,7 @@ CFLAGS += $(BIN_CFLAGS) -Wno-unused-parameter $(W_MISSING_INITIALIZERS)
LIBDEPS += -L. -L$(mpathcmddir) -lmultipath -lmpathcmd -lcmocka
TESTS := uevent parser util dmevents hwtable blacklist unaligned vpd pgpolicy \
- alias directio valid devt mpathvalid strbuf
+ alias directio valid devt mpathvalid strbuf sysfs
HELPERS := test-lib.o test-log.o
.SILENT: $(TESTS:%=%.o)
@@ -70,6 +70,9 @@ ifneq ($(DIO_TEST_DEV),)
directio-test_LIBDEPS := -laio
endif
strbuf-test_OBJDEPS := ../libmultipath/strbuf.o
+sysfs-test_TESTDEPS := test-log.o
+sysfs-test_OBJDEPS := ../libmultipath/sysfs.o ../libmultipath/util.o
+sysfs-test_LIBDEPS := -ludev -lpthread -ldl
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $($*-test_FLAGS) -c -o $@ $<
diff --git a/tests/sysfs.c b/tests/sysfs.c
new file mode 100644
index 00000000..0ec135bf
--- /dev/null
+++ b/tests/sysfs.c
@@ -0,0 +1,494 @@
+/*
+ * Copyright (c) 2021 SUSE LLC
+ * SPDX-License-Identifier: GPL-2.0-only
+ */
+
+#define _GNU_SOURCE
+#include <stdbool.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <setjmp.h>
+#include <stdlib.h>
+#include <cmocka.h>
+#include <libudev.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "debug.h"
+#include "globals.c"
+#include "test-log.h"
+#include "sysfs.h"
+#include "util.h"
+
+#define TEST_FD 123
+
+char *__wrap_udev_device_get_syspath(struct udev_device *ud)
+{
+ char *val = mock_ptr_type(char *);
+
+ return val;
+}
+
+int __wrap_open(const char *pathname, int flags)
+{
+ int ret;
+
+ check_expected(pathname);
+ check_expected(flags);
+ ret = mock_type(int);
+ return ret;
+}
+
+ssize_t __wrap_read(int fd, void *buf, size_t count)
+{
+ ssize_t ret;
+ char *val;
+
+ check_expected(fd);
+ check_expected(count);
+ ret = mock_type(int);
+ val = mock_ptr_type(char *);
+ if (ret >= (ssize_t)count)
+ ret = count;
+ if (ret >= 0 && val) {
+ fprintf(stderr, "%s: '%s' -> %zd\n", __func__, val, ret);
+ memcpy(buf, val, ret);
+ }
+ return ret;
+}
+
+ssize_t __wrap_write(int fd, void *buf, size_t count)
+{
+ ssize_t ret;
+
+ check_expected(fd);
+ check_expected(count);
+ ret = mock_type(int);
+ if (ret >= (ssize_t)count)
+ ret = count;
+ return ret;
+}
+
+int __real_close(int fd);
+int __wrap_close(int fd) {
+ if (fd != TEST_FD)
+ return __real_close(fd);
+ return mock_type(int);
+}
+
+static int setup(void **state)
+{
+ udev = udev_new();
+ return 0;
+}
+
+static int teardown(void **state)
+{
+ udev_unref(udev);
+ return 0;
+}
+
+static void expect_sagv_invalid(void)
+{
+ expect_condlog(1, "__sysfs_attr_get_value: invalid parameters");
+}
+
+static void test_sagv_invalid(void **state)
+{
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_attr_get_value(NULL, NULL, NULL, 0), -EINVAL);
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_bin_attr_get_value(NULL, NULL, NULL, 0), -EINVAL);
+
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_attr_get_value(NULL, (void *)state, (void *)state, 1),
+ -EINVAL);
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_bin_attr_get_value(NULL, (void *)state, (void *)state, 1),
+ -EINVAL);
+
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_attr_get_value((void *)state, NULL, (void *)state, 1),
+ -EINVAL);
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, NULL, (void *)state, 1),
+ -EINVAL);
+
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_attr_get_value((void *)state, (void *)state, NULL, 1),
+ -EINVAL);
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, (void *)state, NULL, 1),
+ -EINVAL);
+
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_attr_get_value((void *)state, (void *)state,
+ (void *)state, 0), -EINVAL);
+ expect_sagv_invalid();
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, (void *)state,
+ (void *)state, 0), -EINVAL);
+}
+
+static void test_sagv_bad_udev(void **state)
+{
+ will_return(__wrap_udev_device_get_syspath, NULL);
+ expect_condlog(3, "__sysfs_attr_get_value: invalid udevice");
+ assert_int_equal(sysfs_attr_get_value((void *)state, (void *)state,
+ (void *)state, 1), -EINVAL);
+
+ will_return(__wrap_udev_device_get_syspath, NULL);
+ expect_condlog(3, "__sysfs_attr_get_value: invalid udevice");
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, (void *)state,
+ (void *)state, 1), -EINVAL);
+}
+
+static void test_sagv_bad_snprintf(void **state)
+{
+ char longstr[PATH_MAX + 1];
+ char buf[1];
+
+ memset(longstr, 'a', sizeof(longstr) - 1);
+ longstr[sizeof(longstr) - 1] = '\0';
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(3, "__sysfs_attr_get_value: devpath overflow");
+ assert_int_equal(sysfs_attr_get_value((void *)state, longstr,
+ buf, sizeof(buf)), -EOVERFLOW);
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(3, "__sysfs_attr_get_value: devpath overflow");
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, longstr,
+ (unsigned char *)buf, sizeof(buf)),
+ -EOVERFLOW);
+}
+
+static void test_sagv_open_fail(void **state)
+{
+ char buf[1];
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ errno = ENOENT;
+ will_return(__wrap_open, -1);
+ expect_condlog(3, "__sysfs_attr_get_value: attribute '/foo/bar' can not be opened");
+ assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
+ buf, sizeof(buf)), -ENOENT);
+}
+
+static void test_sagv_read_fail(void **state)
+{
+ char buf[1];
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_read, fd, TEST_FD);
+ expect_value(__wrap_read, count, sizeof(buf));
+ errno = EISDIR;
+ will_return(__wrap_read, -1);
+ will_return(__wrap_read, NULL);
+ expect_condlog(3, "__sysfs_attr_get_value: read from /foo/bar failed:");
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
+ buf, sizeof(buf)), -EISDIR);
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/baz'");
+ expect_string(__wrap_open, pathname, "/foo/baz");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_read, fd, TEST_FD);
+ expect_value(__wrap_read, count, sizeof(buf));
+ errno = EPERM;
+ will_return(__wrap_read, -1);
+ will_return(__wrap_read, NULL);
+ expect_condlog(3, "__sysfs_attr_get_value: read from /foo/baz failed:");
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, "baz",
+ (unsigned char *)buf, sizeof(buf)),
+ -EPERM);
+
+}
+
+static void _test_sagv_read(void **state, unsigned int bufsz)
+{
+ char buf[16];
+ char input[] = "01234567";
+ unsigned int n, trunc;
+
+ assert_in_range(bufsz, 1, sizeof(buf));
+ memset(buf, '.', sizeof(buf));
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_read, fd, TEST_FD);
+ expect_value(__wrap_read, count, bufsz);
+ will_return(__wrap_read, sizeof(input) - 1);
+ will_return(__wrap_read, input);
+
+ /* If the buffer is too small, input will be truncated by a 0 byte */
+ if (bufsz <= sizeof(input) - 1) {
+ n = bufsz;
+ trunc = 1;
+ expect_condlog(3, "__sysfs_attr_get_value: overflow reading from /foo/bar");
+ } else {
+ n = sizeof(input) - 1;
+ trunc = 0;
+ }
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
+ buf, bufsz), n);
+ assert_memory_equal(buf, input, n - trunc);
+ assert_int_equal(buf[n - trunc], '\0');
+
+ /* Binary input is not truncated */
+ memset(buf, '.', sizeof(buf));
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/baz'");
+ expect_string(__wrap_open, pathname, "/foo/baz");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_read, fd, TEST_FD);
+ expect_value(__wrap_read, count, bufsz);
+ will_return(__wrap_read, sizeof(input) - 1);
+ will_return(__wrap_read, input);
+ will_return(__wrap_close, 0);
+ n = bufsz < sizeof(input) - 1 ? bufsz : sizeof(input) - 1;
+ assert_int_equal(sysfs_bin_attr_get_value((void *)state, "baz",
+ (unsigned char *)buf,
+ bufsz),
+ n);
+ assert_memory_equal(buf, input, n);
+}
+
+static void test_sagv_read_overflow_8(void **state)
+{
+ _test_sagv_read(state, 8);
+}
+
+static void test_sagv_read_overflow_4(void **state)
+{
+ _test_sagv_read(state, 4);
+}
+
+static void test_sagv_read_overflow_1(void **state)
+{
+ _test_sagv_read(state, 1);
+}
+
+static void test_sagv_read_good_9(void **state)
+{
+ _test_sagv_read(state, 9);
+}
+
+static void test_sagv_read_good_15(void **state)
+{
+ _test_sagv_read(state, 15);
+}
+
+static void _test_sagv_read_zeroes(void **state, unsigned int bufsz)
+{
+ char buf[16];
+ char input[] = { '\0','\0','\0','\0','\0','\0','\0','\0' };
+ unsigned int n;
+
+ assert_in_range(bufsz, 1, sizeof(buf));
+ memset(buf, '.', sizeof(buf));
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_RDONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_read, fd, TEST_FD);
+ expect_value(__wrap_read, count, bufsz);
+ will_return(__wrap_read, sizeof(input) - 1);
+ will_return(__wrap_read, input);
+
+ if (bufsz <= sizeof(input) - 1) {
+ n = bufsz;
+ expect_condlog(3, "__sysfs_attr_get_value: overflow reading from /foo/bar");
+ } else
+ n = 0;
+
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_attr_get_value((void *)state, "bar",
+ buf, bufsz), n);
+
+ /*
+ * The return value of sysfs_attr_get_value ignores zero bytes,
+ * but the read data should have been copied to the buffer
+ */
+ assert_memory_equal(buf, input, n == 0 ? bufsz : n);
+}
+
+static void test_sagv_read_zeroes_4(void **state)
+{
+ _test_sagv_read_zeroes(state, 4);
+}
+
+static void expect_sasv_invalid(void)
+{
+ expect_condlog(1, "sysfs_attr_set_value: invalid parameters");
+}
+
+static void test_sasv_invalid(void **state)
+{
+ expect_sasv_invalid();
+ assert_int_equal(sysfs_attr_set_value(NULL, NULL, NULL, 0), -EINVAL);
+
+ expect_sasv_invalid();
+ assert_int_equal(sysfs_attr_set_value(NULL, (void *)state, (void *)state, 1),
+ -EINVAL);
+
+ expect_sasv_invalid();
+ assert_int_equal(sysfs_attr_set_value((void *)state, NULL, (void *)state, 1),
+ -EINVAL);
+
+ expect_sasv_invalid();
+ assert_int_equal(sysfs_attr_set_value((void *)state, (void *)state, NULL, 1),
+ -EINVAL);
+
+ expect_sasv_invalid();
+ assert_int_equal(sysfs_attr_set_value((void *)state, (void *)state,
+ (void *)state, 0), -EINVAL);
+}
+
+static void test_sasv_bad_udev(void **state)
+{
+ will_return(__wrap_udev_device_get_syspath, NULL);
+ expect_condlog(3, "sysfs_attr_set_value: invalid udevice");
+ assert_int_equal(sysfs_attr_set_value((void *)state, (void *)state,
+ (void *)state, 1), -EINVAL);
+}
+
+static void test_sasv_bad_snprintf(void **state)
+{
+ char longstr[PATH_MAX + 1];
+ char buf[1];
+
+ memset(longstr, 'a', sizeof(longstr) - 1);
+ longstr[sizeof(longstr) - 1] = '\0';
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(3, "sysfs_attr_set_value: devpath overflow");
+ assert_int_equal(sysfs_attr_set_value((void *)state, longstr,
+ buf, sizeof(buf)), -EOVERFLOW);
+}
+
+static void test_sasv_open_fail(void **state)
+{
+ char buf[1];
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_WRONLY);
+ errno = EPERM;
+ will_return(__wrap_open, -1);
+ expect_condlog(3, "sysfs_attr_set_value: attribute '/foo/bar' can not be opened");
+ assert_int_equal(sysfs_attr_set_value((void *)state, "bar",
+ buf, sizeof(buf)), -EPERM);
+}
+
+static void test_sasv_write_fail(void **state)
+{
+ char buf[1];
+
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_WRONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_write, fd, TEST_FD);
+ expect_value(__wrap_write, count, sizeof(buf));
+ errno = EISDIR;
+ will_return(__wrap_write, -1);
+ expect_condlog(3, "sysfs_attr_set_value: write to /foo/bar failed:");
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_attr_set_value((void *)state, "bar",
+ buf, sizeof(buf)), -EISDIR);
+
+}
+
+static void _test_sasv_write(void **state, unsigned int n_written)
+{
+ char buf[8];
+
+ assert_in_range(n_written, 0, sizeof(buf));
+ will_return(__wrap_udev_device_get_syspath, "/foo");
+ expect_condlog(4, "open '/foo/bar'");
+ expect_string(__wrap_open, pathname, "/foo/bar");
+ expect_value(__wrap_open, flags, O_WRONLY);
+ will_return(__wrap_open, TEST_FD);
+ expect_value(__wrap_write, fd, TEST_FD);
+ expect_value(__wrap_write, count, sizeof(buf));
+ will_return(__wrap_write, n_written);
+
+ if (n_written < sizeof(buf))
+ expect_condlog(3, "sysfs_attr_set_value: underflow writing");
+ will_return(__wrap_close, 0);
+ assert_int_equal(sysfs_attr_set_value((void *)state, "bar",
+ buf, sizeof(buf)),
+ n_written);
+}
+
+static void test_sasv_write_0(void **state)
+{
+ _test_sasv_write(state, 0);
+}
+
+static void test_sasv_write_4(void **state)
+{
+ _test_sasv_write(state, 4);
+}
+
+static void test_sasv_write_7(void **state)
+{
+ _test_sasv_write(state, 7);
+}
+
+static void test_sasv_write_8(void **state)
+{
+ _test_sasv_write(state, 8);
+}
+
+static int test_sysfs(void)
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(test_sagv_invalid),
+ cmocka_unit_test(test_sagv_bad_udev),
+ cmocka_unit_test(test_sagv_bad_snprintf),
+ cmocka_unit_test(test_sagv_open_fail),
+ cmocka_unit_test(test_sagv_read_fail),
+ cmocka_unit_test(test_sagv_read_overflow_1),
+ cmocka_unit_test(test_sagv_read_overflow_4),
+ cmocka_unit_test(test_sagv_read_overflow_8),
+ cmocka_unit_test(test_sagv_read_good_9),
+ cmocka_unit_test(test_sagv_read_good_15),
+ cmocka_unit_test(test_sagv_read_zeroes_4),
+ cmocka_unit_test(test_sasv_invalid),
+ cmocka_unit_test(test_sasv_bad_udev),
+ cmocka_unit_test(test_sasv_bad_snprintf),
+ cmocka_unit_test(test_sasv_open_fail),
+ cmocka_unit_test(test_sasv_write_fail),
+ cmocka_unit_test(test_sasv_write_0),
+ cmocka_unit_test(test_sasv_write_4),
+ cmocka_unit_test(test_sasv_write_7),
+ cmocka_unit_test(test_sasv_write_8),
+ };
+
+ return cmocka_run_group_tests(tests, setup, teardown);
+}
+
+int main(void)
+{
+ int ret = 0;
+
+ init_test_verbosity(4);
+ ret += test_sysfs();
+ return ret;
+}

View File

@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 6 Jul 2022 12:45:33 +0200
Subject: [PATCH] libmultipath.version: bump version for sysfs accessors
Formally, the ABI is still the same, but the semantics of the
return value have changed.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/libmultipath.version | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libmultipath/libmultipath.version b/libmultipath/libmultipath.version
index b3690ac0..c1d9b156 100644
--- a/libmultipath/libmultipath.version
+++ b/libmultipath/libmultipath.version
@@ -207,7 +207,6 @@ global:
strchop;
strlcpy;
sync_map_state;
- sysfs_attr_set_value;
sysfs_get_size;
sysfs_is_multipathed;
timespeccmp;
@@ -264,8 +263,13 @@ global:
/* foreign */
free_scandir_result;
- sysfs_attr_get_value;
local:
*;
};
+
+LIBMULTIPATH_16.0.0 {
+global:
+ sysfs_attr_set_value;
+ sysfs_attr_get_value;
+};

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com> From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 10 May 2022 14:17:22 -0500 Date: Tue, 7 Jun 2022 17:45:01 -0500
Subject: [PATCH] libmultipath: unset detect_checker for clariion / Unity Subject: [PATCH] libmultipath: unset detect_checker for clariion / Unity
arrays arrays
@ -12,6 +12,7 @@ checker.
Cc: vincent.chen1@dell.com Cc: vincent.chen1@dell.com
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
--- ---
libmultipath/hwtable.c | 1 + libmultipath/hwtable.c | 1 +
1 file changed, 1 insertion(+) 1 file changed, 1 insertion(+)

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josh Soref <2119212+jsoref@users.noreply.github.com>
Date: Sun, 31 Jul 2022 13:11:15 -0400
Subject: [PATCH] libmultipath: spelling: cplusplus
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Reviewed-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmpathvalid/mpath_valid.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libmpathvalid/mpath_valid.h b/libmpathvalid/mpath_valid.h
index ed06196e..ec2f9392 100644
--- a/libmpathvalid/mpath_valid.h
+++ b/libmpathvalid/mpath_valid.h
@@ -20,7 +20,7 @@
#ifndef LIB_MPATH_VALID_H
#define LIB_MPATH_VALID_H
-#ifdef __cpluscplus
+#ifdef __cplusplus
extern "C" {
#endif

View File

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josh Soref <2119212+jsoref@users.noreply.github.com>
Date: Sun, 31 Jul 2022 13:11:12 -0400
Subject: [PATCH] libmultipath: spelling: ascii
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/prioritizers/alua_spc3.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libmultipath/prioritizers/alua_spc3.h b/libmultipath/prioritizers/alua_spc3.h
index 08e992bd..e1a6c071 100644
--- a/libmultipath/prioritizers/alua_spc3.h
+++ b/libmultipath/prioritizers/alua_spc3.h
@@ -143,7 +143,7 @@ inquiry_data_get_tpgs(struct inquiry_data *id)
*-----------------------------------------------------------------------------
*/
#define CODESET_BINARY 0x1
-#define CODESET_ACSII 0x2
+#define CODESET_ASCII 0x2
#define CODESET_UTF8 0x3
#define ASSOCIATION_UNIT 0x0

View File

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josh Soref <2119212+jsoref@users.noreply.github.com>
Date: Sun, 31 Jul 2022 13:11:22 -0400
Subject: [PATCH] libmultipath: spelling: progress
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/nvme/linux/nvme.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libmultipath/nvme/linux/nvme.h b/libmultipath/nvme/linux/nvme.h
index a6975549..9fc2ae7f 100644
--- a/libmultipath/nvme/linux/nvme.h
+++ b/libmultipath/nvme/linux/nvme.h
@@ -1035,7 +1035,7 @@ enum {
NVME_SANITIZE_LOG_STATUS_MASK = 0x0007,
NVME_SANITIZE_LOG_NEVER_SANITIZED = 0x0000,
NVME_SANITIZE_LOG_COMPLETED_SUCCESS = 0x0001,
- NVME_SANITIZE_LOG_IN_PROGESS = 0x0002,
+ NVME_SANITIZE_LOG_IN_PROGRESS = 0x0002,
NVME_SANITIZE_LOG_COMPLETED_FAILED = 0x0003,
NVME_SANITIZE_LOG_ND_COMPLETED_SUCCESS = 0x0004,
};

View File

@ -0,0 +1,599 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josh Soref <2119212+jsoref@users.noreply.github.com>
Date: Sun, 31 Jul 2022 13:17:53 -0400
Subject: [PATCH] multipath-tools: spelling fixes
Spelling errors detected by the GitHub check-spelling action:
https://github.com/marketplace/actions/check-spelling
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/foreign.yaml | 2 +-
kpartx/crc32.c | 2 +-
kpartx/gpt.c | 2 +-
libdmmp/libdmmp_path.c | 2 +-
libmpathcmd/mpath_cmd.h | 2 +-
libmpathpersist/mpath_persist_int.c | 2 +-
libmpathvalid/mpath_valid.h | 4 ++--
libmultipath/checkers/directio.c | 2 +-
libmultipath/config.h | 2 +-
libmultipath/configure.c | 2 +-
libmultipath/discovery.c | 2 +-
libmultipath/nvme/nvme.h | 2 +-
libmultipath/prioritizers/datacore.c | 4 ++--
libmultipath/prioritizers/hds.c | 2 +-
libmultipath/prioritizers/path_latency.c | 4 ++--
libmultipath/strbuf.h | 4 ++--
libmultipath/structs_vec.c | 2 +-
libmultipath/uevent.c | 2 +-
libmultipath/valid.h | 2 +-
mpathpersist/main.c | 2 +-
multipath/multipath.conf.5 | 14 +++++++-------
multipathd/main.c | 10 +++++-----
tests/directio.c | 2 +-
tests/hwtable.c | 10 +++++-----
tests/mpathvalid.c | 2 +-
tests/pgpolicy.c | 2 +-
tests/valid.c | 4 ++--
third-party/valgrind/valgrind.h | 8 ++++----
28 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/.github/workflows/foreign.yaml b/.github/workflows/foreign.yaml
index e9ffd3d8..32915186 100644
--- a/.github/workflows/foreign.yaml
+++ b/.github/workflows/foreign.yaml
@@ -56,7 +56,7 @@ jobs:
- name: enable foreign arch
run: sudo docker run --rm --privileged multiarch/qemu-user-static:register --reset
- name: run tests
- # Github actions doesn't support referencing docker images with
+ # GitHub actions doesn't support referencing docker images with
# context variables. Workaround: use mosteo-actions/docker-run action
# See https://github.community/t/expressions-in-docker-uri/16271
uses: mosteo-actions/docker-run@v1
diff --git a/kpartx/crc32.c b/kpartx/crc32.c
index e688f8e9..df6c6878 100644
--- a/kpartx/crc32.c
+++ b/kpartx/crc32.c
@@ -290,7 +290,7 @@ uint32_t attribute((pure)) crc32_be(uint32_t crc, unsigned char const *p, size_t
* the end, so we have to add 32 extra cycles shifting in zeros at the
* end of every message,
*
- * So the standard trick is to rearrage merging in the next_input_bit()
+ * So the standard trick is to rearrange merging in the next_input_bit()
* until the moment it's needed. Then the first 32 cycles can be precomputed,
* and merging in the final 32 zero bits to make room for the CRC can be
* skipped entirely.
diff --git a/kpartx/gpt.c b/kpartx/gpt.c
index 34a910cf..47d8743e 100644
--- a/kpartx/gpt.c
+++ b/kpartx/gpt.c
@@ -357,7 +357,7 @@ is_gpt_valid(int fd, uint64_t lba,
__le32_to_cpu((*gpt)->num_partition_entries) *
__le32_to_cpu((*gpt)->sizeof_partition_entry));
if (crc != __le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
- // printf("GUID Partitition Entry Array CRC check failed.\n");
+ // printf("GUID Partition Entry Array CRC check failed.\n");
free(*gpt);
*gpt = NULL;
free(*ptes);
diff --git a/libdmmp/libdmmp_path.c b/libdmmp/libdmmp_path.c
index 47a2162c..21714b15 100644
--- a/libdmmp/libdmmp_path.c
+++ b/libdmmp/libdmmp_path.c
@@ -28,7 +28,7 @@
#include "libdmmp_private.h"
#define _DMMP_SHOW_PS_INDEX_BLK_NAME 0
-#define _DMMP_SHOW_PS_INDEX_SATAUS 1
+#define _DMMP_SHOW_PS_INDEX_STATUS 1
#define _DMMP_SHOW_PS_INDEX_WWID 2
#define _DMMP_SHOW_PS_INDEX_PGID 3
diff --git a/libmpathcmd/mpath_cmd.h b/libmpathcmd/mpath_cmd.h
index 30838b02..0c293c71 100644
--- a/libmpathcmd/mpath_cmd.h
+++ b/libmpathcmd/mpath_cmd.h
@@ -65,7 +65,7 @@ int mpath_connect(void);
/*
* DESCRIPTION:
* Disconnect from the multipathd daemon. This function must be
- * run after after processing all the multipath commands.
+ * run after processing all the multipath commands.
*
* RETURNS:
* 0 on success. -1 on failure (with errno set).
diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c
index e34fc32d..6924b379 100644
--- a/libmpathpersist/mpath_persist_int.c
+++ b/libmpathpersist/mpath_persist_int.c
@@ -601,7 +601,7 @@ static int mpath_prout_rel(struct multipath *mpp,int rq_servact, int rq_scope,
if (get_be64(mpp->reservation_key) &&
memcmp(pr_buff->prin_descriptor.prin_readfd.descriptors[i]->key,
&mpp->reservation_key, 8)){
- /*register with tarnsport id*/
+ /*register with transport id*/
memset(pamp, 0, length);
pamp->trnptid_list[0] = pptr;
memset (pamp->trnptid_list[0], 0, sizeof (struct transportid));
diff --git a/libmpathvalid/mpath_valid.h b/libmpathvalid/mpath_valid.h
index ec2f9392..3e34b1fd 100644
--- a/libmpathvalid/mpath_valid.h
+++ b/libmpathvalid/mpath_valid.h
@@ -112,7 +112,7 @@ int mpathvalid_exit(void);
* RETURNS:
* MPATH_STRICT, MPATH_SMART, MPATH_GREEDY, or MPATH_MODE_ERROR
*
- * MPATH_STRICT = find_multiapths (yes|on|no|off)
+ * MPATH_STRICT = find_multipaths (yes|on|no|off)
* MPATH_SMART = find_multipaths smart
* MPATH_GREEDY = find_multipaths greedy
* MPATH_MODE_ERROR = multipath configuration not initialized
@@ -126,7 +126,7 @@ unsigned int mpathvalid_get_mode(void);
* potentially claimed (MPATH_IS_VALID, MPATH_IS_VALID_NO_CHECK,
* or MPATH_IS_MAYBE_VALID) and wwid is not NULL, then *wiid will
* be set to point to the wwid of device. If set, *wwid must be
- * freed by the caller. path_wwids is an obptional parameter that
+ * freed by the caller. path_wwids is an optional parameter that
* points to an array of wwids, that were returned from previous
* calls to mpathvalid_is_path(). These are wwids of existing
* devices that are or potentially are claimed by device-mapper
diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c
index bc7b7be5..a326e37b 100644
--- a/libmultipath/checkers/directio.c
+++ b/libmultipath/checkers/directio.c
@@ -124,7 +124,7 @@ remove_aio_group(struct aio_group *aio_grp)
/* If an aio_group is completely full of orphans, then no checkers can
* use it, which means that no checkers can clear out the orphans. To
- * avoid keeping the useless group around, simply remove remove the
+ * avoid keeping the useless group around, simply remove the
* group */
static void
check_orphaned_group(struct aio_group *aio_grp)
diff --git a/libmultipath/config.h b/libmultipath/config.h
index 36d40157..fdcdff0a 100644
--- a/libmultipath/config.h
+++ b/libmultipath/config.h
@@ -248,7 +248,7 @@ struct config {
* libmultipath calls. If an application wants to keep using the
* udev variable after calling libmultipath_exit(), it should have taken
* an additional reference on it beforehand. This is the case e.g.
- * after initiazing udev with udev_new().
+ * after initializing udev with udev_new().
*/
extern struct udev *udev;
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 4427f910..8af7cd79 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -397,7 +397,7 @@ int setup_map(struct multipath *mpp, char **params, struct vectors *vecs)
* into a mp->params strings to feed the device-mapper
*/
if (assemble_map(mpp, params)) {
- condlog(0, "%s: problem assembing map", mpp->alias);
+ condlog(0, "%s: problem assembling map", mpp->alias);
return 1;
}
return 0;
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index ee290093..15560f8c 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1344,7 +1344,7 @@ parse_vpd_c0_hp3par(const unsigned char *in, size_t in_len,
condlog(3, "HP/3PAR vendor specific VPD page length too short: %zu", in_len);
return -EINVAL;
}
- if (in[4] <= 3) /* revision must be > 3 to have Vomlume Name */
+ if (in[4] <= 3) /* revision must be > 3 to have Volume Name */
return -ENODATA;
len = get_unaligned_be32(&in[40]);
if (len > out_len || len + 44 > in_len) {
diff --git a/libmultipath/nvme/nvme.h b/libmultipath/nvme/nvme.h
index 7e0278b5..57f82a31 100644
--- a/libmultipath/nvme/nvme.h
+++ b/libmultipath/nvme/nvme.h
@@ -224,7 +224,7 @@ char *nvme_char_from_block(char *block);
* Notes: This function does not care about transport so that the offset is
* not going to be checked inside of this function for the unsupported fields
* in a specific transport. For example, BPMBL(Boot Partition Memory Buffer
- * Location) register is not supported by fabrics, but it can be chcked here.
+ * Location) register is not supported by fabrics, but it can be checked here.
*/
static inline bool is_64bit_reg(__u32 offset)
{
diff --git a/libmultipath/prioritizers/datacore.c b/libmultipath/prioritizers/datacore.c
index 02dc2e27..d1d473d4 100644
--- a/libmultipath/prioritizers/datacore.c
+++ b/libmultipath/prioritizers/datacore.c
@@ -1,6 +1,6 @@
/*
* (C) 2010 Christophe Varoqui
- * (C) 2009 Dembach Goo Infromatik GmbH & Co KG
+ * (C) 2009 Dembach Goo Informatik GmbH & Co KG
* Manon Goo <manon.goo@dg-i.net>
*
* datacore.c
@@ -10,7 +10,7 @@
* Matthias Rudolph <matthias.rudolph@hds.com>
*
* This work is made available on the basis of the
- * GPLv2 for detials see <http://www.gnu.org/licenses/>.
+ * GPLv2 for details see <http://www.gnu.org/licenses/>.
*
* Manon Goo 2009
*
diff --git a/libmultipath/prioritizers/hds.c b/libmultipath/prioritizers/hds.c
index 88cac5f0..d569f2d7 100644
--- a/libmultipath/prioritizers/hds.c
+++ b/libmultipath/prioritizers/hds.c
@@ -32,7 +32,7 @@
* Half of the LUNs are accessed via one HBA/storage controller and the other
* half via the other HBA/storage controller.
*
- * In cluster environmemnts (RAC) it also guarantees that all cluster nodes have
+ * In cluster environments (RAC) it also guarantees that all cluster nodes have
* access to the LDEVs via the same controller.
*
* You can run the prioritizer manually in verbose mode:
diff --git a/libmultipath/prioritizers/path_latency.c b/libmultipath/prioritizers/path_latency.c
index e155f6dc..2f5be9b9 100644
--- a/libmultipath/prioritizers/path_latency.c
+++ b/libmultipath/prioritizers/path_latency.c
@@ -64,7 +64,7 @@ static int prepare_directio_read(int fd, int *blksz, char **pbuf,
long flags;
if (ioctl(fd, BLKBSZGET, blksz) < 0) {
- pp_pl_log(3,"catnnot get blocksize, set default");
+ pp_pl_log(3,"cannot get blocksize, set default");
*blksz = DEF_BLK_SIZE;
}
if (posix_memalign((void **)pbuf, pgsize, *blksz))
@@ -193,7 +193,7 @@ out:
}
/*
- * Do not scale the prioriy in a certain range such as [0, 1024]
+ * Do not scale the priority in a certain range such as [0, 1024]
* because scaling will eliminate the effect of base_num.
*/
int calcPrio(double lg_avglatency, double lg_maxavglatency,
diff --git a/libmultipath/strbuf.h b/libmultipath/strbuf.h
index 41d7d54f..31ab519a 100644
--- a/libmultipath/strbuf.h
+++ b/libmultipath/strbuf.h
@@ -159,7 +159,7 @@ int fill_strbuf(struct strbuf *buf, char c, int slen);
*
* Appends the given string to @strbuf, with leading and trailing double
* quotes (") added, expanding @strbuf's size as necessary. Any double quote
- * characters (") in the string are transformed to double double quotes ("").
+ * characters (") in the string are transformed to a pair of double quotes ("").
* If the function returns an error, @strbuf is unchanged.
*/
int append_strbuf_quoted(struct strbuf *buf, const char *str);
@@ -171,7 +171,7 @@ int append_strbuf_quoted(struct strbuf *buf, const char *str);
* @returns: number of appended characters if successful, (excluding
* terminating '\0'); negative error code otherwise
*
- * Appends the the arguments following @fmt, formatted as in printf(), to
+ * Appends the arguments following @fmt, formatted as in printf(), to
* @strbuf, expanding @strbuf's size as necessary. The function makes sure that
* the output @strbuf is always 0-terminated.
* If the function returns an error, @strbuf is unchanged.
diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index a69f0643..645896c6 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -205,7 +205,7 @@ static bool update_pathvec_from_dm(vector pathvec, struct multipath *mpp,
continue;
/*
- * At this point, pp->udev is valid and and pp->wwid
+ * At this point, pp->udev is valid and pp->wwid
* is the best we could get
*/
if (*pp->wwid && strcmp(mpp->wwid, pp->wwid)) {
diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 5793af94..57447ca0 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -373,7 +373,7 @@ uevent_filter(struct uevent *later, struct uevent_filter_state *st)
list_for_some_entry_reverse_safe(earlier, tmp, &later->node, &st->uevq, node) {
/*
- * filter unnessary earlier uevents
+ * filter unnecessary earlier uevents
* by the later uevent
*/
if (!list_empty(&earlier->merge_node)) {
diff --git a/libmultipath/valid.h b/libmultipath/valid.h
index ce1c7cbf..731e6eff 100644
--- a/libmultipath/valid.h
+++ b/libmultipath/valid.h
@@ -23,7 +23,7 @@
* already.
* PATH_IS_VALID is returned by is_path_valid, when the path is
* valid only if it hasn't been released to systemd already.
- * PATH_IS_MAYBE_VALID is returned when the the path would be valid
+ * PATH_IS_MAYBE_VALID is returned when the path would be valid
* if other paths with the same wwid existed. It is up to the caller
* to check for these other paths.
*/
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
index 4bdd55c2..894e8c94 100644
--- a/mpathpersist/main.c
+++ b/mpathpersist/main.c
@@ -480,7 +480,7 @@ static int handle_args(int argc, char * argv[], int nline)
}
if ((verbose > 2) && num_transportids)
{
- fprintf (stderr, "number of tranport-ids decoded from "
+ fprintf (stderr, "number of transport-ids decoded from "
"command line : %d\n", num_transportids);
}
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index c2d34f18..853e0feb 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -455,7 +455,7 @@ precedence. See KNOWN ISSUES.
(Since kernel 2.6.38) Number of msecs before pg_init retry, it must be between 0 and 60000.
.TP
.I queue_mode <mode>
-(Since kernel 4.8) Select the the queueing mode per multipath device.
+(Since kernel 4.8) Select the queueing mode per multipath device.
<mode> can be \fIbio\fR, \fIrq\fR or \fImq\fR, which corresponds to
bio-based, request-based, and block-multiqueue (blk-mq) request-based,
respectively.
@@ -935,7 +935,7 @@ This option is not supported any more. The value is ignored.
.B san_path_err_threshold
If set to a value greater than 0, multipathd will watch paths and check how many
times a path has been failed due to errors.If the number of failures on a particular
-path is greater then the san_path_err_threshold, then the path will not reinstate
+path is greater than the san_path_err_threshold, then the path will not reinstate
till san_path_err_recovery_time. These path failures should occur within a
san_path_err_forget_rate checks, if not we will consider the path is good enough
to reinstantate. See "Shaky paths detection" below.
@@ -949,7 +949,7 @@ The default is: \fBno\fR
.B san_path_err_forget_rate
If set to a value greater than 0, multipathd will check whether the path failures
has exceeded the san_path_err_threshold within this many checks i.e
-san_path_err_forget_rate . If so we will not reinstante the path till
+san_path_err_forget_rate . If so we will not reinstate the path till
san_path_err_recovery_time. See "Shaky paths detection" below.
.RS
.TP
@@ -962,7 +962,7 @@ The default is: \fBno\fR
If set to a value greater than 0, multipathd will make sure that when path failures
has exceeded the san_path_err_threshold within san_path_err_forget_rate then the path
will be placed in failed state for san_path_err_recovery_time duration.Once san_path_err_recovery_time
-has timeout we will reinstante the failed path .
+has timeout we will reinstate the failed path .
san_path_err_recovery_time value should be in secs.
See "Shaky paths detection" below.
.RS
@@ -1000,7 +1000,7 @@ If the rate of IO error on a particular path is greater than the
\fImarginal_path_err_rate_threshold\fR, then the path will not reinstate for
\fImarginal_path_err_recheck_gap_time\fR seconds unless there is only one
active path. After \fImarginal_path_err_recheck_gap_time\fR expires, the path
-will be requeueed for rechecking. If checking result is good enough, the
+will be requeued for rechecking. If checking result is good enough, the
path will be reinstated. See "Shaky paths detection" below.
.RS
.TP
@@ -1031,7 +1031,7 @@ value, the failed path of which the IO error rate is larger than
\fImarginal_path_err_rate_threshold\fR will be kept in failed state for
\fImarginal_path_err_recheck_gap_time\fR seconds. When
\fImarginal_path_err_recheck_gap_time\fR seconds expires, the path will be
-requeueed for checking. If checking result is good enough, the path will be
+requeued for checking. If checking result is good enough, the path will be
reinstated, or else it will keep failed. See "Shaky paths detection" below.
.RS
.TP
@@ -1379,7 +1379,7 @@ The protocol that a path is using can be viewed by running
\fBmultipathd show paths format "%d %P"\fR
.RE
.LP
-For every device, these 5 blacklist criteria are evaluated in the the order
+For every device, these 5 blacklist criteria are evaluated in the order
"property, dev\%node, device, protocol, wwid". If a device turns out to be
blacklisted by any criterion, it's excluded from handling by multipathd, and
the later criteria aren't evaluated any more. For each
diff --git a/multipathd/main.c b/multipathd/main.c
index a160c824..defee10a 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -583,7 +583,7 @@ retry:
if (mpp->prflag) {
vector_foreach_slot(mpp->paths, pp, i) {
if ((pp->state == PATH_UP) || (pp->state == PATH_GHOST)) {
- /* persistent reseravtion check*/
+ /* persistent reservation check*/
mpath_pr_event_handle(pp);
}
}
@@ -1515,7 +1515,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
condlog(3, "%s: error in change_foreign", __func__);
break;
default:
- condlog(1, "%s: return code %d of change_forein is unsupported",
+ condlog(1, "%s: return code %d of change_foreign is unsupported",
__func__, rc);
break;
}
@@ -1966,7 +1966,7 @@ ghost_delay_tick(struct vectors *vecs)
}
static void
-defered_failback_tick (vector mpvec)
+deferred_failback_tick (vector mpvec)
{
struct multipath * mpp;
unsigned int i;
@@ -2186,7 +2186,7 @@ static int check_path_reinstate_state(struct path * pp) {
get_monotonic_time(&curr_time);
/* when path failures has exceeded the san_path_err_threshold
* place the path in delayed state till san_path_err_recovery_time
- * so that the cutomer can rectify the issue within this time. After
+ * so that the customer can rectify the issue within this time. After
* the completion of san_path_err_recovery_time it should
* automatically reinstate the path
* (note: we know that san_path_err_threshold > 0 here).
@@ -2647,7 +2647,7 @@ checkerloop (void *ap)
pthread_cleanup_push(cleanup_lock, &vecs->lock);
lock(&vecs->lock);
pthread_testcancel();
- defered_failback_tick(vecs->mpvec);
+ deferred_failback_tick(vecs->mpvec);
retry_count_tick(vecs->mpvec);
missing_uev_wait_tick(vecs);
ghost_delay_tick(vecs);
diff --git a/tests/directio.c b/tests/directio.c
index 20ccc47a..01fdef28 100644
--- a/tests/directio.c
+++ b/tests/directio.c
@@ -497,7 +497,7 @@ static void test_free_with_pending(void **state)
do_libcheck_reset(1);
}
-/* test removing orpahed aio_group on free */
+/* test removing orphaned aio_group on free */
static void test_orphaned_aio_group(void **state)
{
struct checker c[AIO_GROUP_SIZE] = {{.cls = NULL}};
diff --git a/tests/hwtable.c b/tests/hwtable.c
index bfaf613f..334b75e8 100644
--- a/tests/hwtable.c
+++ b/tests/hwtable.c
@@ -29,7 +29,7 @@
#define N_CONF_FILES 2
-static const char tmplate[] = "/tmp/hwtable-XXXXXX";
+static const char template[] = "/tmp/hwtable-XXXXXX";
struct key_value {
const char *key;
@@ -136,7 +136,7 @@ static int setup(void **state)
if (hwt == NULL)
return -1;
- snprintf(buf, sizeof(buf), "%s", tmplate);
+ snprintf(buf, sizeof(buf), "%s", template);
if (mkdtemp(buf) == NULL) {
condlog(0, "mkdtemp: %s", strerror(errno));
goto err;
@@ -255,7 +255,7 @@ static void write_defaults(const struct hwt_state *hwt)
{ "detect_prio", "no" },
{ "detect_checker", "no" },
};
- char buf[sizeof(tmplate) + sizeof(bindings_name)];
+ char buf[sizeof(template) + sizeof(bindings_name)];
char dirbuf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/%s", hwt->tmpname, bindings_name);
@@ -308,7 +308,7 @@ static void write_device(FILE *ff, int nkv, const struct key_value *kv)
}
/*
- * Some macros to avoid boilerplace code
+ * Some macros to avoid boilerplate code
*/
#define CHECK_STATE(state) ({ \
@@ -448,7 +448,7 @@ static const struct key_value npr_queue = { _no_path_retry, "queue" };
/***** BEGIN TESTS SECTION *****/
/*
- * Dump the configuration, subistitute the dumped configuration
+ * Dump the configuration, substitute the dumped configuration
* for the current one, and verify that the result is identical.
*/
static void replicate_config(const struct hwt_state *hwt, bool local)
diff --git a/tests/mpathvalid.c b/tests/mpathvalid.c
index 0230a88f..df66ed6a 100644
--- a/tests/mpathvalid.c
+++ b/tests/mpathvalid.c
@@ -399,7 +399,7 @@ static void test_mpathvalid_is_path_good3(void **state)
free(wwid);
}
-/* mabybe valid with no matching paths */
+/* maybe valid with no matching paths */
static void test_mpathvalid_is_path_good4(void **state)
{
const char *wwids[] = { "WWID_A", "WWID_B", "WWID_C", "WWID_D" };
diff --git a/tests/pgpolicy.c b/tests/pgpolicy.c
index f116d12c..43be831f 100644
--- a/tests/pgpolicy.c
+++ b/tests/pgpolicy.c
@@ -191,7 +191,7 @@ verify_pathgroups(struct multipath *mp, struct path *pp, int **groups,
/* Test names instead of pointers to get a more
* useful error message */
assert_string_equal(pgp_path->dev, pp_path->dev);
- /* This test is just a backkup in case the
+ /* This test is just a backup in case the
* something wenth wrong naming the paths */
assert_ptr_equal(pgp_path, pp_path);
}
diff --git a/tests/valid.c b/tests/valid.c
index e7393a1c..398b771e 100644
--- a/tests/valid.c
+++ b/tests/valid.c
@@ -293,7 +293,7 @@ static void test_sysfs_is_multipathed(void **state)
memset(&pp, 0, sizeof(pp));
conf.find_multipaths = FIND_MULTIPATHS_STRICT;
- /* test for already existing multiapthed device */
+ /* test for already existing multipathed device */
will_return(__wrap_sysfs_is_multipathed, true);
will_return(__wrap_sysfs_is_multipathed, wwid);
assert_int_equal(is_path_valid(name, &conf, &pp, true),
@@ -452,7 +452,7 @@ static void test_greedy(void **state)
assert_string_equal(pp.dev, name);
assert_ptr_equal(pp.udev, &test_udev);
assert_string_equal(pp.wwid, wwid);
- /* test greedy success without checking multiapthd */
+ /* test greedy success without checking multipathd */
memset(&pp, 0, sizeof(pp));
setup_passing(name, wwid, CHECK_MPATHD_SKIP, STAGE_IS_FAILED);
assert_int_equal(is_path_valid(name, &conf, &pp, false),
diff --git a/third-party/valgrind/valgrind.h b/third-party/valgrind/valgrind.h
index 577c8f05..1633b318 100644
--- a/third-party/valgrind/valgrind.h
+++ b/third-party/valgrind/valgrind.h
@@ -1075,7 +1075,7 @@ typedef
/* Use these to write the name of your wrapper. NOTE: duplicates
VG_WRAP_FUNCTION_Z{U,Z} in pub_tool_redir.h. NOTE also: inserts
- the default behaviour equivalance class tag "0000" into the name.
+ the default behaviour equivalence class tag "0000" into the name.
See pub_tool_redir.h for details -- normally you don't need to
think about this, though. */
@@ -1620,11 +1620,11 @@ typedef
and say that %r15 is trashed instead. gcc seems happy to go with
that.
- Oh .. and this all needs to be conditionalised so that it is
+ Oh .. and this all needs to be conditionalized so that it is
unchanged from before this commit, when compiled with older gccs
that don't support __builtin_dwarf_cfa. Furthermore, since
this header file is freestanding, it has to be independent of
- config.h, and so the following conditionalisation cannot depend on
+ config.h, and so the following conditionalization cannot depend on
configure time checks.
Although it's not clear from
@@ -1673,7 +1673,7 @@ typedef
/* NB 9 Sept 07. There is a nasty kludge here in all these CALL_FN_
macros. In order not to trash the stack redzone, we need to drop
%rsp by 128 before the hidden call, and restore afterwards. The
- nastyness is that it is only by luck that the stack still appears
+ nastiness is that it is only by luck that the stack still appears
to be unwindable during the hidden call - since then the behaviour
of any routine using this macro does not match what the CFI data
says. Sigh.

View File

@ -0,0 +1,57 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Thu, 21 Jul 2022 19:22:04 +0200
Subject: [PATCH] multipath-tools: remove list of rebranded arrays vendors from
man page
It does not provide useful info, and it is incomplete.
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipath/multipath.conf.5 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index 853e0feb..8b7dc511 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -315,12 +315,12 @@ accepts the optional prio_arg \fIexclusive_pref_bit\fR.
.TP
.I ontap
(Hardware-dependent)
-Generate the path priority for NetApp ONTAP class and OEM arrays as IBM NSeries.
+Generate the path priority for NetApp ONTAP class, and rebranded arrays.
.TP
.I rdac
(Hardware-dependent)
Generate the path priority for LSI/Engenio/NetApp RDAC class as NetApp SANtricity
-E/EF Series, and OEM arrays from IBM DELL SGI STK and SUN.
+E/EF Series, and rebranded arrays.
.TP
.I hp_sw
(Hardware-dependent)
@@ -496,7 +496,7 @@ Active/Standby mode exclusively.
.I rdac
(Hardware-dependent)
Check the path state for LSI/Engenio/NetApp RDAC class as NetApp SANtricity E/EF
-Series, and OEM arrays from IBM DELL SGI STK and SUN.
+Series, and rebranded arrays.
.TP
.I directio
Read the first sector with direct I/O. This checker could cause spurious path
@@ -1568,7 +1568,7 @@ families.
.I 1 rdac
(Hardware-dependent)
Hardware handler for LSI/Engenio/NetApp RDAC class as NetApp SANtricity E/EF
-Series, and OEM arrays from IBM DELL SGI STK and SUN.
+Series, and rebranded arrays.
.TP
.I 1 hp_sw
(Hardware-dependent)

View File

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Sat, 23 Jul 2022 00:01:13 +0200
Subject: [PATCH] multipath-tools: correct CLARiiON info from multipath.conf
man page
Remove "Unity" from emc prio and hardware_handler, because
Unity does not support PNR mode, just ALUA (page 113 and 153):
https://www.delltechnologies.com/asset/en-us/products/storage/technical-support/docu5128.pdf
And add PNR info.
Cc: Yanfei Chen <vincent.chen1@dell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipath/multipath.conf.5 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index 8b7dc511..acdd1ae6 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -306,7 +306,7 @@ generate the path priority. This prioritizer accepts the optional prio_arg
.I emc
(Hardware-dependent)
Generate the path priority for DGC class arrays as CLARiiON CX/AX and
-EMC VNX and Unity families.
+EMC VNX families with Failover Mode 1 (Passive Not Ready(PNR)).
.TP
.I alua
(Hardware-dependent)
@@ -1562,8 +1562,8 @@ The following hardware handler are implemented:
.TP 12
.I 1 emc
(Hardware-dependent)
-Hardware handler for DGC class arrays as CLARiiON CX/AX and EMC VNX and Unity
-families.
+Hardware handler for DGC class arrays as CLARiiON CX/AX and EMC VNX families
+with Failover Mode 1 (Passive Not Ready(PNR)).
.TP
.I 1 rdac
(Hardware-dependent)

View File

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Xose Vazquez Perez <xose.vazquez@gmail.com>
Date: Sat, 23 Jul 2022 15:12:04 +0200
Subject: [PATCH] multipath-tools: add basic info on how to use multipath-tools
with NVMe devices
Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@redhat.com>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
README.md | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/README.md b/README.md
index 2322082c..b05b1332 100644
--- a/README.md
+++ b/README.md
@@ -174,3 +174,19 @@ To enable ALUA, the following options should be changed:
- Huawei OceanStor:
"Host Access Mode" should be changed to "Asymmetric".
+
+
+NVMe
+====
+To use Device Mapper/multipath-tools with NVMe devices,
+if the Native NVMe Multipath subsystem is enabled
+( "Y" in `/sys/module/nvme_core/parameters/multipath` ),
+it has to be disabled:
+
+`echo "options nvme_core multipath=N" > /etc/modprobe.d/01-nvme_core-mp.conf`,
+regenerate the initramfs (`dracut -f` or `update-initramfs`) and reboot.
+
+Check that it is disabled(N) with:
+`cat /sys/module/nvme_core/parameters/multipath`
+or
+`systool -m nvme_core -A multipath`

View File

@ -0,0 +1,90 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 9 Aug 2022 16:46:26 -0500
Subject: [PATCH] multipathd: factor out the code to flush a map with no paths
The code to flush a multipath device because all of its paths have
been removed will be used by another caller, so factor it out of
ev_remove_path().
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
multipathd/main.c | 56 ++++++++++++++++++++++++-----------------------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index defee10a..53cbdb61 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -561,6 +561,30 @@ int update_multipath (struct vectors *vecs, char *mapname, int reset)
return 0;
}
+static bool
+flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) {
+ char alias[WWID_SIZE];
+
+ /*
+ * flush_map will fail if the device is open
+ */
+ strlcpy(alias, mpp->alias, WWID_SIZE);
+ if (mpp->flush_on_last_del == FLUSH_ENABLED) {
+ condlog(2, "%s Last path deleted, disabling queueing",
+ mpp->alias);
+ mpp->retry_tick = 0;
+ mpp->no_path_retry = NO_PATH_RETRY_FAIL;
+ mpp->disable_queueing = 1;
+ mpp->stat_map_failures++;
+ dm_queue_if_no_path(mpp->alias, 0);
+ }
+ if (!flush_map(mpp, vecs, 1)) {
+ condlog(2, "%s: removed map after removing all paths", alias);
+ return true;
+ }
+ return false;
+}
+
static int
update_map (struct multipath *mpp, struct vectors *vecs, int new_map)
{
@@ -1363,34 +1387,12 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
vector_del_slot(mpp->paths, i);
/*
- * remove the map IF removing the last path
+ * remove the map IF removing the last path. If
+ * flush_map_nopaths succeeds, the path has been removed.
*/
- if (VECTOR_SIZE(mpp->paths) == 0) {
- char alias[WWID_SIZE];
-
- /*
- * flush_map will fail if the device is open
- */
- strlcpy(alias, mpp->alias, WWID_SIZE);
- if (mpp->flush_on_last_del == FLUSH_ENABLED) {
- condlog(2, "%s Last path deleted, disabling queueing", mpp->alias);
- mpp->retry_tick = 0;
- mpp->no_path_retry = NO_PATH_RETRY_FAIL;
- mpp->disable_queueing = 1;
- mpp->stat_map_failures++;
- dm_queue_if_no_path(mpp->alias, 0);
- }
- if (!flush_map(mpp, vecs, 1)) {
- condlog(2, "%s: removed map after"
- " removing all paths",
- alias);
- /* flush_map() has freed the path */
- goto out;
- }
- /*
- * Not an error, continue
- */
- }
+ if (VECTOR_SIZE(mpp->paths) == 0 &&
+ flush_map_nopaths(mpp, vecs))
+ goto out;
if (setup_map(mpp, &params, vecs)) {
condlog(0, "%s: failed to setup map for"

View File

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 9 Aug 2022 16:46:27 -0500
Subject: [PATCH] libmultipath: return success if we raced to remove a map and
lost
_dm_flush_map() was returning failure if it failed to remove a map,
even if that was because the map had already been removed. Return
success in this case.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/devmapper.c | 4 ++++
multipathd/main.c | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 1748d258..a49db3b0 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -1111,6 +1111,10 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
}
condlog(4, "multipath map %s removed", mapname);
return 0;
+ } else if (dm_is_mpath(mapname) != 1) {
+ condlog(4, "multipath map %s removed externally",
+ mapname);
+ return 0; /*we raced with someone else removing it */
} else {
condlog(2, "failed to remove multipath map %s",
mapname);
diff --git a/multipathd/main.c b/multipathd/main.c
index 53cbdb61..3fcd6bdb 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -758,10 +758,6 @@ flush_map(struct multipath * mpp, struct vectors * vecs, int nopaths)
* the spurious uevent we may generate with the dm_flush_map call below
*/
if (r) {
- /*
- * May not really be an error -- if the map was already flushed
- * from the device mapper by dmsetup(8) for instance.
- */
if (r == 1)
condlog(0, "%s: can't flush", mpp->alias);
else {

View File

@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Tue, 9 Aug 2022 16:46:28 -0500
Subject: [PATCH] multipathd: Handle losing all path in update_map
Its possible that when a multipath device is being updated, it will end
up that all the paths for it are gone. This can happen if paths are
added and then removed again before multipathd processes the uevent for
the newly created multipath device. In this case multipathd wasn't
taking the proper action for the case where all the paths had been
removed. If flush_on_last_del was set, multipathd wasn't disabling
flushing and if deferred_remove was set, it wasn't doing a deferred
remove. Multipathd should call flush_map_nopaths(), just like
ev_remove_path() does when the last path is removed.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
multipathd/main.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/multipathd/main.c b/multipathd/main.c
index 3fcd6bdb..7d127dbe 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -602,6 +602,10 @@ retry:
goto fail;
}
verify_paths(mpp);
+ if (VECTOR_SIZE(mpp->paths) == 0 &&
+ flush_map_nopaths(mpp, vecs))
+ return 1;
+
mpp->action = ACT_RELOAD;
if (mpp->prflag) {

View File

@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Fri, 5 Aug 2022 18:16:03 -0500
Subject: [PATCH] multipath: fix systemd timers in the initramfs
The systemd timers created for "find_multipaths smart" conflict with
shutdown.target, but not with initrd-cleanup.service. This can make
these timers trigger after the inirtd has started shutting down,
restarting multipathd (which then stops initrd-cleanup.service, since it
conflicts). To avoid this, make sure the timers and the unit they
trigger conflict with inird-cleanup.service. Also don't make them start
multipathd. "multipath -u" will not return "maybe" if multipathd isn't
running or set to run, and since we no longer wait for udev-settle,
multipathd starts up pretty quickly, so it shouldn't be a problem to
not trigger it here.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
multipath/multipath.rules | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/multipath/multipath.rules b/multipath/multipath.rules
index 9df11a95..f993d996 100644
--- a/multipath/multipath.rules
+++ b/multipath/multipath.rules
@@ -71,7 +71,7 @@ ENV{.SAVED_FM_WAIT_UNTIL}=="?*", GOTO="pretend_mpath"
#
# We must trigger an "add" event because LVM2 will only act on those.
-RUN+="/usr/bin/systemd-run --unit=cancel-multipath-wait-$kernel --description 'cancel waiting for multipath siblings of $kernel' --no-block --timer-property DefaultDependencies=no --timer-property Conflicts=shutdown.target --timer-property Before=shutdown.target --timer-property AccuracySec=500ms --property DefaultDependencies=no --property Conflicts=shutdown.target --property Before=shutdown.target --property Wants=multipathd.service --property After=multipathd.service --on-active=$env{FIND_MULTIPATHS_WAIT_UNTIL} /usr/bin/udevadm trigger --action=add $sys$devpath"
+RUN+="/usr/bin/systemd-run --unit=cancel-multipath-wait-$kernel --description 'cancel waiting for multipath siblings of $kernel' --no-block --timer-property DefaultDependencies=no --timer-property Conflicts=shutdown.target --timer-property Before=shutdown.target --timer-property Conflicts=initrd-cleanup.service --timer-property Before=initrd-cleanup.service --timer-property AccuracySec=500ms --property DefaultDependencies=no --property Conflicts=shutdown.target --property Before=shutdown.target --property Conflicts=initrd-cleanup.service --property Before=initrd-cleanup.service --on-active=$env{FIND_MULTIPATHS_WAIT_UNTIL} /usr/bin/udevadm trigger --action=add $sys$devpath"
LABEL="pretend_mpath"
ENV{DM_MULTIPATH_DEVICE_PATH}="1"

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bastian Germann <bage@debian.org>
Date: Thu, 14 Oct 2021 00:34:33 +0200
Subject: [PATCH] multipathd: Add missing ctype include
In uxclnt.c, there are isspace calls. Add an explicit include.
Signed-off-by: Bastian Germann <bage@debian.org>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/uxclnt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
index b1b058bd..bdcc7c3f 100644
--- a/multipathd/uxclnt.c
+++ b/multipathd/uxclnt.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
+#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>

View File

@ -0,0 +1,102 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Fri, 12 Aug 2022 18:58:15 +0200
Subject: [PATCH] multipathd: replace libreadline with libedit
Linking multipathd with libreadline may cause a license conflict,
because libreadline is licensed under GPL-3.0-or-later, and
libmultipath contains several files under GPL-2.0.
See:
https://github.com/opensvc/multipath-tools/issues/36
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=979095
https://www.gnu.org/licenses/gpl-faq.html#AllCompatibility
Replace the readline functionality with libedit, which comes under
a BSD license. The readline library can still be enabled (e.g. for
binaries not intended to be distributed) by running
"make READLINE=libreadline".
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
Makefile.inc | 5 +++++
multipathd/Makefile | 11 ++++++++++-
multipathd/cli.c | 5 +++++
multipathd/uxclnt.c | 6 ++++++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/Makefile.inc b/Makefile.inc
index bcd2212a..ad7afd04 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -8,6 +8,11 @@
#
# Uncomment to disable dmevents polling support
# ENABLE_DMEVENTS_POLL = 0
+#
+# Readline library to use, libedit or libreadline
+# Caution: Using libreadline may make the multipathd binary undistributable,
+# see https://github.com/opensvc/multipath-tools/issues/36
+READLINE = libedit
# List of scsi device handler modules to load on boot, e.g.
# SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac
diff --git a/multipathd/Makefile b/multipathd/Makefile
index c937cd55..95acd887 100644
--- a/multipathd/Makefile
+++ b/multipathd/Makefile
@@ -22,7 +22,16 @@ CFLAGS += $(BIN_CFLAGS)
LDFLAGS += $(BIN_LDFLAGS)
LIBDEPS += -L$(multipathdir) -lmultipath -L$(mpathpersistdir) -lmpathpersist \
-L$(mpathcmddir) -lmpathcmd -ludev -ldl -lurcu -lpthread \
- -ldevmapper -lreadline
+ -ldevmapper
+
+ifeq ($(READLINE),libedit)
+CPPFLAGS += -DUSE_LIBEDIT
+LIBDEPS += -ledit
+endif
+ifeq ($(READLINE),libreadline)
+CPPFLAGS += -DUSE_LIBREADLINE
+LIBDEPS += -lreadline
+endif
ifdef SYSTEMD
CPPFLAGS += -DUSE_SYSTEMD=$(SYSTEMD)
diff --git a/multipathd/cli.c b/multipathd/cli.c
index b2ee9a99..fa482a67 100644
--- a/multipathd/cli.c
+++ b/multipathd/cli.c
@@ -11,7 +11,12 @@
#include "parser.h"
#include "util.h"
#include "version.h"
+#ifdef USE_LIBEDIT
+#include <editline/readline.h>
+#endif
+#ifdef USE_LIBREADLINE
#include <readline/readline.h>
+#endif
#include "mpath_cmd.h"
#include "cli.h"
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
index bdcc7c3f..251e7d75 100644
--- a/multipathd/uxclnt.c
+++ b/multipathd/uxclnt.c
@@ -16,8 +16,14 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <poll.h>
+
+#ifdef USE_LIBEDIT
+#include <editline/readline.h>
+#endif
+#ifdef USE_LIBREADLINE
#include <readline/readline.h>
#include <readline/history.h>
+#endif
#include "mpath_cmd.h"
#include "uxsock.h"

View File

@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Fri, 12 Aug 2022 21:25:37 +0200
Subject: [PATCH] libmultipath: convert license of strbuf code to GPL-2.0+
This (partly) fixes the license incompatibility reported in
https://github.com/opensvc/multipath-tools/issues/36
As I'm the only author (except for a trivial spelling fix),
I see no issue with changing the license.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/strbuf.c | 2 +-
libmultipath/strbuf.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libmultipath/strbuf.c b/libmultipath/strbuf.c
index f654594d..e23b65e8 100644
--- a/libmultipath/strbuf.c
+++ b/libmultipath/strbuf.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 SUSE LLC
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#include <inttypes.h>
#include <stdint.h>
diff --git a/libmultipath/strbuf.h b/libmultipath/strbuf.h
index 31ab519a..ae863417 100644
--- a/libmultipath/strbuf.h
+++ b/libmultipath/strbuf.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 SUSE LLC
- * SPDX-License-Identifier: GPL-2.0-only
+ * SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _STRBUF_H
#define _STRBUF_H

View File

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 16 Aug 2022 14:10:39 +0200
Subject: [PATCH] github workflows: build-and-unittest.yaml: add libedit-dev
This is is required after switching from libreadline to libedit.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/build-and-unittest.yaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/build-and-unittest.yaml b/.github/workflows/build-and-unittest.yaml
index 7ff45842..1ab0d36c 100644
--- a/.github/workflows/build-and-unittest.yaml
+++ b/.github/workflows/build-and-unittest.yaml
@@ -27,7 +27,7 @@ jobs:
sudo apt-get install --yes gcc
make perl-base pkg-config valgrind
libdevmapper-dev libreadline-dev libaio-dev libsystemd-dev
- libudev-dev libjson-c-dev liburcu-dev libcmocka-dev
+ libudev-dev libjson-c-dev liburcu-dev libcmocka-dev libedit-dev
- name: build
run: make -O -j$(grep -c ^processor /proc/cpuinfo)
- name: test
@@ -55,7 +55,7 @@ jobs:
sudo apt-get install --yes gcc-10
make perl-base pkg-config valgrind
libdevmapper-dev libreadline-dev libaio-dev libsystemd-dev
- libudev-dev libjson-c-dev liburcu-dev libcmocka-dev
+ libudev-dev libjson-c-dev liburcu-dev libcmocka-dev libedit-dev
- name: set CC
run: echo CC=gcc-10 >> $GITHUB_ENV
- name: build
@@ -85,7 +85,7 @@ jobs:
sudo apt-get install --yes clang
make perl-base pkg-config valgrind
libdevmapper-dev libreadline-dev libaio-dev libsystemd-dev
- libudev-dev libjson-c-dev liburcu-dev libcmocka-dev
+ libudev-dev libjson-c-dev liburcu-dev libcmocka-dev libedit-dev
- name: set CC
run: echo CC=clang >> $GITHUB_ENV
- name: build

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 16 Aug 2022 14:10:39 +0200
Subject: [PATCH] github workflows: coverity.yaml: add libedit-dev
This is is required after switching from libreadline to libedit.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/coverity.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/coverity.yaml b/.github/workflows/coverity.yaml
index a8b56d43..3c6b3824 100644
--- a/.github/workflows/coverity.yaml
+++ b/.github/workflows/coverity.yaml
@@ -15,7 +15,7 @@ jobs:
sudo apt-get install --yes
gcc make pkg-config
libdevmapper-dev libreadline-dev libaio-dev libsystemd-dev
- libudev-dev libjson-c-dev liburcu-dev libcmocka-dev
+ libudev-dev libjson-c-dev liburcu-dev libcmocka-dev libedit-dev
- name: download coverity
run: >
curl -o cov-analysis-linux64.tar.gz

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 16 Aug 2022 14:10:39 +0200
Subject: [PATCH] github workflows: abi.yaml: add libedit-dev
This is is required after switching from libreadline to libedit.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/abi.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/abi.yaml b/.github/workflows/abi.yaml
index 0a40104a..89b971cd 100644
--- a/.github/workflows/abi.yaml
+++ b/.github/workflows/abi.yaml
@@ -30,7 +30,7 @@ jobs:
sudo apt-get install --yes gcc
gcc make pkg-config abigail-tools
libdevmapper-dev libreadline-dev libaio-dev libsystemd-dev
- libudev-dev libjson-c-dev liburcu-dev libcmocka-dev
+ libudev-dev libjson-c-dev liburcu-dev libcmocka-dev libedit-dev
- name: create ABI
run: make -O -j$(grep -c ^processor /proc/cpuinfo) abi.tar.gz
- name: save ABI

View File

@ -0,0 +1,71 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 16 Aug 2022 16:52:07 +0200
Subject: [PATCH] GitHub workflows: native.yaml: add libedit-dev, except for
jessie
This is is required after switching from libreadline to libedit.
On jessie, we can use libreadline5 (libreadline-gpl2-dev) without
license issues. Trying to compile against libedit results in an
"incompatible pointer type" error on jessie, because libedit
uses a different prototype for rl_completion_entry_function.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/native.yaml | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/native.yaml b/.github/workflows/native.yaml
index ddfd4a09..8b599209 100644
--- a/.github/workflows/native.yaml
+++ b/.github/workflows/native.yaml
@@ -22,13 +22,24 @@ jobs:
- name: checkout
uses: actions/checkout@v1
- name: build and test
+ if: ${{ matrix.os != 'jessie' }}
run: make test
+ - name: build and test (jessie)
+ # On jessie, we use libreadline 5 (no licensing issue)
+ if: ${{ matrix.os == 'jessie' }}
+ run: make READLINE=libreadline test
- name: clean
run: make clean
- name: clang
+ if: ${{ matrix.os != 'jessie' }}
env:
CC: clang
run: make test
+ - name: clang (jessie)
+ if: ${{ matrix.os == 'jessie' }}
+ env:
+ CC: clang
+ run: make READLINE=libreadline test
rolling:
runs-on: ubuntu-20.04
@@ -56,12 +67,13 @@ jobs:
libjson-c-dev
liburcu-dev
libcmocka-dev
+ libedit-dev
- name: dependencies-alpine
if: ${{ matrix.os == 'alpine' }}
run: >
apk add make gcc clang cmocka
musl-dev lvm2-dev libaio-dev readline-dev ncurses-dev eudev-dev
- userspace-rcu-dev json-c-dev cmocka-dev
+ userspace-rcu-dev json-c-dev cmocka-dev libedit-dev
- name: dependencies-fedora
if: ${{ matrix.os == 'fedora:rawhide' }}
run: >
@@ -76,6 +88,7 @@ jobs:
userspace-rcu-devel
json-c-devel
libcmocka-devel
+ libedit-devel
- name: checkout
uses: actions/checkout@v1
- name: build and test

View File

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Tue, 16 Aug 2022 23:38:18 +0200
Subject: [PATCH] GitHub workflows: foreign.yaml: switch to Debian 11
(bullseye)
Building the containers in the build-multipath project recently
started failing for buster/s390x and buster/ppc64el. That failure
had nothing to do with the switch to libedit.
It's about time to switch to bullseye anyway.
Signed-off-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
.github/workflows/foreign.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/foreign.yaml b/.github/workflows/foreign.yaml
index 32915186..f6e69709 100644
--- a/.github/workflows/foreign.yaml
+++ b/.github/workflows/foreign.yaml
@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
- os: [buster]
+ os: [bullseye]
arch: ['ppc64le', 'aarch64', 's390x']
container: mwilck/multipath-build-${{ matrix.os }}-${{ matrix.arch }}
steps:
@@ -44,7 +44,7 @@ jobs:
needs: build
strategy:
matrix:
- os: [buster]
+ os: [bullseye]
arch: ['ppc64le', 'aarch64', 's390x']
steps:
- name: get binaries

View File

@ -15,10 +15,10 @@ Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
3 files changed, 4 insertions(+), 4 deletions(-) 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc diff --git a/Makefile.inc b/Makefile.inc
index bcd2212a..40cfbd0c 100644 index ad7afd04..03450610 100644
--- a/Makefile.inc --- a/Makefile.inc
+++ b/Makefile.inc +++ b/Makefile.inc
@@ -76,7 +76,7 @@ endif @@ -81,7 +81,7 @@ endif
prefix = prefix =
exec_prefix = $(prefix) exec_prefix = $(prefix)
usr_prefix = $(prefix) usr_prefix = $(prefix)

View File

@ -43,7 +43,7 @@ index 8d15d2ea..eff690fd 100644
udev_device_get_properties_list_entry(udev)) { udev_device_get_properties_list_entry(udev)) {
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index c2d34f18..18a55b70 100644 index acdd1ae6..5ab770ba 100644
--- a/multipath/multipath.conf.5 --- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5
@@ -1348,9 +1348,14 @@ keywords. Both are regular expressions. For a full description of these keywords @@ -1348,9 +1348,14 @@ keywords. Both are regular expressions. For a full description of these keywords

View File

@ -45,7 +45,7 @@ index ab8b26e7..f06fcbf9 100644
conf->processed_main_config = 1; conf->processed_main_config = 1;
diff --git a/libmultipath/config.h b/libmultipath/config.h diff --git a/libmultipath/config.h b/libmultipath/config.h
index 36d40157..115b463b 100644 index fdcdff0a..affba937 100644
--- a/libmultipath/config.h --- a/libmultipath/config.h
+++ b/libmultipath/config.h +++ b/libmultipath/config.h
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
@ -57,7 +57,7 @@ index 36d40157..115b463b 100644
enum devtypes { enum devtypes {
DEV_NONE, DEV_NONE,
diff --git a/multipath/multipath.rules b/multipath/multipath.rules diff --git a/multipath/multipath.rules b/multipath/multipath.rules
index 9df11a95..0486bf70 100644 index f993d996..68c30644 100644
--- a/multipath/multipath.rules --- a/multipath/multipath.rules
+++ b/multipath/multipath.rules +++ b/multipath/multipath.rules
@@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath" @@ -9,6 +9,7 @@ IMPORT{cmdline}="nompath"

View File

@ -13,10 +13,10 @@ Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 file changed, 18 insertions(+), 6 deletions(-) 1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/Makefile.inc b/Makefile.inc diff --git a/Makefile.inc b/Makefile.inc
index 40cfbd0c..307b6b4d 100644 index 03450610..2cf6e85f 100644
--- a/Makefile.inc --- a/Makefile.inc
+++ b/Makefile.inc +++ b/Makefile.inc
@@ -136,18 +136,30 @@ ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers @@ -141,18 +141,30 @@ ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers
WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,) WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,)
WFORMATOVERFLOW := $(call TEST_CC_OPTION,-Wformat-overflow=2,) WFORMATOVERFLOW := $(call TEST_CC_OPTION,-Wformat-overflow=2,)

View File

@ -14,10 +14,10 @@ Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
2 files changed, 8 insertions(+), 10 deletions(-) 2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 0d8a558c..0c73b754 100644 index 15560f8c..2339c9a9 100644
--- a/libmultipath/discovery.c --- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c +++ b/libmultipath/discovery.c
@@ -1177,13 +1177,9 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, @@ -1175,13 +1175,9 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len,
good_len = 8; good_len = 8;
break; break;
case 2: case 2:
@ -33,7 +33,7 @@ index 0d8a558c..0c73b754 100644
good_len = 8; good_len = 8;
break; break;
default: default:
@@ -1201,10 +1197,6 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len, @@ -1199,10 +1195,6 @@ parse_vpd_pg83(const unsigned char *in, size_t in_len,
break; break;
case 0x8: case 0x8:
/* SCSI Name: Prio 3 */ /* SCSI Name: Prio 3 */

View File

@ -11,10 +11,10 @@ Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 file changed, 1 insertion(+), 1 deletion(-) 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.inc b/Makefile.inc diff --git a/Makefile.inc b/Makefile.inc
index 307b6b4d..8f64c700 100644 index 2cf6e85f..7277cf5f 100644
--- a/Makefile.inc --- a/Makefile.inc
+++ b/Makefile.inc +++ b/Makefile.inc
@@ -11,7 +11,7 @@ @@ -16,7 +16,7 @@ READLINE = libedit
# List of scsi device handler modules to load on boot, e.g. # List of scsi device handler modules to load on boot, e.g.
# SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac # SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac

View File

@ -1,6 +1,6 @@
Name: device-mapper-multipath Name: device-mapper-multipath
Version: 0.9.0 Version: 0.9.0
Release: 2%{?dist} Release: 3%{?dist}
Summary: Tools to manage multipath devices using device-mapper Summary: Tools to manage multipath devices using device-mapper
License: GPLv2 License: GPLv2
URL: http://christophe.varoqui.free.fr/ URL: http://christophe.varoqui.free.fr/
@ -14,25 +14,62 @@ Patch0001: 0001-github-workflows-switch-to-fedora-36.patch
Patch0002: 0002-multipath-tools-fix-multipath-ll-bug-for-Native-NVME.patch Patch0002: 0002-multipath-tools-fix-multipath-ll-bug-for-Native-NVME.patch
Patch0003: 0003-multipath-tools-update-Huawei-OceanStor-NVMe-vendor-.patch Patch0003: 0003-multipath-tools-update-Huawei-OceanStor-NVMe-vendor-.patch
Patch0004: 0004-multipath-tools-update-Generic-NVMe-vendor-regex-in-.patch Patch0004: 0004-multipath-tools-update-Generic-NVMe-vendor-regex-in-.patch
Patch0005: 0005-libmultipath-unset-detect_checker-for-clariion-Unity.patch Patch0005: 0005-libmultipath-fix-find_multipaths_timeout-for-unknown.patch
Patch0006: 0006-libmultipath-fix-find_multipaths_timeout-for-unknown.patch Patch0006: 0006-multipath-tools-update-devel-repo-info-in-README.md.patch
Patch0007: 0007-RH-fixup-udev-rules-for-redhat.patch Patch0007: 0007-multipath-tools-delete-README.alua.patch
Patch0008: 0008-RH-Remove-the-property-blacklist-exception-builtin.patch Patch0008: 0008-multipath-tools-add-ALUA-info-to-README.md.patch
Patch0009: 0009-RH-don-t-start-without-a-config-file.patch Patch0009: 0009-libmultipath-alua-remove-get_sysfs_pg83.patch
Patch0010: 0010-RH-Fix-nvme-function-missing-argument.patch Patch0010: 0010-libmultipath-remove-sysfs_get_binary.patch
Patch0011: 0011-RH-use-rpm-optflags-if-present.patch Patch0011: 0011-libmultipath-sysfs_bin_attr_get_value-no-error-if-bu.patch
Patch0012: 0012-RH-add-mpathconf.patch Patch0012: 0012-libmultipath-common-code-path-for-sysfs_attr_get_val.patch
Patch0013: 0013-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch Patch0013: 0013-libmultipath-sanitize-error-checking-in-sysfs-access.patch
Patch0014: 0014-RH-reset-default-find_mutipaths-value-to-off.patch Patch0014: 0014-libmultipath-get-rid-of-PATH_SIZE.patch
Patch0015: 0015-RH-attempt-to-get-ANA-info-via-sysfs-first.patch Patch0015: 0015-libmultipath-sysfs_attr_get_value-don-t-return-0-if-.patch
Patch0016: 0016-RH-make-parse_vpd_pg83-match-scsi_id-output.patch Patch0016: 0016-libmultipath-sysfs_attr_set_value-don-t-return-0-on-.patch
Patch0017: 0017-RH-add-scsi-device-handlers-to-modules-load.d.patch Patch0017: 0017-libmultipath-sysfs-cleanup-file-descriptors-on-pthre.patch
Patch0018: 0018-libmultipath-multipathd-log-failure-setting-sysfs-at.patch
Patch0019: 0019-multipath-tests-expect_condlog-skip-depending-on-ver.patch
Patch0020: 0020-multipath-tests-__wrap_dlog-print-log-message.patch
Patch0021: 0021-multipath-tests-add-sysfs-test.patch
Patch0022: 0022-libmultipath.version-bump-version-for-sysfs-accessor.patch
Patch0023: 0023-libmultipath-unset-detect_checker-for-clariion-Unity.patch
Patch0024: 0024-libmultipath-spelling-cplusplus.patch
Patch0025: 0025-libmultipath-spelling-ascii.patch
Patch0026: 0026-libmultipath-spelling-progress.patch
Patch0027: 0027-multipath-tools-spelling-fixes.patch
Patch0028: 0028-multipath-tools-remove-list-of-rebranded-arrays-vend.patch
Patch0029: 0029-multipath-tools-correct-CLARiiON-info-from-multipath.patch
Patch0030: 0030-multipath-tools-add-basic-info-on-how-to-use-multipa.patch
Patch0031: 0031-multipathd-factor-out-the-code-to-flush-a-map-with-n.patch
Patch0032: 0032-libmultipath-return-success-if-we-raced-to-remove-a-.patch
Patch0033: 0033-multipathd-Handle-losing-all-path-in-update_map.patch
Patch0034: 0034-multipath-fix-systemd-timers-in-the-initramfs.patch
Patch0035: 0035-multipathd-Add-missing-ctype-include.patch
Patch0036: 0036-multipathd-replace-libreadline-with-libedit.patch
Patch0037: 0037-libmultipath-convert-license-of-strbuf-code-to-GPL-2.patch
Patch0038: 0038-github-workflows-build-and-unittest.yaml-add-libedit.patch
Patch0039: 0039-github-workflows-coverity.yaml-add-libedit-dev.patch
Patch0040: 0040-github-workflows-abi.yaml-add-libedit-dev.patch
Patch0041: 0041-GitHub-workflows-native.yaml-add-libedit-dev-except-.patch
Patch0042: 0042-GitHub-workflows-foreign.yaml-switch-to-Debian-11-bu.patch
Patch0043: 0043-RH-fixup-udev-rules-for-redhat.patch
Patch0044: 0044-RH-Remove-the-property-blacklist-exception-builtin.patch
Patch0045: 0045-RH-don-t-start-without-a-config-file.patch
Patch0046: 0046-RH-Fix-nvme-function-missing-argument.patch
Patch0047: 0047-RH-use-rpm-optflags-if-present.patch
Patch0048: 0048-RH-add-mpathconf.patch
Patch0049: 0049-RH-add-wwids-from-kernel-cmdline-mpath.wwids-with-A.patch
Patch0050: 0050-RH-reset-default-find_mutipaths-value-to-off.patch
Patch0051: 0051-RH-attempt-to-get-ANA-info-via-sysfs-first.patch
Patch0052: 0052-RH-make-parse_vpd_pg83-match-scsi_id-output.patch
Patch0053: 0053-RH-add-scsi-device-handlers-to-modules-load.d.patch
# runtime # runtime
Requires: %{name}-libs = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release}
Requires: kpartx = %{version}-%{release} Requires: kpartx = %{version}-%{release}
Requires: device-mapper >= 1.02.96 Requires: device-mapper >= 1.02.96
Requires: userspace-rcu Requires: userspace-rcu
Requires: libedit
Requires(post): systemd-units Requires(post): systemd-units
Requires(preun): systemd-units Requires(preun): systemd-units
Requires(postun): systemd-units Requires(postun): systemd-units
@ -50,7 +87,7 @@ Conflicts: udisks2 < 2.8.0-2
# build/setup # build/setup
BuildRequires: libaio-devel, device-mapper-devel >= 1.02.89 BuildRequires: libaio-devel, device-mapper-devel >= 1.02.89
BuildRequires: libselinux-devel, libsepol-devel BuildRequires: libselinux-devel, libsepol-devel
BuildRequires: readline-devel, ncurses-devel BuildRequires: libedit-devel, ncurses-devel
BuildRequires: systemd-units, systemd-devel BuildRequires: systemd-units, systemd-devel
BuildRequires: json-c-devel, perl-interpreter, pkgconfig, gcc BuildRequires: json-c-devel, perl-interpreter, pkgconfig, gcc
BuildRequires: userspace-rcu-devel BuildRequires: userspace-rcu-devel
@ -172,7 +209,6 @@ fi
/usr/lib/modules-load.d/multipath.conf /usr/lib/modules-load.d/multipath.conf
/usr/lib/modules-load.d/scsi_dh.conf /usr/lib/modules-load.d/scsi_dh.conf
%doc README.md %doc README.md
%doc README.alua
%doc multipath.conf %doc multipath.conf
%dir /etc/multipath %dir /etc/multipath
@ -227,6 +263,18 @@ fi
%{_pkgconfdir}/libdmmp.pc %{_pkgconfdir}/libdmmp.pc
%changelog %changelog
* Fri Aug 19 2022 Benjamin Marzinski <bmarzins@redhat.com> - 0.9.0-3
- Update to the head of the upstream staging branch
* Patches 0005-0042 are from the upstream staging branch
* Previous patches 0005 & 0006 are now patches 0023 & 0005
- Rename redhat patches
* Previous patches 0007-0017 are now patches 0043-0053
- Change from using readline to libedit
* readline is licensed GPL v3, and multipathd includes code
licensed gpl v2.
- Remove README.alua
* information moved to README.md
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-2 * Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild