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