From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
Hannes Reinecke <hare@suse.de>
Cc: dm-devel@redhat.com, Xose Vazquez Perez <xose.vazquez@gmail.com>
Subject: [PATCH v4 10/11] libmultipath: don't try to set hwhandler if it is retained
Date: Thu, 22 Jun 2017 16:59:12 +0200 [thread overview]
Message-ID: <20170622145913.23714-11-mwilck@suse.com> (raw)
In-Reply-To: <20170622145913.23714-1-mwilck@suse.com>
Setting a device handler only works if retain_attached_hw_handler
is 'no', or if the kernel didn't auto-assign a handler. If this
is not the case, don't even attempt to set a different handler.
This requires reading the sysfs "dh_state" path attribute.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/configure.c | 8 +++++++-
libmultipath/propsel.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 74b6f52a..03874f47 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -275,15 +275,21 @@ int setup_map(struct multipath *mpp, char *params, int params_size)
/*
* properties selectors
+ *
+ * Ordering matters for some properties:
+ * - features after no_path_retry and retain_hwhandler
+ * - hwhandler after retain_hwhandler
+ * No guarantee that this list is complete, check code in
+ * propsel.c if in doubt.
*/
conf = get_multipath_config();
select_pgfailback(conf, mpp);
select_pgpolicy(conf, mpp);
select_selector(conf, mpp);
- select_hwhandler(conf, mpp);
select_no_path_retry(conf, mpp);
select_retain_hwhandler(conf, mpp);
select_features(conf, mpp);
+ select_hwhandler(conf, mpp);
select_rr_weight(conf, mpp);
select_minio(conf, mpp);
select_mode(conf, mpp);
diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c
index d609394e..a86207a0 100644
--- a/libmultipath/propsel.c
+++ b/libmultipath/propsel.c
@@ -19,8 +19,10 @@
#include "discovery.h"
#include "dict.h"
#include "util.h"
+#include "sysfs.h"
#include "prioritizers/alua_rtpg.h"
#include <inttypes.h>
+#include <libudev.h>
pgpolicyfn *pgpolicies[] = {
NULL,
@@ -342,9 +344,42 @@ out:
return 0;
}
+static int get_dh_state(struct path *pp, char *value, size_t value_len)
+{
+ struct udev_device *ud;
+
+ if (pp->udev == NULL)
+ return -1;
+
+ ud = udev_device_get_parent_with_subsystem_devtype(
+ pp->udev, "scsi", "scsi_device");
+ if (ud == NULL)
+ return -1;
+
+ return sysfs_attr_get_value(ud, "dh_state", value, value_len);
+}
+
int select_hwhandler(struct config *conf, struct multipath *mp)
{
char *origin;
+ struct path *pp;
+ /* dh_state is no longer than "detached" */
+ char handler[12];
+ char *dh_state;
+ int i;
+
+ dh_state = &handler[2];
+ if (mp->retain_hwhandler != RETAIN_HWHANDLER_OFF) {
+ vector_foreach_slot(mp->paths, pp, i) {
+ if (get_dh_state(pp, dh_state, sizeof(handler) - 2) > 0
+ && strcmp(dh_state, "detached")) {
+ memcpy(handler, "1 ", 2);
+ mp->hwhandler = handler;
+ origin = "(setting: retained by kernel driver)";
+ goto out;
+ }
+ }
+ }
mp_set_hwe(hwhandler);
mp_set_conf(hwhandler);
--
2.13.1
next prev parent reply other threads:[~2017-06-22 14:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 14:59 [PATCH v4 00/11] multipath-tools: no_path_retry/queue_if_no_path/hwhandler logic Martin Wilck
2017-06-22 14:59 ` [PATCH v4 01/11] libmultipath: load_config: skip setting unnecessary defaults Martin Wilck
2017-06-22 14:59 ` [PATCH v4 02/11] libmultipath: add/remove_feature: use const char* for feature Martin Wilck
2017-06-22 14:59 ` [PATCH v4 03/11] libmultipath: clarify option conflicts for "features" Martin Wilck
2017-06-22 14:59 ` [PATCH v4 04/11] libmultipath: merge_hwe: fix queue_if_no_path logic Martin Wilck
2017-06-22 14:59 ` [PATCH v4 05/11] libmultipath: assemble_map: " Martin Wilck
2017-06-22 14:59 ` [PATCH v4 06/11] multipath.conf.5: document no_path_retry vs. queue_if_no_path Martin Wilck
2017-06-22 14:59 ` [PATCH v4 07/11] multipath.conf.5: Remove ??? and other minor fixes Martin Wilck
2017-06-22 14:59 ` [PATCH v4 08/11] libmultipath: add deprecated warning for some features settings Martin Wilck
2017-06-22 14:59 ` [PATCH v4 09/11] libmultipath: retain_attached_hw_handler obsolete with 4.3+ Martin Wilck
2017-06-22 19:09 ` Benjamin Marzinski
2017-06-23 17:25 ` Xose Vazquez Perez
2017-06-26 8:00 ` Martin Wilck
2017-06-22 14:59 ` Martin Wilck [this message]
2017-06-22 19:09 ` [PATCH v4 10/11] libmultipath: don't try to set hwhandler if it is retained Benjamin Marzinski
2017-06-22 14:59 ` [PATCH v4 11/11] libmultipath: don't [un]set queue_if_no_path after domap Martin Wilck
2017-08-03 6:36 ` [PATCH v4 00/11] multipath-tools: no_path_retry/queue_if_no_path/hwhandler logic Christophe Varoqui
2017-08-09 13:19 ` Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170622145913.23714-11-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.de \
--cc=xose.vazquez@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox