[prev in list] [next in list] [prev in thread] [next in thread]
List: dm-devel
Subject: [dm-devel] [RFC] [PATCH] add serial keyword to the weightedpath prioritizer
From: Christophe Varoqui <christophe.varoqui () opensvc ! com>
Date: 2016-07-31 19:26:53
Message-ID: CABr-Gndh4LLgd=T00GdtwNVrFgL7Te91BwjZ0Dh4uYyDi3c9bA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Ben, Hannes,
Can you review this patch, adding a new 'serial' keyword to the
weightedpath prioritizer.
I compile-tested it only, as I have no testing environment at hand at the
moment.
I commited it in a separate 'weightedpath-serial' branch for now.
http://git.opensvc.com/?p=multipath-tools/.git;a=commitdiff;h=4dd16d99281104fc3504ad73626894a5c3702fb3
Thanks,
Christophe Varoqui
OpenSVC
---
commit 4dd16d99281104fc3504ad73626894a5c3702fb3
Author: Christophe Varoqui <christophe.varoqui@opensvc.com>
Date: Sun Jul 31 21:08:14 2016 +0200
multipath: add serial keyword to the weightedpath prioritizer
Allow the weightedpath prioritizer to set priority to paths to
specific serial numbers, expressed as regular expressions.
Example:
prio weightedpath
prio_args "serial .*101 30 .*102 10"
This feature is most synthetic for cross-site + all-paths-active
topologies, where servers on a site want to prefer paths to the
local storage heads.
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 7c556b3..94d6384 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -503,7 +503,7 @@ snprint_path_size (char * buff, size_t len, struct path
* pp)
return snprint_size(buff, len, pp->size);
}
-static int
+int
snprint_path_serial (char * buff, size_t len, struct path * pp)
{
return snprint_str(buff, len, pp->serial);
diff --git a/libmultipath/print.h b/libmultipath/print.h
index 9306e50..6839fc7 100644
--- a/libmultipath/print.h
+++ b/libmultipath/print.h
@@ -112,6 +112,7 @@ int snprint_devices (struct config *, char *, int,
struct vectors *);
int snprint_hwtable (struct config *, char *, int, vector);
int snprint_mptable (struct config *, char *, int, vector);
int snprint_overrides (struct config *, char *, int, struct hwentry *);
+int snprint_path_serial (char *, size_t, struct path *);
int snprint_host_wwnn (char *, size_t, struct path *);
int snprint_host_wwpn (char *, size_t, struct path *);
int snprint_tgt_wwnn (char *, size_t, struct path *);
diff --git a/libmultipath/prioritizers/weightedpath.c
b/libmultipath/prioritizers/weightedpath.c
index e8168fe..e53ab48 100644
--- a/libmultipath/prioritizers/weightedpath.c
+++ b/libmultipath/prioritizers/weightedpath.c
@@ -53,6 +53,16 @@ do { \
} while(0)
static int
+build_serial_path(struct path *pp, char *str, int len)
+{
+ char *p = str;
+
+ p += snprint_path_serial(p, str + len - p, pp);
+ CHECK_LEN;
+ return 0;
+}
+
+static int
build_wwn_path(struct path *pp, char *str, int len)
{
char *p = str;
@@ -103,8 +113,13 @@ int prio_path_weight(struct path *pp, char *prio_args)
pp->sg_id.channel, pp->sg_id.scsi_id, pp->sg_id.lun);
} else if (!strcmp(regex, DEV_NAME)) {
strcpy(path, pp->dev);
+ } else if (!strcmp(regex, SERIAL)) {
+ if (build_serial_path(pp, path, FILE_NAME_SIZE) != 0) {
+ FREE(arg);
+ return priority;
+ }
} else if (!strcmp(regex, WWN)) {
- if (build_wwn_path(pp, path, FILE_NAME_SIZE) != 0) {
+ if (build_serial_path(pp, path, FILE_NAME_SIZE) != 0) {
FREE(arg);
return priority;
}
diff --git a/libmultipath/prioritizers/weightedpath.h
b/libmultipath/prioritizers/weightedpath.h
index 93d8c43..a1b268f 100644
--- a/libmultipath/prioritizers/weightedpath.h
+++ b/libmultipath/prioritizers/weightedpath.h
@@ -4,6 +4,7 @@
#define PRIO_WEIGHTED_PATH "weightedpath"
#define HBTL "hbtl"
#define DEV_NAME "devname"
+#define SERIAL "serial"
#define WWN "wwn"
#define DEFAULT_PRIORITY 0
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5
index ecaef1f..e73e917 100644
--- a/multipath/multipath.conf.5
+++ b/multipath/multipath.conf.5
@@ -243,17 +243,25 @@ prioritizers:
.TP 12
.I weighted
Needs a value of the form
-.I "<hbtl|devname|wwn> <regex1> <prio1> <regex2> <prio2> ..."
+.I "<hbtl|devname|serial|wwn> <regex1> <prio1> <regex2> <prio2> ..."
+.RS
+.TP 8
.I hbtl
regex can be of SCSI H:B:T:L format Ex: 1:0:.:. , *:0:0:.
+.TP
.I devname
regex can be of device name format Ex: sda , sd.e
+.TP
+.I serial
+regex can be of serial number format Ex: .*J1FR.*324 The serial can be
looked up through sysfs or by running multipathd show paths format "%z" Ex:
0395J1FR904324
+.TP
.I wwn
regex can be of the form
.I "host_wwnn:host_wwpn:target_wwnn:target_wwpn"
these values can be looked up through sysfs or by running
-.I mulitpathd show paths format "%N:%R:%n:%r" Ex:
0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* ,
.*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.*
-.TP
+.I multipathd show paths format "%N:%R:%n:%r" Ex:
0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* ,
.*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.*
+.RE
+.TP 12
.I alua
If
.I exclusive_pref_bit
[Attachment #5 (text/html)]
<div dir="ltr">Ben, Hannes,<div><br></div><div>Can you review this patch, adding a \
new 'serial' keyword to the weightedpath \
prioritizer.</div><div><br></div><div>I compile-tested it only, as I have no testing \
environment at hand at the moment.</div><div><br></div><div>I commited it in a \
separate 'weightedpath-serial' branch for now.</div><div><br></div><div><a \
href="http://git.opensvc.com/?p=multipath-tools/.git;a=commitdiff;h=4dd16d99281104fc35 \
04ad73626894a5c3702fb3">http://git.opensvc.com/?p=multipath-tools/.git;a=commitdiff;h= \
4dd16d99281104fc3504ad73626894a5c3702fb3</a><br></div><div><br></div><div>Thanks,</div><div>Christophe \
Varoqui</div><div>OpenSVC</div><div><br></div><div>---</div><div><br></div><div><div>commit \
4dd16d99281104fc3504ad73626894a5c3702fb3</div><div>Author: Christophe Varoqui <<a \
href="mailto:christophe.varoqui@opensvc.com">christophe.varoqui@opensvc.com</a>></div><div>Date: \
Sun Jul 31 21:08:14 2016 +0200</div><div><br></div><div> multipath: add serial \
keyword to the weightedpath prioritizer</div><div> </div><div> Allow the \
weightedpath prioritizer to set priority to paths to</div><div> specific serial \
numbers, expressed as regular expressions.</div><div> </div><div> \
Example:</div><div> </div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>prio weightedpath</div><div> <span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>prio_args "serial \
.*101 30 .*102 10"</div><div> </div><div> This feature is most \
synthetic for cross-site + all-paths-active</div><div> topologies, where servers \
on a site want to prefer paths to the</div><div> local storage \
heads.</div><div><br></div><div>diff --git a/libmultipath/print.c \
b/libmultipath/print.c</div><div>index 7c556b3..94d6384 100644</div><div>--- \
a/libmultipath/print.c</div><div>+++ b/libmultipath/print.c</div><div>@@ -503,7 \
+503,7 @@ snprint_path_size (char * buff, size_t len, struct path * pp)</div><div> \
<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>return \
snprint_size(buff, len, pp->size);</div><div> }</div><div> </div><div>-static \
int</div><div>+int</div><div> snprint_path_serial (char * buff, size_t len, struct \
path * pp)</div><div> {</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>return snprint_str(buff, len, \
pp->serial);</div><div>diff --git a/libmultipath/print.h \
b/libmultipath/print.h</div><div>index 9306e50..6839fc7 100644</div><div>--- \
a/libmultipath/print.h</div><div>+++ b/libmultipath/print.h</div><div>@@ -112,6 \
+112,7 @@ int snprint_devices (struct config *, char *, int, struct vectors \
*);</div><div> int snprint_hwtable (struct config *, char *, int, \
vector);</div><div> int snprint_mptable (struct config *, char *, int, \
vector);</div><div> int snprint_overrides (struct config *, char *, int, struct \
hwentry *);</div><div>+int snprint_path_serial (char *, size_t, struct path \
*);</div><div> int snprint_host_wwnn (char *, size_t, struct path *);</div><div> \
int snprint_host_wwpn (char *, size_t, struct path *);</div><div> int \
snprint_tgt_wwnn (char *, size_t, struct path *);</div><div>diff --git \
a/libmultipath/prioritizers/weightedpath.c \
b/libmultipath/prioritizers/weightedpath.c</div><div>index e8168fe..e53ab48 \
100644</div><div>--- a/libmultipath/prioritizers/weightedpath.c</div><div>+++ \
b/libmultipath/prioritizers/weightedpath.c</div><div>@@ -53,6 +53,16 @@ do { \
\</div><div> } while(0)</div><div> </div><div> static \
int</div><div>+build_serial_path(struct path *pp, char *str, int \
len)</div><div>+{</div><div>+<span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>char *p = str;</div><div>+</div><div>+<span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>p += \
snprint_path_serial(p, str + len - p, pp);</div><div>+<span \
class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>CHECK_LEN;</div><div>+<span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>return \
0;</div><div>+}</div><div>+</div><div>+static int</div><div> build_wwn_path(struct \
path *pp, char *str, int len)</div><div> {</div><div> <span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>char *p = \
str;</div><div>@@ -103,8 +113,13 @@ int prio_path_weight(struct path *pp, char \
*prio_args)</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>pp->sg_id.channel, pp->sg_id.scsi_id, \
pp->sg_id.lun);</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>} else if (!strcmp(regex, DEV_NAME)) {</div><div> \
<span class="gmail-Apple-tab-span" style="white-space:pre"> </span>strcpy(path, \
pp->dev);</div><div>+<span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>} else if (!strcmp(regex, SERIAL)) {</div><div>+<span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>if \
(build_serial_path(pp, path, FILE_NAME_SIZE) != 0) {</div><div>+<span \
class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>FREE(arg);</div><div>+<span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>return \
priority;</div><div>+<span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>}</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>} else if (!strcmp(regex, WWN)) {</div><div>-<span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>if (build_wwn_path(pp, \
path, FILE_NAME_SIZE) != 0) {</div><div>+<span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>if (build_serial_path(pp, path, FILE_NAME_SIZE) != \
0) {</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>FREE(arg);</div><div> <span \
class="gmail-Apple-tab-span" style="white-space:pre"> </span>return \
priority;</div><div> <span class="gmail-Apple-tab-span" \
style="white-space:pre"> </span>}</div><div>diff --git \
a/libmultipath/prioritizers/weightedpath.h \
b/libmultipath/prioritizers/weightedpath.h</div><div>index 93d8c43..a1b268f \
100644</div><div>--- a/libmultipath/prioritizers/weightedpath.h</div><div>+++ \
b/libmultipath/prioritizers/weightedpath.h</div><div>@@ -4,6 +4,7 @@</div><div> \
#define PRIO_WEIGHTED_PATH "weightedpath"</div><div> #define HBTL \
"hbtl"</div><div> #define DEV_NAME "devname"</div><div>+#define \
SERIAL "serial"</div><div> #define WWN "wwn"</div><div> #define \
DEFAULT_PRIORITY 0</div><div> </div><div>diff --git a/multipath/multipath.conf.5 \
b/multipath/multipath.conf.5</div><div>index ecaef1f..e73e917 100644</div><div>--- \
a/multipath/multipath.conf.5</div><div>+++ b/multipath/multipath.conf.5</div><div>@@ \
-243,17 +243,25 @@ prioritizers:</div><div> .TP 12</div><div> .I \
weighted</div><div> Needs a value of the form</div><div>-.I \
"<hbtl|devname|wwn> <regex1> <prio1> <regex2> \
<prio2> ..."</div><div>+.I "<hbtl|devname|serial|wwn> \
<regex1> <prio1> <regex2> <prio2> \
..."</div><div>+.RS</div><div>+.TP 8</div><div> .I hbtl</div><div> regex can \
be of SCSI H:B:T:L format Ex: 1:0:.:. , *:0:0:.</div><div>+.TP</div><div> .I \
devname</div><div> regex can be of device name format Ex: sda , \
sd.e</div><div>+.TP</div><div>+.I serial</div><div>+regex can be of serial number \
format Ex: .*J1FR.*324 The serial can be looked up through sysfs or by running \
multipathd show paths format "%z" Ex: \
0395J1FR904324</div><div>+.TP</div><div> .I wwn</div><div> regex can be of the \
form</div><div> .I "host_wwnn:host_wwpn:target_wwnn:target_wwpn"</div><div> \
these values can be looked up through sysfs or by running</div><div>-.I mulitpathd \
show paths format "%N:%R:%n:%r" Ex: \
0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* , \
.*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.*</div><div>-.TP</div><div>+.I \
multipathd show paths format "%N:%R:%n:%r" Ex: \
0x200100e08ba0aea0:0x210100e08ba0aea0:.*:.* , \
.*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.*</div><div>+.RE</div><div>+.TP \
12</div><div> .I alua</div><div> If</div><div> .I \
exclusive_pref_bit</div></div><div><br></div></div>
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic