|
|
a1c519 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
a1c519 |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
a1c519 |
Date: Thu, 11 Apr 2019 13:25:42 -0500
|
|
|
a1c519 |
Subject: [PATCH] RH: attempt to get ANA info via sysfs first
|
|
|
a1c519 |
|
|
|
a1c519 |
When the ANA prioritizer is run, first see if the "ana_state" sysfs file
|
|
|
a1c519 |
exists, and if it does, try to read the state from there. If that fails,
|
|
|
a1c519 |
fallback to using an ioctl.
|
|
|
a1c519 |
|
|
|
a1c519 |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
a1c519 |
---
|
|
|
a1c519 |
libmultipath/prioritizers/ana.c | 31 +++++++++++++++++++++++++++++--
|
|
|
a1c519 |
1 file changed, 29 insertions(+), 2 deletions(-)
|
|
|
a1c519 |
|
|
|
a1c519 |
diff --git a/libmultipath/prioritizers/ana.c b/libmultipath/prioritizers/ana.c
|
|
|
8444ee |
index 2673d9d9..f34ade28 100644
|
|
|
a1c519 |
--- a/libmultipath/prioritizers/ana.c
|
|
|
a1c519 |
+++ b/libmultipath/prioritizers/ana.c
|
|
|
a1c519 |
@@ -24,6 +24,7 @@
|
|
|
a1c519 |
#include "prio.h"
|
|
|
a1c519 |
#include "util.h"
|
|
|
a1c519 |
#include "structs.h"
|
|
|
a1c519 |
+#include "sysfs.h"
|
|
|
a1c519 |
|
|
|
a1c519 |
enum {
|
|
|
a1c519 |
ANA_ERR_GETCTRL_FAILED = 1,
|
|
|
a1c519 |
@@ -36,6 +37,7 @@ enum {
|
|
|
a1c519 |
ANA_ERR_GETNS_FAILED,
|
|
|
a1c519 |
ANA_ERR_NO_MEMORY,
|
|
|
a1c519 |
ANA_ERR_NO_INFORMATION,
|
|
|
a1c519 |
+ ANA_ERR_INVALID_STATE,
|
|
|
a1c519 |
};
|
|
|
a1c519 |
|
|
|
a1c519 |
static const char *ana_errmsg[] = {
|
|
|
a1c519 |
@@ -49,6 +51,7 @@ static const char *ana_errmsg[] = {
|
|
|
a1c519 |
[ANA_ERR_GETNS_FAILED] = "couldn't get namespace info",
|
|
|
a1c519 |
[ANA_ERR_NO_MEMORY] = "out of memory",
|
|
|
a1c519 |
[ANA_ERR_NO_INFORMATION] = "invalid fd",
|
|
|
a1c519 |
+ [ANA_ERR_INVALID_STATE] = "invalid state",
|
|
|
a1c519 |
};
|
|
|
a1c519 |
|
|
|
a1c519 |
static const char *anas_string[] = {
|
|
|
a1c519 |
@@ -106,6 +109,27 @@ static int get_ana_state(__u32 nsid, __u32 anagrpid, void *ana_log,
|
|
|
a1c519 |
return -ANA_ERR_GETANAS_NOTFOUND;
|
|
|
a1c519 |
}
|
|
|
a1c519 |
|
|
|
a1c519 |
+int get_ana_info_sysfs(struct path *pp)
|
|
|
a1c519 |
+{
|
|
|
a1c519 |
+ char state[32];
|
|
|
a1c519 |
+
|
|
|
a1c519 |
+ if (!pp->udev || sysfs_attr_get_value(pp->udev, "ana_state", state,
|
|
|
a1c519 |
+ sizeof(state)) <= 0)
|
|
|
a1c519 |
+ return -ANA_ERR_NO_INFORMATION;
|
|
|
a1c519 |
+
|
|
|
a1c519 |
+ if (strcmp(state, "optimized") == 0)
|
|
|
a1c519 |
+ return NVME_ANA_OPTIMIZED;
|
|
|
a1c519 |
+ if (strcmp(state, "non-optimized") == 0)
|
|
|
a1c519 |
+ return NVME_ANA_NONOPTIMIZED;
|
|
|
a1c519 |
+ if (strcmp(state, "inaccessible") == 0)
|
|
|
a1c519 |
+ return NVME_ANA_INACCESSIBLE;
|
|
|
a1c519 |
+ if (strcmp(state, "persistent-loss") == 0)
|
|
|
a1c519 |
+ return NVME_ANA_PERSISTENT_LOSS;
|
|
|
a1c519 |
+ if (strcmp(state, "change") == 0)
|
|
|
a1c519 |
+ return NVME_ANA_CHANGE;
|
|
|
a1c519 |
+ return -ANA_ERR_INVALID_STATE;
|
|
|
a1c519 |
+}
|
|
|
a1c519 |
+
|
|
|
a1c519 |
int get_ana_info(struct path * pp, unsigned int timeout)
|
|
|
a1c519 |
{
|
|
|
a1c519 |
int rc;
|
|
|
a1c519 |
@@ -208,8 +232,11 @@ int getprio(struct path *pp, char *args, unsigned int timeout)
|
|
|
a1c519 |
|
|
|
a1c519 |
if (pp->fd < 0)
|
|
|
a1c519 |
rc = -ANA_ERR_NO_INFORMATION;
|
|
|
a1c519 |
- else
|
|
|
a1c519 |
- rc = get_ana_info(pp, timeout);
|
|
|
a1c519 |
+ else {
|
|
|
a1c519 |
+ rc = get_ana_info_sysfs(pp);
|
|
|
a1c519 |
+ if (rc < 0)
|
|
|
a1c519 |
+ rc = get_ana_info(pp, timeout);
|
|
|
a1c519 |
+ }
|
|
|
a1c519 |
|
|
|
a1c519 |
switch (rc) {
|
|
|
a1c519 |
case NVME_ANA_OPTIMIZED:
|
|
|
a1c519 |
--
|
|
|
a1c519 |
2.17.2
|
|
|
a1c519 |
|