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