From patchwork Sun Jul 31 19:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Varoqui X-Patchwork-Id: 9253439 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 809CD60865 for ; Sun, 31 Jul 2016 19:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6236528483 for ; Sun, 31 Jul 2016 19:32:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54B392848A; Sun, 31 Jul 2016 19:32:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 672CC28483 for ; Sun, 31 Jul 2016 19:32:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6VJR48l020878; Sun, 31 Jul 2016 15:27:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u6VJR2YG006738 for ; Sun, 31 Jul 2016 15:27:02 -0400 Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6VJR2Nf002965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 31 Jul 2016 15:27:02 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF75B4E034; Sun, 31 Jul 2016 19:26:58 +0000 (UTC) Received: from mfilter47-d.gandi.net (mfilter47-d.gandi.net [217.70.178.178]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 0F462A80D2; Sun, 31 Jul 2016 21:26:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter47-d.gandi.net Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter47-d.gandi.net (mfilter47-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id S0st0twQD9wf; Sun, 31 Jul 2016 21:26:55 +0200 (CEST) X-Originating-IP: 209.85.215.51 Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) (Authenticated sender: gmail@opensvc.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 0AA3AA80D1; Sun, 31 Jul 2016 21:26:54 +0200 (CEST) Received: by mail-lf0-f51.google.com with SMTP id g62so102232794lfe.3; Sun, 31 Jul 2016 12:26:54 -0700 (PDT) X-Gm-Message-State: AEkoouuO0RmgzUzZk/q8L3gzPKRu8WICgFYCDtnjGBcbZY9AiCqdQXQn7A87pN7LZ7LN4XZ3ThU6Fj8jPvGVcg== X-Received: by 10.25.167.6 with SMTP id q6mr17565971lfe.198.1469993214069; Sun, 31 Jul 2016 12:26:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.25.135.7 with HTTP; Sun, 31 Jul 2016 12:26:53 -0700 (PDT) From: Christophe Varoqui Date: Sun, 31 Jul 2016 21:26:53 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Benjamin Marzinski , Hannes Reinecke X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 31 Jul 2016 19:26:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 31 Jul 2016 19:26:59 +0000 (UTC) for IP:'217.70.183.195' DOMAIN:'relay3-d.mail.gandi.net' HELO:'relay3-d.mail.gandi.net' FROM:'christophe.varoqui@opensvc.com' RCPT:'' X-RedHat-Spam-Score: 0.081 (BAYES_50, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL) 217.70.183.195 relay3-d.mail.gandi.net 217.70.183.195 relay3-d.mail.gandi.net X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [RFC] [PATCH] add serial keyword to the weightedpath prioritizer X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP 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 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. .*:.*:iqn.2009-10.com.redhat.msp.lab.ask-06:.* +.RE +.TP 12 .I alua If .I exclusive_pref_bit -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel 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 " ..." +.I " ..." +.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:.*:.* ,