From 5df1fd8b21e7f449c02f1c1ffb0d76d1de996816 Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Fri, 12 Apr 2019 12:57:39 -0500 Subject: [PATCH] device-mapper-multipath-0.8.0-2 Add 0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch * try to get ANA state from sysfs first, with the ioctl as a fallback --- ...empt-to-get-ANA-info-via-sysfs-first.patch | 87 +++++++++++++++++++ device-mapper-multipath.spec | 7 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch diff --git a/0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch b/0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch new file mode 100644 index 0000000..36954ad --- /dev/null +++ b/0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Benjamin Marzinski +Date: Thu, 11 Apr 2019 13:25:42 -0500 +Subject: [PATCH] RH: attempt to get ANA info via sysfs first + +When the ANA prioritizer is run, first see if the "ana_state" sysfs file +exists, and if it does, try to read the state from there. If that fails, +fallback to using an ioctl. + +Signed-off-by: Benjamin Marzinski +--- + libmultipath/prioritizers/ana.c | 31 +++++++++++++++++++++++++++++-- + 1 file changed, 29 insertions(+), 2 deletions(-) + +diff --git a/libmultipath/prioritizers/ana.c b/libmultipath/prioritizers/ana.c +index 990d935..d84571b 100644 +--- a/libmultipath/prioritizers/ana.c ++++ b/libmultipath/prioritizers/ana.c +@@ -24,6 +24,7 @@ + #include "prio.h" + #include "util.h" + #include "structs.h" ++#include "sysfs.h" + + enum { + ANA_ERR_GETCTRL_FAILED = 1, +@@ -36,6 +37,7 @@ enum { + ANA_ERR_GETNS_FAILED, + ANA_ERR_NO_MEMORY, + ANA_ERR_NO_INFORMATION, ++ ANA_ERR_INVALID_STATE, + }; + + static const char *ana_errmsg[] = { +@@ -49,6 +51,7 @@ static const char *ana_errmsg[] = { + [ANA_ERR_GETNS_FAILED] = "couldn't get namespace info", + [ANA_ERR_NO_MEMORY] = "out of memory", + [ANA_ERR_NO_INFORMATION] = "invalid fd", ++ [ANA_ERR_INVALID_STATE] = "invalid state", + }; + + static const char *anas_string[] = { +@@ -106,6 +109,27 @@ static int get_ana_state(__u32 nsid, __u32 anagrpid, void *ana_log, + return -ANA_ERR_GETANAS_NOTFOUND; + } + ++int get_ana_info_sysfs(struct path *pp) ++{ ++ char state[32]; ++ ++ if (!pp->udev || sysfs_attr_get_value(pp->udev, "ana_state", state, ++ sizeof(state)) <= 0) ++ return -ANA_ERR_NO_INFORMATION; ++ ++ if (strcmp(state, "optimized") == 0) ++ return NVME_ANA_OPTIMIZED; ++ if (strcmp(state, "non-optimized") == 0) ++ return NVME_ANA_NONOPTIMIZED; ++ if (strcmp(state, "inaccessible") == 0) ++ return NVME_ANA_INACCESSIBLE; ++ if (strcmp(state, "persistent-loss") == 0) ++ return NVME_ANA_PERSISTENT_LOSS; ++ if (strcmp(state, "change") == 0) ++ return NVME_ANA_CHANGE; ++ return -ANA_ERR_INVALID_STATE; ++} ++ + int get_ana_info(struct path * pp, unsigned int timeout) + { + int rc; +@@ -208,8 +232,11 @@ int getprio(struct path *pp, char *args, unsigned int timeout) + + if (pp->fd < 0) + rc = -ANA_ERR_NO_INFORMATION; +- else +- rc = get_ana_info(pp, timeout); ++ else { ++ rc = get_ana_info_sysfs(pp); ++ if (rc < 0) ++ rc = get_ana_info(pp, timeout); ++ } + + switch (rc) { + case NVME_ANA_OPTIMIZED: +-- +2.17.2 + diff --git a/device-mapper-multipath.spec b/device-mapper-multipath.spec index d923a0b..8503fb7 100644 --- a/device-mapper-multipath.spec +++ b/device-mapper-multipath.spec @@ -1,6 +1,6 @@ Name: device-mapper-multipath Version: 0.8.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Tools to manage multipath devices using device-mapper License: GPLv2 URL: http://christophe.varoqui.free.fr/ @@ -37,6 +37,7 @@ Patch0024: 0024-RH-warn-on-invalid-regex-instead-of-failing.patch Patch0025: 0025-RH-reset-default-find_mutipaths-value-to-off.patch Patch0026: 0026-RH-Fix-nvme-compilation-warning.patch Patch0027: 0027-Fix-systemd-version-detection.patch +Patch0028: 0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch # runtime Requires: %{name}-libs = %{version}-%{release} @@ -231,6 +232,10 @@ fi %{_pkgconfdir}/libdmmp.pc %changelog +* Fri Apr 12 2019 Benjamin Marzinski - 0.8.0-2 +- Add 0028-RH-attempt-to-get-ANA-info-via-sysfs-first.patch + * try to get ANA state from sysfs first, with the ioctl as a fallback + * Thu Apr 4 2019 Benjamin Marzinski - 0.8.0-1 - Update Source to upstream version 0.8.0 * Previous patches 0006 & 0007 are included in this commit