From patchwork Fri Jun 8 10:20:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10454105 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 32D7E6037F for ; Fri, 8 Jun 2018 10:21:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D8B729514 for ; Fri, 8 Jun 2018 10:21:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 222C32951C; Fri, 8 Jun 2018 10:21:57 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 ACC1129514 for ; Fri, 8 Jun 2018 10:21:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB6A630820CC; Fri, 8 Jun 2018 10:21:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07ACF3091AA6; Fri, 8 Jun 2018 10:21:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 727181800FED; Fri, 8 Jun 2018 10:21:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w58ALXWT017912 for ; Fri, 8 Jun 2018 06:21:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE6A510694C2; Fri, 8 Jun 2018 10:21:33 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B63191001F45; Fri, 8 Jun 2018 10:21:31 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95614C049D7F; Fri, 8 Jun 2018 10:21:30 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 08 Jun 2018 04:21:27 -0600 From: Martin Wilck To: Christophe Varoqui Date: Fri, 8 Jun 2018 12:20:28 +0200 Message-Id: <20180608102041.22904-16-mwilck@suse.com> In-Reply-To: <20180608102041.22904-1-mwilck@suse.com> References: <20180608102041.22904-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Jun 2018 10:21:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Jun 2018 10:21:30 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Xose Vazquez Perez , Martin Wilck Subject: [dm-devel] [PATCH 15/28] libmultipath: merge hwentries inside a conf file 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 08 Jun 2018 10:21:56 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Merging hwentries with identical vendor/product/revision is still useful, although it's not strictly necessary any more. But such identical entries should always be merged, not only if they appear in different configuration files. This requires changing the logic of factorize_hwtable. By setting -DCHECK_BUILTIN_HWTABLE at compile time, the built-in hwtable can be checked against duplicates as well. Signed-off-by: Martin Wilck --- libmultipath/config.c | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 713ac7f3..fb41d620 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -452,7 +452,7 @@ out: } static void -factorize_hwtable (vector hw, int n) +factorize_hwtable (vector hw, int n, const char *table_desc) { struct hwentry *hwe1, *hwe2; int i, j; @@ -462,22 +462,26 @@ restart: if (i == n) break; j = n; + /* drop invalid device configs */ + if (i >= n && (!hwe1->vendor || !hwe1->product)) { + condlog(0, "device config in %s missing vendor or product parameter", + table_desc); + vector_del_slot(hw, i--); + free_hwe(hwe1); + continue; + } + j = n > i + 1 ? n : i + 1; vector_foreach_slot_after(hw, hwe2, j) { - /* drop invalid device configs */ - if (!hwe2->vendor || !hwe2->product) { - condlog(0, "device config missing vendor or product parameter"); - vector_del_slot(hw, j--); - free_hwe(hwe2); - continue; - } if (hwe_strmatch(hwe2, hwe1) == 0) { - condlog(4, "%s: removing hwentry %s:%s:%s", + condlog(i >= n ? 1 : 3, + "%s: duplicate device section for %s:%s:%s in %s", __func__, hwe1->vendor, hwe1->product, - hwe1->revision); + hwe1->revision, table_desc); vector_del_slot(hw, i); merge_hwe(hwe2, hwe1); free_hwe(hwe1); - n -= 1; + if (i < n) + n -= 1; /* * Play safe here; we have modified * the original vector so the outer @@ -605,9 +609,8 @@ process_config_dir(struct config *conf, vector keywords, char *dir) snprintf(path, LINE_MAX, "%s/%s", dir, namelist[i]->d_name); path[LINE_MAX-1] = '\0'; process_file(conf, path); - if (VECTOR_SIZE(conf->hwtable) > old_hwtable_size) - factorize_hwtable(conf->hwtable, old_hwtable_size); - + factorize_hwtable(conf->hwtable, old_hwtable_size, + namelist[i]->d_name); } pthread_cleanup_pop(1); } @@ -655,6 +658,9 @@ load_config (char * file) if (setup_default_hwtable(conf->hwtable)) goto out; +#ifdef CHECK_BUILTIN_HWTABLE + factorize_hwtable(conf->hwtable, 0, "builtin"); +#endif /* * read the config file */ @@ -668,14 +674,7 @@ load_config (char * file) condlog(0, "error parsing config file"); goto out; } - if (VECTOR_SIZE(conf->hwtable) > builtin_hwtable_size) { - /* - * remove duplica in hwtable. config file - * takes precedence over build-in hwtable - */ - factorize_hwtable(conf->hwtable, builtin_hwtable_size); - } - + factorize_hwtable(conf->hwtable, builtin_hwtable_size, file); } conf->processed_main_config = 1;