From patchwork Mon Jun 20 08:09:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 9186837 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 0F42A60756 for ; Mon, 20 Jun 2016 08:13:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB41124B5B for ; Mon, 20 Jun 2016 08:13:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E048F25221; Mon, 20 Jun 2016 08:13:35 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6052824B5B for ; Mon, 20 Jun 2016 08:13:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K8A2Di047798; Mon, 20 Jun 2016 04:10: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 u5K89Y9F031190 for ; Mon, 20 Jun 2016 04:09:34 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5K89YGC023680 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Jun 2016 04:09:34 -0400 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 667FF3F725; Mon, 20 Jun 2016 08:09:33 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CB09FADC5; Mon, 20 Jun 2016 08:09:27 +0000 (UTC) From: Hannes Reinecke To: Christophe Varoqui Date: Mon, 20 Jun 2016 10:09:06 +0200 Message-Id: <1466410153-23896-20-git-send-email-hare@suse.de> In-Reply-To: <1466410153-23896-1-git-send-email-hare@suse.de> References: <1466410153-23896-1-git-send-email-hare@suse.de> X-Greylist: Sender IP whitelisted by DNSRBL, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 20 Jun 2016 08:09:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 20 Jun 2016 08:09:33 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx2.suse.de' FROM:'hare@suse.de' RCPT:'' X-RedHat-Spam-Score: -3.327 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-loop: dm-devel@redhat.com Cc: Hannes Reinecke , dm-devel@redhat.com Subject: [dm-devel] [PATCH 19/26] prio: use 'multipath_dir' as argument 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: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP Pass in the 'multipath_dir' config setting as explicit argument for init_prio() and prio_get(). Signed-off-by: Hannes Reinecke --- libmultipath/prio.c | 24 ++++++++++++++++-------- libmultipath/prio.h | 6 +++--- libmultipath/propsel.c | 16 ++++++++-------- multipath/main.c | 2 +- multipathd/main.c | 2 +- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/libmultipath/prio.c b/libmultipath/prio.c index fbf3190..c37d1b0 100644 --- a/libmultipath/prio.c +++ b/libmultipath/prio.c @@ -17,9 +17,9 @@ unsigned int get_prio_timeout(unsigned int default_timeout) return default_timeout; } -int init_prio (void) +int init_prio (char *multipath_dir) { - if (!add_prio(DEFAULT_PRIO)) + if (!add_prio(multipath_dir, DEFAULT_PRIO)) return 1; return 0; } @@ -78,7 +78,7 @@ struct prio * prio_lookup (char * name) if (!strncmp(name, p->name, PRIO_NAME_LEN)) return p; } - return add_prio(name); + return NULL; } int prio_set_args (struct prio * p, char * args) @@ -86,7 +86,7 @@ int prio_set_args (struct prio * p, char * args) return snprintf(p->args, PRIO_ARGS_LEN, "%s", args); } -struct prio * add_prio (char * name) +struct prio * add_prio (char *multipath_dir, char * name) { char libname[LIB_PRIO_NAMELEN]; struct stat stbuf; @@ -98,10 +98,10 @@ struct prio * add_prio (char * name) return NULL; snprintf(p->name, PRIO_NAME_LEN, "%s", name); snprintf(libname, LIB_PRIO_NAMELEN, "%s/libprio%s.so", - conf->multipath_dir, name); + multipath_dir, name); if (stat(libname,&stbuf) < 0) { condlog(0,"Prioritizer '%s' not found in %s", - name, conf->multipath_dir); + name, multipath_dir); goto out; } condlog(3, "loading %s prioritizer", libname); @@ -147,10 +147,18 @@ char * prio_args (struct prio * p) return p->args; } -void prio_get (struct prio * dst, char * name, char * args) +void prio_get (char *multipath_dir, struct prio * dst, char * name, char * args) { - struct prio * src = prio_lookup(name); + struct prio * src = NULL; + + if (!dst) + return; + if (name && strlen(name)) { + src = prio_lookup(name); + if (!src) + src = add_prio(multipath_dir, name); + } if (!src) { dst->getprio = NULL; return; diff --git a/libmultipath/prio.h b/libmultipath/prio.h index 258dee7..ce72a54 100644 --- a/libmultipath/prio.h +++ b/libmultipath/prio.h @@ -53,12 +53,12 @@ struct prio { }; unsigned int get_prio_timeout(unsigned int default_timeout); -int init_prio (void); +int init_prio (char *); void cleanup_prio (void); -struct prio * add_prio (char *); +struct prio * add_prio (char *, char *); struct prio * prio_lookup (char *); int prio_getprio (struct prio *, struct path *); -void prio_get (struct prio *, char *, char *); +void prio_get (char *, struct prio *, char *, char *); void prio_put (struct prio *); int prio_selected (struct prio *); char * prio_name (struct prio *); diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index c1f3d4e..a97e80f 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -383,13 +383,13 @@ detect_prio(struct path * pp) return; if (get_asymmetric_access_state(pp->fd, ret) < 0) return; - prio_get(p, PRIO_ALUA, DEFAULT_PRIO_ARGS); + prio_get(conf->multipath_dir, p, PRIO_ALUA, DEFAULT_PRIO_ARGS); } -#define set_prio(src, msg) \ +#define set_prio(dir, src, msg) \ do { \ if (src && src->prio_name) { \ - prio_get(p, src->prio_name, src->prio_args); \ + prio_get(dir, p, src->prio_name, src->prio_args); \ origin = msg; \ goto out; \ } \ @@ -410,11 +410,11 @@ select_prio (struct path * pp) } } mpe = find_mpe(conf->hwtable, pp->wwid); - set_prio(mpe, "(LUN setting)"); - set_prio(conf->overrides, "(overrides setting)"); - set_prio(pp->hwe, "controller setting)"); - set_prio(conf, "(config file default)"); - prio_get(p, DEFAULT_PRIO, DEFAULT_PRIO_ARGS); + set_prio(conf->multipath_dir, mpe, "(LUN setting)"); + set_prio(conf->multipath_dir, conf->overrides, "(overrides setting)"); + set_prio(conf->multipath_dir, pp->hwe, "controller setting)"); + set_prio(conf->multipath_dir, conf, "(config file default)"); + prio_get(conf->multipath_dir, p, DEFAULT_PRIO, DEFAULT_PRIO_ARGS); origin = "(internal default)"; out: /* diff --git a/multipath/main.c b/multipath/main.c index 70412a8..a6f593f 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -626,7 +626,7 @@ main (int argc, char *argv[]) condlog(0, "failed to initialize checkers"); goto out; } - if (init_prio()) { + if (init_prio(conf->multipath_dir)) { condlog(0, "failed to initialize prioritizers"); goto out; } diff --git a/multipathd/main.c b/multipathd/main.c index 09b96c6..a076f71 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2114,7 +2114,7 @@ child (void * param) condlog(0, "failed to initialize checkers"); goto failed; } - if (init_prio()) { + if (init_prio(conf->multipath_dir)) { condlog(0, "failed to initialize prioritizers"); goto failed; }