From patchwork Tue Oct 30 21:06:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661759 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-2.web.codeaurora.org (Postfix) with ESMTP id EA15A14E2 for ; Tue, 30 Oct 2018 22:39:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0382AB4A for ; Tue, 30 Oct 2018 22:39:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFBC12AB73; Tue, 30 Oct 2018 22:39:18 +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 7B5042AB4A for ; Tue, 30 Oct 2018 22:39:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0C374E90D; Tue, 30 Oct 2018 22:39:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7BAAD612BA; Tue, 30 Oct 2018 22:39:17 +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 3E0634CA94; Tue, 30 Oct 2018 22:39:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7rVD001155 for ; Tue, 30 Oct 2018 17:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 428225C476; Tue, 30 Oct 2018 21:07:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22DCE197FE; Tue, 30 Oct 2018 21:07:23 +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 33E5930A3ACA; Tue, 30 Oct 2018 21:07:22 +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); Tue, 30 Oct 2018 15:07:19 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:32 +0100 Message-Id: <20181030210653.29677-2-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:22 +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.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 01/22] libmultipath: fix use of uninitialized memory in write() 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 30 Oct 2018 22:39:18 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP valgrind complained about this. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 873035e5..3550c3a7 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -661,7 +661,7 @@ sysfs_set_session_tmo(struct multipath *mpp, struct path *pp) } else { snprintf(value, 11, "%u", mpp->fast_io_fail); if (sysfs_attr_set_value(session_dev, "recovery_tmo", - value, 11) <= 0) { + value, strlen(value)) <= 0) { condlog(3, "%s: Failed to set recovery_tmo, " " error %d", pp->dev, errno); } @@ -693,7 +693,7 @@ sysfs_set_nexus_loss_tmo(struct multipath *mpp, struct path *pp) if (mpp->dev_loss) { snprintf(value, 11, "%u", mpp->dev_loss); if (sysfs_attr_set_value(sas_dev, "I_T_nexus_loss_timeout", - value, 11) <= 0) + value, strlen(value)) <= 0) condlog(3, "%s: failed to update " "I_T Nexus loss timeout, error %d", pp->dev, errno); From patchwork Tue Oct 30 21:06:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661721 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-2.web.codeaurora.org (Postfix) with ESMTP id B078913A4 for ; Tue, 30 Oct 2018 22:23:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0B7B2AB79 for ; Tue, 30 Oct 2018 22:23:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 920E62AB8E; Tue, 30 Oct 2018 22:23:08 +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 13DD92AB79 for ; Tue, 30 Oct 2018 22:23:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34B31307D867; Tue, 30 Oct 2018 22:23:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07CF060CD7; Tue, 30 Oct 2018 22:23:07 +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 C5383EEEB; Tue, 30 Oct 2018 22:23:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7bVK001075 for ; Tue, 30 Oct 2018 17:07:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 39AE45D781; Tue, 30 Oct 2018 21:07:37 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB22E61520; Tue, 30 Oct 2018 21:07:33 +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 34E8C80462; Tue, 30 Oct 2018 21:07:32 +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); Tue, 30 Oct 2018 15:07:21 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:33 +0100 Message-Id: <20181030210653.29677-3-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 30 Oct 2018 21:07:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 30 Oct 2018 21:07:32 +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.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 02/22] libmultipath: fix memory leaks from scandir() use 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Oct 2018 22:23:07 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP scandir() users must not only free the resulting dirent* array, but also every member. Add a cleanup function, and fix the existing users of scandir() in libmultipath. Add a small helper macro for casting function pointers to the type pthread_cleanup_push() expects. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/config.c | 10 ++++------ libmultipath/foreign.c | 5 ++++- libmultipath/foreign/nvme.c | 6 +++++- libmultipath/sysfs.c | 5 ++++- libmultipath/util.c | 9 +++++++++ libmultipath/util.h | 9 +++++++++ 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 0aef186a..5af7af58 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -639,17 +639,13 @@ free_config (struct config * conf) FREE(conf); } -static void free_namelist(void *nl) -{ - free(nl); -} - /* if multipath fails to process the config directory, it should continue, * with just a warning message */ static void process_config_dir(struct config *conf, vector keywords, char *dir) { struct dirent **namelist; + struct scandir_result sr; int i, n; char path[LINE_MAX]; int old_hwtable_size; @@ -669,7 +665,9 @@ process_config_dir(struct config *conf, vector keywords, char *dir) return; } else if (n == 0) return; - pthread_cleanup_push(free_namelist, namelist); + sr.di = namelist; + sr.n = n; + pthread_cleanup_push_cast(free_scandir_result, &sr); for (i = 0; i < n; i++) { if (!strstr(namelist[i]->d_name, ".conf")) continue; diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c index 80b399ba..48e8d247 100644 --- a/libmultipath/foreign.c +++ b/libmultipath/foreign.c @@ -115,6 +115,7 @@ static int _init_foreign(const char *multipath_dir) { char pathbuf[PATH_MAX]; struct dirent **di; + struct scandir_result sr; int r, i; foreigns = vector_alloc(); @@ -135,7 +136,9 @@ static int _init_foreign(const char *multipath_dir) return -r; } - pthread_cleanup_push(free, di); + sr.di = di; + sr.n = r; + pthread_cleanup_push_cast(free_scandir_result, &sr); for (i = 0; i < r; i++) { const char *msg, *fn, *c; struct foreign *fgn; diff --git a/libmultipath/foreign/nvme.c b/libmultipath/foreign/nvme.c index 8887a755..c753a747 100644 --- a/libmultipath/foreign/nvme.c +++ b/libmultipath/foreign/nvme.c @@ -27,6 +27,7 @@ #include #include #include +#include "util.h" #include "vector.h" #include "generic.h" #include "foreign.h" @@ -534,6 +535,7 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map) { char pathbuf[PATH_MAX], realbuf[PATH_MAX]; struct dirent **di = NULL; + struct scandir_result sr; struct udev_device *subsys; struct nvme_path *path; int r, i, n; @@ -568,7 +570,9 @@ static void _find_controllers(struct context *ctx, struct nvme_map *map) return; } - pthread_cleanup_push(free, di); + sr.di = di; + sr.n = r; + pthread_cleanup_push_cast(free_scandir_result, &sr); for (i = 0; i < r; i++) { char *fn = di[i]->d_name; struct udev_device *ctrl, *udev; diff --git a/libmultipath/sysfs.c b/libmultipath/sysfs.c index b7dacaad..558c8d6a 100644 --- a/libmultipath/sysfs.c +++ b/libmultipath/sysfs.c @@ -303,6 +303,7 @@ static void close_fd(void *arg) bool sysfs_is_multipathed(const struct path *pp) { char pathbuf[PATH_MAX]; + struct scandir_result sr; struct dirent **di; int n, r, i; bool found = false; @@ -323,7 +324,9 @@ bool sysfs_is_multipathed(const struct path *pp) return false; } - pthread_cleanup_push(free, di); + sr.di = di; + sr.n = r; + pthread_cleanup_push_cast(free_scandir_result, &sr); for (i = 0; i < r && !found; i++) { long fd; int nr; diff --git a/libmultipath/util.c b/libmultipath/util.c index d08112db..66c47611 100644 --- a/libmultipath/util.c +++ b/libmultipath/util.c @@ -496,3 +496,12 @@ void set_max_fds(int max_fds) } } } + +void free_scandir_result(struct scandir_result *res) +{ + int i; + + for (i = 0; i < res->n; i++) + FREE(res->di[i]); + FREE(res->di); +} diff --git a/libmultipath/util.h b/libmultipath/util.h index c2462950..a818e29a 100644 --- a/libmultipath/util.h +++ b/libmultipath/util.h @@ -30,4 +30,13 @@ void set_max_fds(int max_fds); #define safe_snprintf(var, size, format, args...) \ snprintf(var, size, format, ##args) >= size +#define pthread_cleanup_push_cast(f, arg) \ + pthread_cleanup_push(((void (*)(void *))&f), (arg)) + +struct scandir_result { + struct dirent **di; + int n; +}; +void free_scandir_result(struct scandir_result *); + #endif /* _UTIL_H */ From patchwork Tue Oct 30 21:06:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661747 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-2.web.codeaurora.org (Postfix) with ESMTP id BECC81751 for ; Tue, 30 Oct 2018 22:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A190F2A988 for ; Tue, 30 Oct 2018 22:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 906B92AAED; Tue, 30 Oct 2018 22:38:16 +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 E88502A988 for ; Tue, 30 Oct 2018 22:38:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AC8C811A9; Tue, 30 Oct 2018 22:38:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA5B65D75E; Tue, 30 Oct 2018 22:38:12 +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 3FB294CAA8; Tue, 30 Oct 2018 22:38:12 +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 w9UL7Xdx001048 for ; Tue, 30 Oct 2018 17:07:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4D9D100034B; Tue, 30 Oct 2018 21:07:33 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 992031001F3D; Tue, 30 Oct 2018 21:07:33 +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 54712307D856; Tue, 30 Oct 2018 21:07:32 +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); Tue, 30 Oct 2018 15:07:22 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:34 +0100 Message-Id: <20181030210653.29677-4-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Oct 2018 21:07:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Oct 2018 21:07:32 +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.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 03/22] libmultipath/checkers: replace message by msgid 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 30 Oct 2018 22:38:14 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Replace the character array "message" in struct checker with a "message ID" field. The generic checker code defines a couple of standard message IDs and corresponding messages. Checker-specific message IDs start at CHECKER_FIRST_MSG. Checkers that implement specific message IDs must provide a table for converting the IDs into actual log messages. This simplifies the checker data structure and the handling of checker messages in the critical checker code path. It comes at the cost that only constant message strings are supported. It turns out that only a single checker log message (in the emc_clariion checker) was dynamically generated, and the missing information can be provided with a standard condlog message. Follow-up patches implement this for the existing checkers. checker_message() isn't thread-safe in its current form. This will be fixed in another follow-up patch. Signed-off-by: Martin Wilck --- libmultipath/checkers.c | 70 +++++++++++++++++++++++++++++++++++------ libmultipath/checkers.h | 39 +++++++++++++++++++---- 2 files changed, 94 insertions(+), 15 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 0bacc864..0bf15f47 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -141,6 +141,22 @@ struct checker * add_checker (char *multipath_dir, char * name) if (!c->free) goto out; + c->msgtable_size = 0; + c->msgtable = dlsym(c->handle, "libcheck_msgtable"); + + if (c->msgtable != NULL) { + const char **p; + + for (p = c->msgtable; + *p && (p - c->msgtable) < CHECKER_MSGTABLE_SIZE; p++) + /* nothing */; + + c->msgtable_size = p - c->msgtable; + } else + c->msgtable_size = 0; + condlog(3, "checker %s: message table size = %d", + c->name, c->msgtable_size); + done: c->fd = -1; c->sync = 1; @@ -222,16 +238,16 @@ int checker_check (struct checker * c, int path_state) if (!c) return PATH_WILD; - c->message[0] = '\0'; + c->msgid = CHECKER_MSGID_NONE; if (c->disable) { - MSG(c, "checker disabled"); + c->msgid = CHECKER_MSGID_DISABLED; return PATH_UNCHECKED; } if (!strncmp(c->name, NONE, 4)) return path_state; if (c->fd < 0) { - MSG(c, "no usable fd"); + c->msgid = CHECKER_MSGID_NO_FD; return PATH_WILD; } r = c->check(c); @@ -248,25 +264,59 @@ int checker_selected (struct checker * c) return (c->check) ? 1 : 0; } -char * checker_name (struct checker * c) +const char *checker_name(const struct checker *c) { if (!c) return NULL; return c->name; } -char * checker_message (struct checker * c) +static const char *generic_msg[CHECKER_LAST_GENERIC_MSGID] = { + [CHECKER_MSGID_NONE] = "", + [CHECKER_MSGID_DISABLED] = " is disabled", + [CHECKER_MSGID_NO_FD] = " has no usable fd", + [CHECKER_MSGID_INVALID] = " provided invalid message id", + [CHECKER_MSGID_UP] = " reports path is up", + [CHECKER_MSGID_DOWN] = " reports path is down", + [CHECKER_MSGID_GHOST] = " reports path is ghost", +}; + +static const char *_checker_message(const struct checker *c) { - if (!c) + int id; + + if (!c || c->msgid < 0 || + (c->msgid >= CHECKER_LAST_GENERIC_MSGID && + c->msgid < CHECKER_FIRST_MSGID)) return NULL; - return c->message; + + if (c->msgid < CHECKER_LAST_GENERIC_MSGID) + return generic_msg[c->msgid]; + + id = c->msgid - CHECKER_FIRST_MSGID; + if (id < c->msgtable_size) + return c->msgtable[id]; + return NULL; +} + +char *checker_message(const struct checker *c) +{ + static char buf[CHECKER_MSG_LEN]; + const char *msg = _checker_message(c); + + if (msg == NULL || *msg == '\0') + *buf = '\0'; + else + snprintf(buf, sizeof(buf), "%s checker%s", + c->name, msg); + return buf; } void checker_clear_message (struct checker *c) { if (!c) return; - c->message[0] = '\0'; + c->msgid = CHECKER_MSGID_NONE; } void checker_get (char *multipath_dir, struct checker * dst, char * name) @@ -288,10 +338,12 @@ void checker_get (char *multipath_dir, struct checker * dst, char * name) dst->fd = src->fd; dst->sync = src->sync; strncpy(dst->name, src->name, CHECKER_NAME_LEN); - strncpy(dst->message, src->message, CHECKER_MSG_LEN); + dst->msgid = CHECKER_MSGID_NONE; dst->check = src->check; dst->init = src->init; dst->free = src->free; + dst->msgtable = src->msgtable; + dst->msgtable_size = src->msgtable_size; dst->handle = NULL; src->refcount++; } diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 7b18a1ac..1d1a116a 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -97,6 +97,22 @@ enum path_check_state { #define CHECKER_DEV_LEN 256 #define LIB_CHECKER_NAMELEN 256 +/* + * Generic message IDs for use in checkers. + */ +enum { + CHECKER_MSGID_NONE = 0, + CHECKER_MSGID_DISABLED, + CHECKER_MSGID_NO_FD, + CHECKER_MSGID_INVALID, + CHECKER_MSGID_UP, + CHECKER_MSGID_DOWN, + CHECKER_MSGID_GHOST, + CHECKER_LAST_GENERIC_MSGID, + CHECKER_FIRST_MSGID = 100, /* lowest msgid for checkers */ + CHECKER_MSGTABLE_SIZE = 100, /* max msg table size for checkers */ +}; + struct checker { struct list_head node; void *handle; @@ -106,7 +122,7 @@ struct checker { unsigned int timeout; int disable; char name[CHECKER_NAME_LEN]; - char message[CHECKER_MSG_LEN]; /* comm with callers */ + short msgid; /* checker-internal extra status */ void * context; /* store for persistent data */ void ** mpcontext; /* store for persistent data shared multipath-wide. Use MALLOC if @@ -114,10 +130,10 @@ struct checker { int (*check)(struct checker *); int (*init)(struct checker *); /* to allocate the context */ void (*free)(struct checker *); /* to free the context */ + const char**msgtable; + short msgtable_size; }; -#define MSG(c, fmt, args...) snprintf((c)->message, CHECKER_MSG_LEN, fmt, ##args); - char * checker_state_name (int); int init_checkers (char *); void cleanup_checkers (void); @@ -134,14 +150,25 @@ void checker_enable (struct checker *); void checker_disable (struct checker *); int checker_check (struct checker *, int); int checker_selected (struct checker *); -char * checker_name (struct checker *); -char * checker_message (struct checker *); +const char *checker_name (const struct checker *); +char *checker_message (const struct checker *); void checker_clear_message (struct checker *c); void checker_get (char *, struct checker *, char *); -/* Functions exported by path checker dynamic libraries (.so) */ +/* Prototypes for symbols exported by path checker dynamic libraries (.so) */ int libcheck_check(struct checker *); int libcheck_init(struct checker *); void libcheck_free(struct checker *); +/* + * msgid => message map. + * + * It only needs to be provided if the checker defines specific + * message IDs. + * Message IDs available to checkers start at CHECKER_FIRST_MSG. + * The msgtable array is 0-based, i.e. msgtable[0] is the message + * for msgid == __CHECKER_FIRST_MSG. + * The table ends with a NULL element. + */ +extern const char *libcheck_msgtable[]; #endif /* _CHECKERS_H */ From patchwork Tue Oct 30 21:06:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661749 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-2.web.codeaurora.org (Postfix) with ESMTP id 44DD214E2 for ; Tue, 30 Oct 2018 22:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FB4C29D11 for ; Tue, 30 Oct 2018 22:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1072F29D49; Tue, 30 Oct 2018 22:38:30 +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 A897029D11 for ; Tue, 30 Oct 2018 22:38:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA416356DA; Tue, 30 Oct 2018 22:38:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 941975D75D; Tue, 30 Oct 2018 22:38:28 +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 3D3C54CA94; Tue, 30 Oct 2018 22:38:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7ZlH001065 for ; Tue, 30 Oct 2018 17:07:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0D86A6251E; Tue, 30 Oct 2018 21:07:35 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00868610FF; Tue, 30 Oct 2018 21:07:34 +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 A6DC058E26; Tue, 30 Oct 2018 21:07:32 +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); Tue, 30 Oct 2018 15:07:23 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:35 +0100 Message-Id: <20181030210653.29677-5-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 30 Oct 2018 21:07:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 30 Oct 2018 21:07:33 +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.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 04/22] libmultipath/checkers: cciss_tur: use message id 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 22:38:29 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/cciss_tur.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libmultipath/checkers/cciss_tur.c b/libmultipath/checkers/cciss_tur.c index 1cab2015..ea843742 100644 --- a/libmultipath/checkers/cciss_tur.c +++ b/libmultipath/checkers/cciss_tur.c @@ -42,9 +42,6 @@ #define TUR_CMD_LEN 6 #define HEAVY_CHECK_COUNT 10 -#define MSG_CCISS_TUR_UP "cciss_tur checker reports path is up" -#define MSG_CCISS_TUR_DOWN "cciss_tur checker reports path is down" - struct cciss_tur_checker_context { void * dummy; }; @@ -69,7 +66,7 @@ int libcheck_check(struct checker * c) IOCTL_Command_struct cic; // cciss ioctl command if ((c->fd) < 0) { - MSG(c,"no usable fd"); + c->msgid = CHECKER_MSGID_NO_FD; ret = -1; goto out; } @@ -79,7 +76,7 @@ int libcheck_check(struct checker * c) perror("Error: "); fprintf(stderr, "cciss TUR failed in CCISS_GETLUNINFO: %s\n", strerror(errno)); - MSG(c,MSG_CCISS_TUR_DOWN); + c->msgid = CHECKER_MSGID_DOWN; ret = PATH_DOWN; goto out; } else { @@ -106,18 +103,18 @@ int libcheck_check(struct checker * c) if (rc < 0) { fprintf(stderr, "cciss TUR failed: %s\n", strerror(errno)); - MSG(c,MSG_CCISS_TUR_DOWN); + c->msgid = CHECKER_MSGID_DOWN; ret = PATH_DOWN; goto out; } if ((cic.error_info.CommandStatus | cic.error_info.ScsiStatus )) { - MSG(c,MSG_CCISS_TUR_DOWN); + c->msgid = CHECKER_MSGID_DOWN; ret = PATH_DOWN; goto out; } - MSG(c,MSG_CCISS_TUR_UP); + c->msgid = CHECKER_MSGID_UP; ret = PATH_UP; out: From patchwork Tue Oct 30 21:06:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661717 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-2.web.codeaurora.org (Postfix) with ESMTP id 6175A13A4 for ; Tue, 30 Oct 2018 22:22:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FA352AAD8 for ; Tue, 30 Oct 2018 22:22:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FDDB2AB4F; Tue, 30 Oct 2018 22:22:44 +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 D1E842AAD8 for ; Tue, 30 Oct 2018 22:22:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7CCD308625A; Tue, 30 Oct 2018 22:22:42 +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 879F860487; Tue, 30 Oct 2018 22:22:42 +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 E00AF18005BE; Tue, 30 Oct 2018 22:22:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7YeQ001059 for ; Tue, 30 Oct 2018 17:07:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id C6DAD19495; Tue, 30 Oct 2018 21:07:34 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B26C819745; Tue, 30 Oct 2018 21:07:34 +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 34BA03C2CCB; Tue, 30 Oct 2018 21:07:33 +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); Tue, 30 Oct 2018 15:07:24 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:36 +0100 Message-Id: <20181030210653.29677-6-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 30 Oct 2018 21:07:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 30 Oct 2018 21:07:33 +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.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 05/22] libmultipath/checkers: directio: use message id 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 22:22:43 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/directio.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index a80848d4..c4a0712e 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -18,10 +18,19 @@ #include "checkers.h" #include "../libmultipath/debug.h" -#define MSG_DIRECTIO_UNKNOWN "directio checker is not available" -#define MSG_DIRECTIO_UP "directio checker reports path is up" -#define MSG_DIRECTIO_DOWN "directio checker reports path is down" -#define MSG_DIRECTIO_PENDING "directio checker is waiting on aio" +enum { + MSG_DIRECTIO_UNKNOWN = CHECKER_FIRST_MSGID, + MSG_DIRECTIO_PENDING, + MSG_DIRECTIO_BLOCKSIZE, +}; + +#define _IDX(x) (MSG_DIRECTIO_##x - CHECKER_FIRST_MSGID) +const char *libcheck_msgtable[] = { + [_IDX(UNKNOWN)] = " is not available", + [_IDX(PENDING)] = " is waiting on aio", + [_IDX(BLOCKSIZE)] = " cannot get blocksize, set default", + NULL, +}; #define LOG(prio, fmt, args...) condlog(prio, "directio: " fmt, ##args) @@ -54,7 +63,7 @@ int libcheck_init (struct checker * c) } if (ioctl(c->fd, BLKBSZGET, &ct->blksize) < 0) { - MSG(c, "cannot get blocksize, set default"); + c->msgid = MSG_DIRECTIO_BLOCKSIZE; ct->blksize = 512; } if (ct->blksize > 4096) { @@ -198,16 +207,16 @@ int libcheck_check (struct checker * c) switch (ret) { case PATH_UNCHECKED: - MSG(c, MSG_DIRECTIO_UNKNOWN); + c->msgid = MSG_DIRECTIO_UNKNOWN; break; case PATH_DOWN: - MSG(c, MSG_DIRECTIO_DOWN); + c->msgid = CHECKER_MSGID_DOWN; break; case PATH_UP: - MSG(c, MSG_DIRECTIO_UP); + c->msgid = CHECKER_MSGID_UP; break; case PATH_PENDING: - MSG(c, MSG_DIRECTIO_PENDING); + c->msgid = MSG_DIRECTIO_PENDING; break; default: break; From patchwork Tue Oct 30 21:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661729 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-2.web.codeaurora.org (Postfix) with ESMTP id A7BF913A4 for ; Tue, 30 Oct 2018 22:23:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9724C28BDC for ; Tue, 30 Oct 2018 22:23:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88D3628C31; Tue, 30 Oct 2018 22:23:40 +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 0F60028BDC for ; Tue, 30 Oct 2018 22:23:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 336653082A32; Tue, 30 Oct 2018 22:23:38 +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 0DD5B19495; Tue, 30 Oct 2018 22:23:38 +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 C887018005B4; Tue, 30 Oct 2018 22:23:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7rGo001160 for ; Tue, 30 Oct 2018 17:07:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 550B963B81; Tue, 30 Oct 2018 21:07:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 921FB620D8; Tue, 30 Oct 2018 21:07:35 +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 BF66C2D7EB; Tue, 30 Oct 2018 21:07:33 +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); Tue, 30 Oct 2018 15:07:26 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:37 +0100 Message-Id: <20181030210653.29677-7-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 21:07:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 21:07:34 +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.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 06/22] libmultipath/checkers: emc_clariion: use message id 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 22:23:39 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP emc_clariion is the only path checker that was using a non-constant message ("read error" case). This isn't possible with the msgid approach any more. Use condlog() for the dynamic log message and simply report "read error" as checker message. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/emc_clariion.c | 60 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c index 9115b1b9..f8e55b93 100644 --- a/libmultipath/checkers/emc_clariion.c +++ b/libmultipath/checkers/emc_clariion.c @@ -41,6 +41,35 @@ ((struct emc_clariion_checker_LU_context *)\ (*c->mpcontext))->inactive_snap = 0 +enum { + MSG_CLARIION_QUERY_FAILED = CHECKER_FIRST_MSGID, + MSG_CLARIION_QUERY_ERROR, + MSG_CLARIION_PATH_CONFIG, + MSG_CLARIION_UNIT_REPORT, + MSG_CLARIION_PATH_NOT_AVAIL, + MSG_CLARIION_LUN_UNBOUND, + MSG_CLARIION_WWN_CHANGED, + MSG_CLARIION_READ_ERROR, + MSG_CLARIION_PASSIVE_GOOD, +}; + +#define _IDX(x) (MSG_CLARIION_ ## x - CHECKER_FIRST_MSGID) +const char *libcheck_msgtable[] = { + [_IDX(QUERY_FAILED)] = ": sending query command failed", + [_IDX(QUERY_ERROR)] = ": query command indicates error", + [_IDX(PATH_CONFIG)] = + ": Path not correctly configured for failover", + [_IDX(UNIT_REPORT)] = + ": Path unit report page in unknown format", + [_IDX(PATH_NOT_AVAIL)] = + ": Path not available for normal operations", + [_IDX(LUN_UNBOUND)] = ": Logical Unit is unbound or LUNZ", + [_IDX(WWN_CHANGED)] = ": Logical Unit WWN has changed", + [_IDX(READ_ERROR)] = ": Read error", + [_IDX(PASSIVE_GOOD)] = ": Active path is healthy", + NULL, +}; + struct emc_clariion_checker_path_context { char wwn[16]; unsigned wwn_set; @@ -116,17 +145,16 @@ int libcheck_check (struct checker * c) io_hdr.timeout = c->timeout * 1000; io_hdr.pack_id = 0; if (ioctl(c->fd, SG_IO, &io_hdr) < 0) { - MSG(c, "emc_clariion_checker: sending query command failed"); + c->msgid = MSG_CLARIION_QUERY_FAILED; return PATH_DOWN; } if (io_hdr.info & SG_INFO_OK_MASK) { - MSG(c, "emc_clariion_checker: query command indicates error"); + c->msgid = MSG_CLARIION_QUERY_ERROR; return PATH_DOWN; } if (/* Verify the code page - right page & revision */ sense_buffer[1] != 0xc0 || sense_buffer[9] != 0x00) { - MSG(c, "emc_clariion_checker: Path unit report page in " - "unknown format"); + c->msgid = MSG_CLARIION_UNIT_REPORT; return PATH_DOWN; } @@ -140,22 +168,19 @@ int libcheck_check (struct checker * c) ((sense_buffer[28] & 0x07) != 0x06)) /* Arraycommpath should be set to 1 */ || (sense_buffer[30] & 0x04) != 0x04) { - MSG(c, "emc_clariion_checker: Path not correctly configured " - "for failover"); + c->msgid = MSG_CLARIION_PATH_CONFIG; return PATH_DOWN; } if ( /* LUN operations should indicate normal operations */ sense_buffer[48] != 0x00) { - MSG(c, "emc_clariion_checker: Path not available for normal " - "operations"); + c->msgid = MSG_CLARIION_PATH_NOT_AVAIL; return PATH_SHAKY; } if ( /* LUN should at least be bound somewhere and not be LUNZ */ sense_buffer[4] == 0x00) { - MSG(c, "emc_clariion_checker: Logical Unit is unbound " - "or LUNZ"); + c->msgid = MSG_CLARIION_LUN_UNBOUND; return PATH_DOWN; } @@ -166,8 +191,7 @@ int libcheck_check (struct checker * c) */ if (ct->wwn_set) { if (memcmp(ct->wwn, &sense_buffer[10], 16) != 0) { - MSG(c, "emc_clariion_checker: Logical Unit WWN " - "has changed!"); + c->msgid = MSG_CLARIION_WWN_CHANGED; return PATH_DOWN; } } else { @@ -202,14 +226,15 @@ int libcheck_check (struct checker * c) condlog(3, "emc_clariion_checker: Active " "path to inactive snapshot WWN %s.", wwnstr); - } else - MSG(c, "emc_clariion_checker: Read " + } else { + condlog(3, "emc_clariion_checker: Read " "error for WWN %s. Sense data are " "0x%x/0x%x/0x%x.", wwnstr, sbb[2]&0xf, sbb[12], sbb[13]); + c->msgid = MSG_CLARIION_READ_ERROR; + } } else { - MSG(c, "emc_clariion_checker: Active path is " - "healthy."); + c->msgid = MSG_CLARIION_PASSIVE_GOOD; /* * Remove the path from the set of paths to inactive * snapshot LUs if it was in this list since the @@ -225,8 +250,7 @@ int libcheck_check (struct checker * c) wwnstr); ret = PATH_DOWN; } else { - MSG(c, - "emc_clariion_checker: Passive path is healthy."); + c->msgid = MSG_CLARIION_PASSIVE_GOOD; ret = PATH_UP; /* not ghost */ } } From patchwork Tue Oct 30 21:06:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661761 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-2.web.codeaurora.org (Postfix) with ESMTP id 494351751 for ; Tue, 30 Oct 2018 22:39:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A22A2AB66 for ; Tue, 30 Oct 2018 22:39:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CF762AB4A; Tue, 30 Oct 2018 22:39:23 +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 CF1892AB4A for ; Tue, 30 Oct 2018 22:39:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0043B3082AF0; Tue, 30 Oct 2018 22:39:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBCD619745; Tue, 30 Oct 2018 22:39:21 +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 936A94CAA7; Tue, 30 Oct 2018 22:39:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7bix001076 for ; Tue, 30 Oct 2018 17:07:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D3C05D788; Tue, 30 Oct 2018 21:07:37 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D74754360; Tue, 30 Oct 2018 21:07:35 +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 0CD163082120; Tue, 30 Oct 2018 21:07:34 +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); Tue, 30 Oct 2018 15:07:27 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:38 +0100 Message-Id: <20181030210653.29677-8-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 30 Oct 2018 21:07:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 30 Oct 2018 21:07:34 +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.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 07/22] libmultipath/checkers: hp_sw: use message id 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 22:39:22 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/hp_sw.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libmultipath/checkers/hp_sw.c b/libmultipath/checkers/hp_sw.c index 0ad34a6b..d7f1018c 100644 --- a/libmultipath/checkers/hp_sw.c +++ b/libmultipath/checkers/hp_sw.c @@ -27,10 +27,6 @@ #define MX_ALLOC_LEN 255 #define HEAVY_CHECK_COUNT 10 -#define MSG_HP_SW_UP "hp_sw checker reports path is up" -#define MSG_HP_SW_DOWN "hp_sw checker reports path is down" -#define MSG_HP_SW_GHOST "hp_sw checker reports path is ghost" - struct sw_checker_context { void * dummy; }; @@ -128,14 +124,14 @@ int libcheck_check(struct checker * c) char buff[MX_ALLOC_LEN]; if (0 != do_inq(c->fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0, c->timeout)) { - MSG(c, MSG_HP_SW_DOWN); + c->msgid = CHECKER_MSGID_DOWN; return PATH_DOWN; - } + }; if (do_tur(c->fd, c->timeout)) { - MSG(c, MSG_HP_SW_GHOST); + c->msgid = CHECKER_MSGID_GHOST; return PATH_GHOST; } - MSG(c, MSG_HP_SW_UP); + c->msgid = CHECKER_MSGID_UP; return PATH_UP; } From patchwork Tue Oct 30 21:06:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661767 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-2.web.codeaurora.org (Postfix) with ESMTP id 2934A1751 for ; Tue, 30 Oct 2018 22:39:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 192A82AB73 for ; Tue, 30 Oct 2018 22:39:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DD3F2AB79; Tue, 30 Oct 2018 22:39:40 +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 973622AB73 for ; Tue, 30 Oct 2018 22:39:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC3C330820DC; Tue, 30 Oct 2018 22:39:38 +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 869E960C13; Tue, 30 Oct 2018 22:39:38 +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 49E98180B5B7; Tue, 30 Oct 2018 22:39:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7h3s001102 for ; Tue, 30 Oct 2018 17:07:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54B0C612A2; Tue, 30 Oct 2018 21:07:43 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53D4961B73; Tue, 30 Oct 2018 21:07:35 +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 43578308FB97; Tue, 30 Oct 2018 21:07:34 +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); Tue, 30 Oct 2018 15:07:28 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:39 +0100 Message-Id: <20181030210653.29677-9-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:34 +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.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 08/22] libmultipath/checkers: rdac: use message id 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 30 Oct 2018 22:39:39 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/rdac.c | 64 +++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/libmultipath/checkers/rdac.c b/libmultipath/checkers/rdac.c index 5104e4e5..266f8e10 100644 --- a/libmultipath/checkers/rdac.c +++ b/libmultipath/checkers/rdac.c @@ -31,9 +31,7 @@ #define CURRENT_PAGE_CODE_VALUES 0 #define CHANGEABLE_PAGE_CODE_VALUES 1 -#define MSG_RDAC_UP "rdac checker reports path is up" -#define MSG_RDAC_DOWN "rdac checker reports path is down" -#define MSG_RDAC_GHOST "rdac checker reports path is ghost" +#define MSG_RDAC_DOWN " reports path is down" #define MSG_RDAC_DOWN_TYPE(STR) MSG_RDAC_DOWN": "STR #define RTPG_UNAVAILABLE 0x3 @@ -219,41 +217,69 @@ struct volume_access_inq char dontcare1[34]; }; -const char -*checker_msg_string(struct volume_access_inq *inq) +enum { + RDAC_MSGID_NOT_CONN = CHECKER_FIRST_MSGID, + RDAC_MSGID_IN_STARTUP, + RDAC_MSGID_NON_RESPONSIVE, + RDAC_MSGID_IN_RESET, + RDAC_MSGID_FW_DOWNLOADING, + RDAC_MSGID_QUIESCED, + RDAC_MSGID_SERVICE_MODE, + RDAC_MSGID_UNAVAILABLE, + RDAC_MSGID_INQUIRY_FAILED, +}; + +#define _IDX(x) (RDAC_MSGID_##x - CHECKER_FIRST_MSGID) +const char *libcheck_msgtable[] = { + [_IDX(NOT_CONN)] = MSG_RDAC_DOWN_TYPE("lun not connected"), + [_IDX(IN_STARTUP)] = MSG_RDAC_DOWN_TYPE("ctlr is in startup sequence"), + [_IDX(NON_RESPONSIVE)] = + MSG_RDAC_DOWN_TYPE("non-responsive to queries"), + [_IDX(IN_RESET)] = MSG_RDAC_DOWN_TYPE("ctlr held in reset"), + [_IDX(FW_DOWNLOADING)] = + MSG_RDAC_DOWN_TYPE("ctlr firmware downloading"), + [_IDX(QUIESCED)] = MSG_RDAC_DOWN_TYPE("ctlr quiesced by admin request"), + [_IDX(SERVICE_MODE)] = MSG_RDAC_DOWN_TYPE("ctlr is in service mode"), + [_IDX(UNAVAILABLE)] = MSG_RDAC_DOWN_TYPE("ctlr is unavailable"), + [_IDX(INQUIRY_FAILED)] = MSG_RDAC_DOWN_TYPE("inquiry failed"), + NULL, +}; + +static int +checker_msg_string(const struct volume_access_inq *inq) { /* lun not connected */ if (((inq->PQ_PDT & 0xE0) == 0x20) || (inq->PQ_PDT & 0x7f)) - return MSG_RDAC_DOWN_TYPE("lun not connected"); + return RDAC_MSGID_NOT_CONN; /* if no tpg data is available, give the generic path down message */ if (!(inq->avtcvp & 0x10)) - return MSG_RDAC_DOWN; + return CHECKER_MSGID_DOWN; /* controller is booting up */ if (((inq->aas_cur & 0x0F) == RTPG_TRANSITIONING) && (inq->aas_alt & 0x0F) != RTPG_TRANSITIONING) - return MSG_RDAC_DOWN_TYPE("ctlr is in startup sequence"); + return RDAC_MSGID_IN_STARTUP; /* if not unavailable, give generic message */ if ((inq->aas_cur & 0x0F) != RTPG_UNAVAILABLE) - return MSG_RDAC_DOWN; + return CHECKER_MSGID_DOWN; /* target port group unavailable */ switch (inq->vendor_specific_cur) { case RTPG_UNAVAIL_NON_RESPONSIVE: - return MSG_RDAC_DOWN_TYPE("non-responsive to queries"); + return RDAC_MSGID_NON_RESPONSIVE; case RTPG_UNAVAIL_IN_RESET: - return MSG_RDAC_DOWN_TYPE("ctlr held in reset"); + return RDAC_MSGID_IN_RESET; case RTPG_UNAVAIL_CFW_DL1: case RTPG_UNAVAIL_CFW_DL2: - return MSG_RDAC_DOWN_TYPE("ctlr firmware downloading"); + return RDAC_MSGID_FW_DOWNLOADING; case RTPG_UNAVAIL_QUIESCED: - return MSG_RDAC_DOWN_TYPE("ctlr quiesced by admin request"); + return RDAC_MSGID_QUIESCED; case RTPG_UNAVAIL_SERVICE_MODE: - return MSG_RDAC_DOWN_TYPE("ctlr is in service mode"); + return RDAC_MSGID_SERVICE_MODE; default: - return MSG_RDAC_DOWN_TYPE("ctlr is unavailable"); + return RDAC_MSGID_UNAVAILABLE; } } @@ -307,14 +333,14 @@ int libcheck_check(struct checker * c) done: switch (ret) { case PATH_DOWN: - MSG(c, "%s", (inqfail) ? MSG_RDAC_DOWN_TYPE("inquiry failed") : - checker_msg_string(&inq)); + c->msgid = (inqfail ? RDAC_MSGID_INQUIRY_FAILED : + checker_msg_string(&inq)); break; case PATH_UP: - MSG(c, MSG_RDAC_UP); + c->msgid = CHECKER_MSGID_UP; break; case PATH_GHOST: - MSG(c, MSG_RDAC_GHOST); + c->msgid = CHECKER_MSGID_GHOST; break; } From patchwork Tue Oct 30 21:06:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661719 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-2.web.codeaurora.org (Postfix) with ESMTP id D4E7514DE for ; Tue, 30 Oct 2018 22:22:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C13552AB3F for ; Tue, 30 Oct 2018 22:22:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B246B2AB79; Tue, 30 Oct 2018 22:22:58 +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 45EF62AB3F for ; Tue, 30 Oct 2018 22:22:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B92E81DE2; Tue, 30 Oct 2018 22:22:57 +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 0A80160851; Tue, 30 Oct 2018 22:22:57 +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 A79681804750; Tue, 30 Oct 2018 22:22:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7aNC001070 for ; Tue, 30 Oct 2018 17:07:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 02AAF194A8; Tue, 30 Oct 2018 21:07:36 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E04FD19495; Tue, 30 Oct 2018 21:07:35 +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 94BD73082B02; Tue, 30 Oct 2018 21:07:34 +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); Tue, 30 Oct 2018 15:07:29 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:40 +0100 Message-Id: <20181030210653.29677-10-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:35 +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.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 09/22] libmultipath/checkers: readsector0: use message id 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 Oct 2018 22:22:57 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/readsector0.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libmultipath/checkers/readsector0.c b/libmultipath/checkers/readsector0.c index 1c2a868e..cf79e067 100644 --- a/libmultipath/checkers/readsector0.c +++ b/libmultipath/checkers/readsector0.c @@ -6,9 +6,6 @@ #include "checkers.h" #include "libsg.h" -#define MSG_READSECTOR0_UP "readsector0 checker reports path is up" -#define MSG_READSECTOR0_DOWN "readsector0 checker reports path is down" - struct readsector0_checker_context { void * dummy; }; @@ -35,10 +32,10 @@ int libcheck_check (struct checker * c) switch (ret) { case PATH_DOWN: - MSG(c, MSG_READSECTOR0_DOWN); + c->msgid = CHECKER_MSGID_DOWN; break; case PATH_UP: - MSG(c, MSG_READSECTOR0_UP); + c->msgid = CHECKER_MSGID_UP; break; default: break; From patchwork Tue Oct 30 21:06:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661727 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-2.web.codeaurora.org (Postfix) with ESMTP id AE77B13A4 for ; Tue, 30 Oct 2018 22:23:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B40328BDC for ; Tue, 30 Oct 2018 22:23:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B44428C31; Tue, 30 Oct 2018 22:23:29 +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 DE29B28BDC for ; Tue, 30 Oct 2018 22:23:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7728C049581; Tue, 30 Oct 2018 22:23:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EF6616D29; Tue, 30 Oct 2018 22:23:27 +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 69B69EEEB; Tue, 30 Oct 2018 22:23:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7hHn001101 for ; Tue, 30 Oct 2018 17:07:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5615C65926; Tue, 30 Oct 2018 21:07:43 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53CC3612B6; Tue, 30 Oct 2018 21:07:37 +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 5AE4731256A6; Tue, 30 Oct 2018 21:07:36 +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); Tue, 30 Oct 2018 15:07:31 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:41 +0100 Message-Id: <20181030210653.29677-11-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 30 Oct 2018 21:07:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 30 Oct 2018 21:07:36 +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.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 10/22] libmultipath/checkers: tur: use message id 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 30 Oct 2018 22:23:28 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/tur.c | 54 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index a6c88eb2..22734be2 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -29,12 +29,19 @@ #define TUR_CMD_LEN 6 #define HEAVY_CHECK_COUNT 10 -#define MSG_TUR_UP "tur checker reports path is up" -#define MSG_TUR_DOWN "tur checker reports path is down" -#define MSG_TUR_GHOST "tur checker reports path is in standby state" -#define MSG_TUR_RUNNING "tur checker still running" -#define MSG_TUR_TIMEOUT "tur checker timed out" -#define MSG_TUR_FAILED "tur checker failed to initialize" +enum { + MSG_TUR_RUNNING = CHECKER_FIRST_MSGID, + MSG_TUR_TIMEOUT, + MSG_TUR_FAILED, +}; + +#define _IDX(x) (MSG_ ## x - CHECKER_FIRST_MSGID) +const char *libcheck_msgtable[] = { + [_IDX(TUR_RUNNING)] = " still running", + [_IDX(TUR_TIMEOUT)] = " timed out", + [_IDX(TUR_FAILED)] = " failed to initialize", + NULL, +}; struct tur_checker_context { dev_t devt; @@ -47,7 +54,7 @@ struct tur_checker_context { pthread_mutex_t lock; pthread_cond_t active; int holders; /* uatomic access only */ - char message[CHECKER_MSG_LEN]; + int msgid; }; int libcheck_init (struct checker * c) @@ -99,7 +106,7 @@ void libcheck_free (struct checker * c) } static int -tur_check(int fd, unsigned int timeout, char *msg) +tur_check(int fd, unsigned int timeout, short *msgid) { struct sg_io_hdr io_hdr; unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 }; @@ -118,7 +125,7 @@ retry: io_hdr.timeout = timeout * 1000; io_hdr.pack_id = 0; if (ioctl(fd, SG_IO, &io_hdr) < 0) { - snprintf(msg, CHECKER_MSG_LEN, MSG_TUR_DOWN); + *msgid = CHECKER_MSGID_DOWN; return PATH_DOWN; } if ((io_hdr.status & 0x7e) == 0x18) { @@ -126,7 +133,7 @@ retry: * SCSI-3 arrays might return * reservation conflict on TUR */ - snprintf(msg, CHECKER_MSG_LEN, MSG_TUR_UP); + *msgid = CHECKER_MSGID_UP; return PATH_UP; } if (io_hdr.info & SG_INFO_OK_MASK) { @@ -171,14 +178,14 @@ retry: * LOGICAL UNIT NOT ACCESSIBLE, * TARGET PORT IN STANDBY STATE */ - snprintf(msg, CHECKER_MSG_LEN, MSG_TUR_GHOST); + *msgid = CHECKER_MSGID_GHOST; return PATH_GHOST; } } - snprintf(msg, CHECKER_MSG_LEN, MSG_TUR_DOWN); + *msgid = CHECKER_MSGID_DOWN; return PATH_DOWN; } - snprintf(msg, CHECKER_MSG_LEN, MSG_TUR_UP); + *msgid = CHECKER_MSGID_UP; return PATH_UP; } @@ -244,7 +251,7 @@ static void *tur_thread(void *ctx) { struct tur_checker_context *ct = ctx; int state, running; - char msg[CHECKER_MSG_LEN]; + short msgid; /* This thread can be canceled, so setup clean up */ tur_thread_cleanup_push(ct); @@ -254,13 +261,13 @@ static void *tur_thread(void *ctx) minor(ct->devt)); tur_deep_sleep(ct); - state = tur_check(ct->fd, ct->timeout, msg); + state = tur_check(ct->fd, ct->timeout, &msgid); pthread_testcancel(); /* TUR checker done */ pthread_mutex_lock(&ct->lock); ct->state = state; - strlcpy(ct->message, msg, sizeof(ct->message)); + ct->msgid = msgid; pthread_cond_signal(&ct->active); pthread_mutex_unlock(&ct->lock); @@ -313,7 +320,7 @@ int libcheck_check(struct checker * c) return PATH_UNCHECKED; if (c->sync) - return tur_check(c->fd, c->timeout, c->message); + return tur_check(c->fd, c->timeout, &c->msgid); /* * Async mode @@ -325,13 +332,12 @@ int libcheck_check(struct checker * c) pthread_cancel(ct->thread); condlog(3, "%d:%d : tur checker timeout", major(ct->devt), minor(ct->devt)); - MSG(c, MSG_TUR_TIMEOUT); + c->msgid = MSG_TUR_TIMEOUT; tur_status = PATH_TIMEOUT; } else { pthread_mutex_lock(&ct->lock); tur_status = ct->state; - strlcpy(c->message, ct->message, - sizeof(c->message)); + c->msgid = ct->msgid; pthread_mutex_unlock(&ct->lock); } ct->thread = 0; @@ -344,7 +350,7 @@ int libcheck_check(struct checker * c) ct->thread = 0; pthread_mutex_lock(&ct->lock); tur_status = ct->state; - strlcpy(c->message, ct->message, sizeof(c->message)); + c->msgid = ct->msgid; pthread_mutex_unlock(&ct->lock); } } else { @@ -376,7 +382,7 @@ int libcheck_check(struct checker * c) /* Start new TUR checker */ pthread_mutex_lock(&ct->lock); tur_status = ct->state = PATH_PENDING; - ct->message[0] = '\0'; + ct->msgid = CHECKER_MSGID_NONE; pthread_mutex_unlock(&ct->lock); ct->fd = c->fd; ct->timeout = c->timeout; @@ -392,7 +398,7 @@ int libcheck_check(struct checker * c) ct->thread = 0; condlog(3, "%d:%d : failed to start tur thread, using" " sync mode", major(ct->devt), minor(ct->devt)); - return tur_check(c->fd, c->timeout, c->message); + return tur_check(c->fd, c->timeout, &c->msgid); } tur_timeout(&tsp); pthread_mutex_lock(&ct->lock); @@ -401,7 +407,7 @@ int libcheck_check(struct checker * c) &tsp); if (!r) { tur_status = ct->state; - strlcpy(c->message, ct->message, sizeof(c->message)); + c->msgid = ct->msgid; } pthread_mutex_unlock(&ct->lock); if (tur_status == PATH_PENDING) { From patchwork Tue Oct 30 21:06:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661771 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-2.web.codeaurora.org (Postfix) with ESMTP id B6DB73CF1 for ; Tue, 30 Oct 2018 22:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A589D2AB76 for ; Tue, 30 Oct 2018 22:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99D432AB7D; Tue, 30 Oct 2018 22:39:54 +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 346242AB76 for ; Tue, 30 Oct 2018 22:39:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 231BB3082137; Tue, 30 Oct 2018 22:39:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9C3360F87; Tue, 30 Oct 2018 22:39:47 +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 B31AE4CAA0; Tue, 30 Oct 2018 22:39:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7khf001112 for ; Tue, 30 Oct 2018 17:07:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55ABA63140; Tue, 30 Oct 2018 21:07:46 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7FD96149F; Tue, 30 Oct 2018 21:07:37 +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 6FAC2307CDC3; Tue, 30 Oct 2018 21:07:36 +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); Tue, 30 Oct 2018 15:07:32 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:42 +0100 Message-Id: <20181030210653.29677-12-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 21:07:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 21:07:36 +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.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 11/22] multipathd: improve checker message logging 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 30 Oct 2018 22:39:53 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Don't rely on any variables being defined in LOG_MSG. If message log level is low, don't bother to fetch the message. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/main.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index bf5f12a6..904fc693 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -89,12 +89,22 @@ static int use_watchdog; #define FILE_NAME_SIZE 256 #define CMDSIZE 160 -#define LOG_MSG(a, b) \ -do { \ - if (pp->offline) \ - condlog(a, "%s: %s - path offline", pp->mpp->alias, pp->dev); \ - else if (strlen(b)) \ - condlog(a, "%s: %s - %s", pp->mpp->alias, pp->dev, b); \ +#define LOG_MSG(lvl, verb, pp) \ +do { \ + if (lvl <= verb) { \ + if (pp->offline) \ + condlog(lvl, "%s: %s - path offline", \ + pp->mpp->alias, pp->dev); \ + else { \ + const char *__m = \ + checker_message(&pp->checker); \ + \ + if (strlen(__m)) \ + condlog(lvl, "%s: %s - %s", \ + pp->mpp->alias, \ + pp->dev, __m); \ + } \ + } \ } while(0) struct mpath_event_param @@ -1811,7 +1821,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) int add_active; int disable_reinstate = 0; int oldchkrstate = pp->chkrstate; - int retrigger_tries, checkint, max_checkint; + int retrigger_tries, checkint, max_checkint, verbosity; struct config *conf; int ret; @@ -1828,6 +1838,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) retrigger_tries = conf->retrigger_tries; checkint = conf->checkint; max_checkint = conf->max_checkint; + verbosity = conf->verbosity; put_multipath_config(conf); if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV) { if (pp->retriggers < retrigger_tries) { @@ -1970,7 +1981,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) int oldstate = pp->state; pp->state = newstate; - LOG_MSG(1, checker_message(&pp->checker)); + LOG_MSG(1, verbosity, pp); /* * upon state change, reset the checkint @@ -2058,7 +2069,7 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) return 0; } } else { - LOG_MSG(4, checker_message(&pp->checker)); + LOG_MSG(4, verbosity, pp); if (pp->checkint != max_checkint) { /* * double the next check delay. @@ -2088,9 +2099,9 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) log_checker_err = conf->log_checker_err; put_multipath_config(conf); if (log_checker_err == LOG_CHKR_ERR_ONCE) - LOG_MSG(3, checker_message(&pp->checker)); + LOG_MSG(3, verbosity, pp); else - LOG_MSG(2, checker_message(&pp->checker)); + LOG_MSG(2, verbosity, pp); } } From patchwork Tue Oct 30 21:06:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661725 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-2.web.codeaurora.org (Postfix) with ESMTP id 1F32C13A4 for ; Tue, 30 Oct 2018 22:23:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DF322AB09 for ; Tue, 30 Oct 2018 22:23:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 016612AB79; Tue, 30 Oct 2018 22:23:18 +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 9B0C82AB09 for ; Tue, 30 Oct 2018 22:23:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5F73307D856; Tue, 30 Oct 2018 22:23:17 +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 983CB5D75D; Tue, 30 Oct 2018 22:23:17 +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 598FA18005B3; Tue, 30 Oct 2018 22:23:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7dUh001090 for ; Tue, 30 Oct 2018 17:07:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF11E5D784; Tue, 30 Oct 2018 21:07:39 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE6775D778; Tue, 30 Oct 2018 21:07:37 +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 830083082135; Tue, 30 Oct 2018 21:07:36 +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); Tue, 30 Oct 2018 15:07:33 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:43 +0100 Message-Id: <20181030210653.29677-13-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 30 Oct 2018 21:07:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 30 Oct 2018 21:07:36 +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.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 12/22] libmultipath/checkers: support unsupported paths 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Oct 2018 22:23:18 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP We should be able to distinguish the case where a checker determines a path to be positively down from the case where the checker fails to obtain necessary information, e.g. because of a configuration problem (wrong checker). Use PATH_WILD for the latter case, as it's hardly used now. Provide a generic message for the situation that a path checker can't handle a certain path. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers.c | 1 + libmultipath/checkers.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 0bf15f47..b947ddf8 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -279,6 +279,7 @@ static const char *generic_msg[CHECKER_LAST_GENERIC_MSGID] = { [CHECKER_MSGID_UP] = " reports path is up", [CHECKER_MSGID_DOWN] = " reports path is down", [CHECKER_MSGID_GHOST] = " reports path is ghost", + [CHECKER_MSGID_UNSUPPORTED] = " doesn't support this device", }; static const char *_checker_message(const struct checker *c) diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 1d1a116a..dfa60f48 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -10,8 +10,10 @@ * Userspace (multipath/multipathd) path states * * PATH_WILD: - * - Use: None of the checkers (returned if we don't have an fd) - * - Description: Corner case where "fd < 0" for path fd (see checker_check()) + * - Use: Any checker + * - Description: Corner case where "fd < 0" for path fd (see checker_check()), + * or where a checker detects an unsupported device + * (e.g. wrong checker configured for a given device). * * PATH_UNCHECKED: * - Use: Only in directio checker @@ -108,6 +110,7 @@ enum { CHECKER_MSGID_UP, CHECKER_MSGID_DOWN, CHECKER_MSGID_GHOST, + CHECKER_MSGID_UNSUPPORTED, CHECKER_LAST_GENERIC_MSGID, CHECKER_FIRST_MSGID = 100, /* lowest msgid for checkers */ CHECKER_MSGTABLE_SIZE = 100, /* max msg table size for checkers */ From patchwork Tue Oct 30 21:06:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10662219 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-2.web.codeaurora.org (Postfix) with ESMTP id EF58014BD for ; Wed, 31 Oct 2018 08:53:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB459294B5 for ; Wed, 31 Oct 2018 08:53:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCAD129A7F; Wed, 31 Oct 2018 08:53: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=-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 695BB294B5 for ; Wed, 31 Oct 2018 08:53:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5EEFB307B969; Wed, 31 Oct 2018 08:53:24 +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 BD65B5D6A6; Wed, 31 Oct 2018 08:53:22 +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 3B5FA180B5B7; Wed, 31 Oct 2018 08:53:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7cke001085 for ; Tue, 30 Oct 2018 17:07:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id BEC2519495; Tue, 30 Oct 2018 21:07:38 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADA1019745; Tue, 30 Oct 2018 21:07:38 +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 69602312E9CA; Tue, 30 Oct 2018 21:07:37 +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); Tue, 30 Oct 2018 15:07:35 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:44 +0100 Message-Id: <20181030210653.29677-14-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 30 Oct 2018 21:07:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 30 Oct 2018 21:07:37 +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.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Wed, 31 Oct 2018 04:52:41 -0400 Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 13/22] libmultipath: clariion checker: leave unsupported paths alone 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 31 Oct 2018 08:53:25 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP A checker shouldn't set the path state to PATH_DOWN if it fails to obtain information about the path in the first place. Add logic to the checker to distinguish a failed path from an unsupported path. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/checkers/emc_clariion.c | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c index f8e55b93..6fc89113 100644 --- a/libmultipath/checkers/emc_clariion.c +++ b/libmultipath/checkers/emc_clariion.c @@ -20,6 +20,11 @@ #define INQUIRY_CMD 0x12 #define INQUIRY_CMDLEN 6 #define HEAVY_CHECK_COUNT 10 +#define SCSI_COMMAND_TERMINATED 0x22 +#define SCSI_CHECK_CONDITION 0x2 +#define RECOVERED_ERROR 0x01 +#define ILLEGAL_REQUEST 0x05 +#define SG_ERR_DRIVER_SENSE 0x08 /* * Mechanism to track CLARiiON inactive snapshot LUs. @@ -130,7 +135,9 @@ int libcheck_check (struct checker * c) (struct emc_clariion_checker_path_context *)c->context; char wwnstr[33]; int ret; + int retry_emc = 5; +retry: memset(&io_hdr, 0, sizeof (struct sg_io_hdr)); memset(sense_buffer, 0, 128); memset(sb, 0, SENSE_BUFF_LEN); @@ -145,13 +152,60 @@ int libcheck_check (struct checker * c) io_hdr.timeout = c->timeout * 1000; io_hdr.pack_id = 0; if (ioctl(c->fd, SG_IO, &io_hdr) < 0) { + if (errno == ENOTTY) { + c->msgid = CHECKER_MSGID_UNSUPPORTED; + return PATH_WILD; + } c->msgid = MSG_CLARIION_QUERY_FAILED; return PATH_DOWN; } + if (io_hdr.info & SG_INFO_OK_MASK) { + switch (io_hdr.host_status) { + case DID_BUS_BUSY: + case DID_ERROR: + case DID_SOFT_ERROR: + case DID_TRANSPORT_DISRUPTED: + /* Transport error, retry */ + if (--retry_emc) + goto retry; + break; + default: + break; + } + } + + if (SCSI_CHECK_CONDITION == io_hdr.status || + SCSI_COMMAND_TERMINATED == io_hdr.status || + SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status)) { + if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) { + unsigned char *sbp = io_hdr.sbp; + int sense_key; + + if (sbp[0] & 0x2) + sense_key = sbp[1] & 0xf; + else + sense_key = sbp[2] & 0xf; + + if (sense_key == ILLEGAL_REQUEST) { + c->msgid = CHECKER_MSGID_UNSUPPORTED; + return PATH_WILD; + } else if (sense_key != RECOVERED_ERROR) { + condlog(1, "emc_clariion_checker: INQUIRY failed with sense key %02x", + sense_key); + c->msgid = MSG_CLARIION_QUERY_ERROR; + return PATH_DOWN; + } + } + } + + if (io_hdr.info & SG_INFO_OK_MASK) { + condlog(1, "emc_clariion_checker: INQUIRY failed without sense, status %02x", + io_hdr.status); c->msgid = MSG_CLARIION_QUERY_ERROR; return PATH_DOWN; } + if (/* Verify the code page - right page & revision */ sense_buffer[1] != 0xc0 || sense_buffer[9] != 0x00) { c->msgid = MSG_CLARIION_UNIT_REPORT; From patchwork Tue Oct 30 21:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661775 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-2.web.codeaurora.org (Postfix) with ESMTP id BE14615E9 for ; Tue, 30 Oct 2018 22:39:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE55A2AB73 for ; Tue, 30 Oct 2018 22:39:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A238A2AB79; Tue, 30 Oct 2018 22:39:59 +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 41D842AB73 for ; Tue, 30 Oct 2018 22:39:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 649F4307D867; Tue, 30 Oct 2018 22:39:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28D5F60F87; Tue, 30 Oct 2018 22:39:58 +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 CC13B4CAA8; Tue, 30 Oct 2018 22:39:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7mkc001117 for ; Tue, 30 Oct 2018 17:07:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 91DB9194B4; Tue, 30 Oct 2018 21:07:48 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FCBB19495; Tue, 30 Oct 2018 21:07:48 +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 612E03082A27; Tue, 30 Oct 2018 21:07:47 +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); Tue, 30 Oct 2018 15:07:36 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:45 +0100 Message-Id: <20181030210653.29677-15-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:47 +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.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 14/22] libmultipath: hp_sw checker: leave unsupported paths alone 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Oct 2018 22:39:58 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP A checker shouldn't set the path state to PATH_DOWN if it fails to obtain information about the path in the first place. Add logic to the checker to distinguish a failed path from an unsupported path. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/hp_sw.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/libmultipath/checkers/hp_sw.c b/libmultipath/checkers/hp_sw.c index d7f1018c..1a820223 100644 --- a/libmultipath/checkers/hp_sw.c +++ b/libmultipath/checkers/hp_sw.c @@ -24,6 +24,7 @@ #define SCSI_COMMAND_TERMINATED 0x22 #define SG_ERR_DRIVER_SENSE 0x08 #define RECOVERED_ERROR 0x01 +#define ILLEGAL_REQUEST 0x05 #define MX_ALLOC_LEN 255 #define HEAVY_CHECK_COUNT 10 @@ -68,14 +69,19 @@ do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op, io_hdr.sbp = sense_b; io_hdr.timeout = timeout * 1000; - if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) - return 1; + if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) { + if (errno == ENOTTY) + return PATH_WILD; + else + return PATH_DOWN; + } /* treat SG_ERR here to get rid of sg_err.[ch] */ io_hdr.status &= 0x7e; if ((0 == io_hdr.status) && (0 == io_hdr.host_status) && (0 == io_hdr.driver_status)) - return 0; + return PATH_UP; + if ((SCSI_CHECK_CONDITION == io_hdr.status) || (SCSI_COMMAND_TERMINATED == io_hdr.status) || (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) { @@ -86,11 +92,13 @@ do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op, sense_key = sense_buffer[1] & 0xf; else sense_key = sense_buffer[2] & 0xf; - if(RECOVERED_ERROR == sense_key) - return 0; + if (RECOVERED_ERROR == sense_key) + return PATH_UP; + else if (ILLEGAL_REQUEST == sense_key) + return PATH_WILD; } } - return 1; + return PATH_DOWN; } static int @@ -122,10 +130,15 @@ do_tur (int fd, unsigned int timeout) int libcheck_check(struct checker * c) { char buff[MX_ALLOC_LEN]; + int ret = do_inq(c->fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0, c->timeout); - if (0 != do_inq(c->fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0, c->timeout)) { + if (ret == PATH_WILD) { + c->msgid = CHECKER_MSGID_UNSUPPORTED; + return ret; + } + if (ret != PATH_UP) { c->msgid = CHECKER_MSGID_DOWN; - return PATH_DOWN; + return ret; }; if (do_tur(c->fd, c->timeout)) { From patchwork Tue Oct 30 21:06:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661731 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-2.web.codeaurora.org (Postfix) with ESMTP id 2924714DE for ; Tue, 30 Oct 2018 22:23:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1969528BDC for ; Tue, 30 Oct 2018 22:23:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DCCD28C31; Tue, 30 Oct 2018 22:23:50 +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 9F21828BDC for ; Tue, 30 Oct 2018 22:23:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F5123091749; Tue, 30 Oct 2018 22:23:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54B8760C1A; Tue, 30 Oct 2018 22:23:48 +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 09D15EF05; Tue, 30 Oct 2018 22:23:48 +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 w9UL7sOL001165 for ; Tue, 30 Oct 2018 17:07:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 736FA106A79A; Tue, 30 Oct 2018 21:07:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDB21104C456; Tue, 30 Oct 2018 21:07:48 +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 81AAB3082A32; Tue, 30 Oct 2018 21:07:47 +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); Tue, 30 Oct 2018 15:07:37 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:46 +0100 Message-Id: <20181030210653.29677-16-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 30 Oct 2018 21:07:47 +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.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 15/22] libmultipath: rdac checker: leave unsupported paths alone 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Oct 2018 22:23:49 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP A checker shouldn't set the path state to PATH_DOWN if it fails to obtain information about the path in the first place. Add logic to the checker to distinguish a failed path from an unsupported path. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/rdac.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/libmultipath/checkers/rdac.c b/libmultipath/checkers/rdac.c index 266f8e10..8a3b73ec 100644 --- a/libmultipath/checkers/rdac.c +++ b/libmultipath/checkers/rdac.c @@ -26,6 +26,7 @@ #define SCSI_COMMAND_TERMINATED 0x22 #define SG_ERR_DRIVER_SENSE 0x08 #define RECOVERED_ERROR 0x01 +#define ILLEGAL_REQUEST 0x05 #define CURRENT_PAGE_CODE_VALUES 0 @@ -162,14 +163,14 @@ retry: io_hdr.sbp = sense_b; io_hdr.timeout = timeout * 1000; - if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) - return 1; + if (ioctl(sg_fd, SG_IO, &io_hdr) < 0 && errno == ENOTTY) + return PATH_WILD; /* treat SG_ERR here to get rid of sg_err.[ch] */ io_hdr.status &= 0x7e; if ((0 == io_hdr.status) && (0 == io_hdr.host_status) && (0 == io_hdr.driver_status)) - return 0; + return PATH_UP; /* check if we need to retry this error */ if (io_hdr.info & SG_INFO_OK_MASK) { @@ -198,10 +199,14 @@ retry: else sense_key = sense_buffer[2] & 0xf; if (RECOVERED_ERROR == sense_key) - return 0; + return PATH_UP; + else if (ILLEGAL_REQUEST == sense_key) + return PATH_WILD; + condlog(1, "rdac checker: INQUIRY failed with sense key %02x", + sense_key); } } - return 1; + return PATH_DOWN; } struct volume_access_inq @@ -290,12 +295,14 @@ int libcheck_check(struct checker * c) inqfail = 0; memset(&inq, 0, sizeof(struct volume_access_inq)); - if (0 != do_inq(c->fd, 0xC9, &inq, sizeof(struct volume_access_inq), - c->timeout)) { - ret = PATH_DOWN; + ret = do_inq(c->fd, 0xC9, &inq, sizeof(struct volume_access_inq), + c->timeout); + if (ret != PATH_UP) { inqfail = 1; goto done; - } else if (((inq.PQ_PDT & 0xE0) == 0x20) || (inq.PQ_PDT & 0x7f)) { + } + + if (((inq.PQ_PDT & 0xE0) == 0x20) || (inq.PQ_PDT & 0x7f)) { /* LUN not connected*/ ret = PATH_DOWN; goto done; @@ -332,6 +339,9 @@ int libcheck_check(struct checker * c) done: switch (ret) { + case PATH_WILD: + c->msgid = CHECKER_MSGID_UNSUPPORTED; + break; case PATH_DOWN: c->msgid = (inqfail ? RDAC_MSGID_INQUIRY_FAILED : checker_msg_string(&inq)); From patchwork Tue Oct 30 21:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661763 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-2.web.codeaurora.org (Postfix) with ESMTP id 2492D1751 for ; Tue, 30 Oct 2018 22:39:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1407B2AB66 for ; Tue, 30 Oct 2018 22:39:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 082772AB76; Tue, 30 Oct 2018 22:39:29 +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 B16522AB66 for ; Tue, 30 Oct 2018 22:39:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5D7258E25; Tue, 30 Oct 2018 22:39:27 +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 9C1C719745; Tue, 30 Oct 2018 22:39:27 +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 58825180B5B7; Tue, 30 Oct 2018 22:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7sBS001170 for ; Tue, 30 Oct 2018 17:07:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id B677E62535; Tue, 30 Oct 2018 21:07:54 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F908672C8; Tue, 30 Oct 2018 21:07:48 +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 A231C30821EB; Tue, 30 Oct 2018 21:07:47 +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); Tue, 30 Oct 2018 15:07:38 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:47 +0100 Message-Id: <20181030210653.29677-17-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 30 Oct 2018 21:07:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 30 Oct 2018 21:07:47 +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.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 16/22] libmultipath: tur checker: leave unsupported paths alone 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 30 Oct 2018 22:39:28 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP A checker shouldn't set the path state to PATH_DOWN if it fails to obtain information about the path in the first place. Add logic to the checker to distinguish a failed path from an unsupported path. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers/tur.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index 22734be2..a27474f9 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -125,6 +125,10 @@ retry: io_hdr.timeout = timeout * 1000; io_hdr.pack_id = 0; if (ioctl(fd, SG_IO, &io_hdr) < 0) { + if (errno == ENOTTY) { + *msgid = CHECKER_MSGID_UNSUPPORTED; + return PATH_WILD; + } *msgid = CHECKER_MSGID_DOWN; return PATH_DOWN; } From patchwork Tue Oct 30 21:06:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661751 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-2.web.codeaurora.org (Postfix) with ESMTP id 7502114E2 for ; Tue, 30 Oct 2018 22:38:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 622822A1A9 for ; Tue, 30 Oct 2018 22:38:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 533EC2A1F9; Tue, 30 Oct 2018 22:38:47 +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 D8E362A1A9 for ; Tue, 30 Oct 2018 22:38:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8F1930833AF; Tue, 30 Oct 2018 22:38:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A39AF601A7; Tue, 30 Oct 2018 22:38:45 +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 6E2F84CA94; Tue, 30 Oct 2018 22:38:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7nXT001122 for ; Tue, 30 Oct 2018 17:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C8B063759; Tue, 30 Oct 2018 21:07:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFC6365309; Tue, 30 Oct 2018 21:07:48 +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 C1A8E307CDC6; Tue, 30 Oct 2018 21:07:47 +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); Tue, 30 Oct 2018 15:07:40 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:48 +0100 Message-Id: <20181030210653.29677-18-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 21:07:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 21:07:48 +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.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 17/22] libmultipath: pathinfo: don't blank wwid if checker fails 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 30 Oct 2018 22:38:46 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Blanking a WWID is a dangerous operation. E.g. configure() would consider the path in question as invalid and orphan it if the WWID is blank. Don't do this checker failures which may be transient or indicate a badly configured or otherwise malfunctioning checker. Moreover, we try to determine WWID even if path_offline returns PATH_DOWN in the first place, so why should we not if the checker has a problem? Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 3550c3a7..467ece7a 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1944,9 +1944,6 @@ int pathinfo(struct path *pp, struct config *conf, int mask) if (path_state == PATH_UP) { pp->chkrstate = pp->state = get_state(pp, conf, 0, path_state); - if (pp->state == PATH_UNCHECKED || - pp->state == PATH_WILD) - goto blank; if (pp->state == PATH_TIMEOUT) pp->state = PATH_DOWN; if (pp->state == PATH_UP && !pp->size) { From patchwork Tue Oct 30 21:06:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661753 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-2.web.codeaurora.org (Postfix) with ESMTP id 2D9BB14E2 for ; Tue, 30 Oct 2018 22:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E4A12AB2B for ; Tue, 30 Oct 2018 22:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12D6D2AB66; Tue, 30 Oct 2018 22:38: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 B3D952AB2B for ; Tue, 30 Oct 2018 22:38:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B641581DEA; Tue, 30 Oct 2018 22:38:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EF4860CD7; Tue, 30 Oct 2018 22:38: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 408A04CAA0; Tue, 30 Oct 2018 22:38:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7oU8001132 for ; Tue, 30 Oct 2018 17:07:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0A3805EDE1; Tue, 30 Oct 2018 21:07:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E53575D77E; Tue, 30 Oct 2018 21:07:49 +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 DE1703154854; Tue, 30 Oct 2018 21:07:47 +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); Tue, 30 Oct 2018 15:07:41 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:49 +0100 Message-Id: <20181030210653.29677-19-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Oct 2018 21:07:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 30 Oct 2018 21:07:48 +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.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 18/22] multipathd: check_path: improve logging for "unusable path" case 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 Oct 2018 22:38:56 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multipathd/main.c b/multipathd/main.c index 904fc693..e80ac906 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1895,7 +1895,8 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) } if (newstate == PATH_WILD || newstate == PATH_UNCHECKED) { - condlog(2, "%s: unusable path", pp->dev); + condlog(2, "%s: unusable path - checker failed", pp->dev); + LOG_MSG(2, verbosity, pp); conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); pathinfo(pp, conf, 0); From patchwork Tue Oct 30 21:06:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661781 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-2.web.codeaurora.org (Postfix) with ESMTP id E44513E9D for ; Tue, 30 Oct 2018 22:40:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D32C32AB7D for ; Tue, 30 Oct 2018 22:40:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C79EB2AB8C; Tue, 30 Oct 2018 22:40:20 +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 7991C2AB81 for ; Tue, 30 Oct 2018 22:40:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CD9A81DED; Tue, 30 Oct 2018 22:40:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55EBE60C7A; Tue, 30 Oct 2018 22:40:19 +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 EBF8E4CAAE; Tue, 30 Oct 2018 22:40:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7o8v001137 for ; Tue, 30 Oct 2018 17:07:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 593BA605A8; Tue, 30 Oct 2018 21:07:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7C1060487; Tue, 30 Oct 2018 21:07:49 +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 0A149C058CA2; Tue, 30 Oct 2018 21:07:48 +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); Tue, 30 Oct 2018 15:07:42 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:50 +0100 Message-Id: <20181030210653.29677-20-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 30 Oct 2018 21:07:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 30 Oct 2018 21:07:48 +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.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 19/22] libmultipath: coalesce_paths: improve logging of orphaned paths 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 Oct 2018 22:40:20 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/configure.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 09c3dcf2..ed3e30f5 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -1020,14 +1020,18 @@ int coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, } } vector_foreach_slot (pathvec, pp1, k) { - int invalid = 0; + int invalid; /* skip this path for some reason */ /* 1. if path has no unique id or wwid blacklisted */ + if (strlen(pp1->wwid) == 0) { + orphan_path(pp1, "no WWID"); + continue; + } + conf = get_multipath_config(); pthread_cleanup_push(put_multipath_config, conf); - if (strlen(pp1->wwid) == 0 || filter_path(conf, pp1) > 0) - invalid = 1; + invalid = (filter_path(conf, pp1) > 0); pthread_cleanup_pop(1); if (invalid) { orphan_path(pp1, "blacklisted"); From patchwork Tue Oct 30 21:06:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661779 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-2.web.codeaurora.org (Postfix) with ESMTP id DD21A15E9 for ; Tue, 30 Oct 2018 22:40:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD55C2AB79 for ; Tue, 30 Oct 2018 22:40:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C19EA2AB81; Tue, 30 Oct 2018 22:40:09 +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 6F4E32AB79 for ; Tue, 30 Oct 2018 22:40:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81AD92D7E1; Tue, 30 Oct 2018 22:40:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50D046046B; Tue, 30 Oct 2018 22:40:08 +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 068254CAA8; Tue, 30 Oct 2018 22:40:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7nUf001127 for ; Tue, 30 Oct 2018 17:07:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id D4CD1194A8; Tue, 30 Oct 2018 21:07:49 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C67F019495; Tue, 30 Oct 2018 21:07:49 +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 5E61D9091A; Tue, 30 Oct 2018 21:07:48 +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); Tue, 30 Oct 2018 15:07:44 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:51 +0100 Message-Id: <20181030210653.29677-21-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 30 Oct 2018 21:07:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 30 Oct 2018 21:07:48 +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.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 20/22] libmultipath: sync_map_state: log failing paths 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 22:40:09 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Emit a log message when force-failing exisiting paths. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/structs_vec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index f87d69d4..c85823a0 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -318,8 +318,11 @@ sync_map_state(struct multipath *mpp) else if ((pp->dmstate == PSTATE_ACTIVE || pp->dmstate == PSTATE_UNDEF) && (pp->state == PATH_DOWN || - pp->state == PATH_SHAKY)) + pp->state == PATH_SHAKY)) { + condlog(2, "sync_map_state: failing %s state %d dmstate %d", + pp->dev, pp->state, pp->dmstate); dm_fail_path(mpp->alias, pp->dev_t); + } } } } From patchwork Tue Oct 30 21:06:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661755 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-2.web.codeaurora.org (Postfix) with ESMTP id 13F241751 for ; Tue, 30 Oct 2018 22:39:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0278B2AB2F for ; Tue, 30 Oct 2018 22:39:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB462AB66; Tue, 30 Oct 2018 22:39:07 +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 1AFFB2AB2F for ; Tue, 30 Oct 2018 22:39:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0EA8B308625A; Tue, 30 Oct 2018 22:39:06 +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 D57C7612B1; Tue, 30 Oct 2018 22:39:05 +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 9C3591804750; Tue, 30 Oct 2018 22:39:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL7oL1001142 for ; Tue, 30 Oct 2018 17:07:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id A82DA19495; Tue, 30 Oct 2018 21:07:50 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96D8A19745; Tue, 30 Oct 2018 21:07:50 +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 AF88F3097022; Tue, 30 Oct 2018 21:07:48 +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); Tue, 30 Oct 2018 15:07:45 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:52 +0100 Message-Id: <20181030210653.29677-22-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 21:07:49 +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.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 21/22] libmultipath/checkers: cleanup class/instance model 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 30 Oct 2018 22:39:06 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The checkers code implicitly uses a sort-of OOP class/instance model, but very clumsily. Separate the checker "class" and "instance" cleanly, and do a few further cleanups (constifications etc) on the way. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/checkers.c | 137 ++++++++++++++++--------------- libmultipath/checkers.h | 23 ++---- libmultipath/checkers/directio.c | 2 +- libmultipath/checkers/tur.c | 2 +- libmultipath/print.c | 2 +- libmultipath/propsel.c | 19 +++-- 6 files changed, 92 insertions(+), 93 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index b947ddf8..9a19c9a6 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -8,6 +8,19 @@ #include "checkers.h" #include "vector.h" +struct checker_class { + struct list_head node; + void *handle; + int refcount; + int sync; + char name[CHECKER_NAME_LEN]; + int (*check)(struct checker *); + int (*init)(struct checker *); /* to allocate the context */ + void (*free)(struct checker *); /* to free the context */ + const char **msgtable; + short msgtable_size; +}; + char *checker_state_names[] = { "wild", "unchecked", @@ -23,38 +36,30 @@ char *checker_state_names[] = { static LIST_HEAD(checkers); -char * checker_state_name (int i) +const char *checker_state_name(int i) { return checker_state_names[i]; } -int init_checkers (char *multipath_dir) -{ - if (!add_checker(multipath_dir, DEFAULT_CHECKER)) - return 1; - return 0; -} - -struct checker * alloc_checker (void) +static struct checker_class *alloc_checker_class(void) { - struct checker *c; + struct checker_class *c; - c = MALLOC(sizeof(struct checker)); + c = MALLOC(sizeof(struct checker_class)); if (c) { INIT_LIST_HEAD(&c->node); c->refcount = 1; - c->fd = -1; } return c; } -void free_checker (struct checker * c) +void free_checker_class(struct checker_class *c) { if (!c) return; c->refcount--; if (c->refcount) { - condlog(3, "%s checker refcount %d", + condlog(4, "%s checker refcount %d", c->name, c->refcount); return; } @@ -71,17 +76,17 @@ void free_checker (struct checker * c) void cleanup_checkers (void) { - struct checker * checker_loop; - struct checker * checker_temp; + struct checker_class *checker_loop; + struct checker_class *checker_temp; list_for_each_entry_safe(checker_loop, checker_temp, &checkers, node) { - free_checker(checker_loop); + free_checker_class(checker_loop); } } -struct checker * checker_lookup (char * name) +static struct checker_class *checker_class_lookup(const char *name) { - struct checker * c; + struct checker_class *c; if (!name || !strlen(name)) return NULL; @@ -92,14 +97,15 @@ struct checker * checker_lookup (char * name) return NULL; } -struct checker * add_checker (char *multipath_dir, char * name) +static struct checker_class *add_checker_class(const char *multipath_dir, + const char *name) { char libname[LIB_CHECKER_NAMELEN]; struct stat stbuf; - struct checker * c; + struct checker_class *c; char *errstr; - c = alloc_checker(); + c = alloc_checker_class(); if (!c) return NULL; snprintf(c->name, CHECKER_NAME_LEN, "%s", name); @@ -158,12 +164,11 @@ struct checker * add_checker (char *multipath_dir, char * name) c->name, c->msgtable_size); done: - c->fd = -1; c->sync = 1; list_add(&c->node, &checkers); return c; out: - free_checker(c); + free_checker_class(c); return NULL; } @@ -176,16 +181,16 @@ void checker_set_fd (struct checker * c, int fd) void checker_set_sync (struct checker * c) { - if (!c) + if (!c || !c->cls) return; - c->sync = 1; + c->cls->sync = 1; } void checker_set_async (struct checker * c) { - if (!c) + if (!c || !c->cls) return; - c->sync = 0; + c->cls->sync = 0; } void checker_enable (struct checker * c) @@ -204,11 +209,11 @@ void checker_disable (struct checker * c) int checker_init (struct checker * c, void ** mpctxt_addr) { - if (!c) + if (!c || !c->cls) return 1; c->mpcontext = mpctxt_addr; - if (c->init) - return c->init(c); + if (c->cls->init) + return c->cls->init(c); return 0; } @@ -220,15 +225,16 @@ void checker_clear (struct checker *c) void checker_put (struct checker * dst) { - struct checker * src; + struct checker_class *src; - if (!dst || !strlen(dst->name)) + if (!dst) return; - src = checker_lookup(dst->name); - if (dst->free) - dst->free(dst); + src = dst->cls; + + if (src && src->free) + src->free(dst); checker_clear(dst); - free_checker(src); + free_checker_class(src); } int checker_check (struct checker * c, int path_state) @@ -243,32 +249,35 @@ int checker_check (struct checker * c, int path_state) c->msgid = CHECKER_MSGID_DISABLED; return PATH_UNCHECKED; } - if (!strncmp(c->name, NONE, 4)) + if (!strncmp(c->cls->name, NONE, 4)) return path_state; if (c->fd < 0) { c->msgid = CHECKER_MSGID_NO_FD; return PATH_WILD; } - r = c->check(c); + r = c->cls->check(c); return r; } -int checker_selected (struct checker * c) +int checker_selected(const struct checker *c) { if (!c) return 0; - if (!strncmp(c->name, NONE, 4)) - return 1; - return (c->check) ? 1 : 0; + return c->cls != NULL; } const char *checker_name(const struct checker *c) { - if (!c) + if (!c || !c->cls) return NULL; - return c->name; + return c->cls->name; +} + +int checker_is_sync(const struct checker *c) +{ + return c && c->cls && c->cls->sync; } static const char *generic_msg[CHECKER_LAST_GENERIC_MSGID] = { @@ -295,8 +304,8 @@ static const char *_checker_message(const struct checker *c) return generic_msg[c->msgid]; id = c->msgid - CHECKER_FIRST_MSGID; - if (id < c->msgtable_size) - return c->msgtable[id]; + if (id < c->cls->msgtable_size) + return c->cls->msgtable[id]; return NULL; } @@ -309,7 +318,7 @@ char *checker_message(const struct checker *c) *buf = '\0'; else snprintf(buf, sizeof(buf), "%s checker%s", - c->name, msg); + c->cls->name, msg); return buf; } @@ -320,31 +329,29 @@ void checker_clear_message (struct checker *c) c->msgid = CHECKER_MSGID_NONE; } -void checker_get (char *multipath_dir, struct checker * dst, char * name) +void checker_get(const char *multipath_dir, struct checker *dst, + const char *name) { - struct checker * src = NULL; + struct checker_class *src = NULL; if (!dst) return; if (name && strlen(name)) { - src = checker_lookup(name); + src = checker_class_lookup(name); if (!src) - src = add_checker(multipath_dir, name); + src = add_checker_class(multipath_dir, name); } - if (!src) { - dst->check = NULL; + dst->cls = src; + if (!src) return; - } - dst->fd = src->fd; - dst->sync = src->sync; - strncpy(dst->name, src->name, CHECKER_NAME_LEN); - dst->msgid = CHECKER_MSGID_NONE; - dst->check = src->check; - dst->init = src->init; - dst->free = src->free; - dst->msgtable = src->msgtable; - dst->msgtable_size = src->msgtable_size; - dst->handle = NULL; + src->refcount++; } + +int init_checkers(const char *multipath_dir) +{ + if (!add_checker_class(multipath_dir, DEFAULT_CHECKER)) + return 1; + return 0; +} diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index dfa60f48..834efcfe 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -116,32 +116,22 @@ enum { CHECKER_MSGTABLE_SIZE = 100, /* max msg table size for checkers */ }; +struct checker_class; struct checker { - struct list_head node; - void *handle; - int refcount; + struct checker_class *cls; int fd; - int sync; unsigned int timeout; int disable; - char name[CHECKER_NAME_LEN]; short msgid; /* checker-internal extra status */ void * context; /* store for persistent data */ void ** mpcontext; /* store for persistent data shared multipath-wide. Use MALLOC if you want to stuff data in. */ - int (*check)(struct checker *); - int (*init)(struct checker *); /* to allocate the context */ - void (*free)(struct checker *); /* to free the context */ - const char**msgtable; - short msgtable_size; }; -char * checker_state_name (int); -int init_checkers (char *); +const char *checker_state_name(int); +int init_checkers(const char *); void cleanup_checkers (void); -struct checker * add_checker (char *, char *); -struct checker * checker_lookup (char *); int checker_init (struct checker *, void **); void checker_clear (struct checker *); void checker_put (struct checker *); @@ -152,11 +142,12 @@ void checker_set_fd (struct checker *, int); void checker_enable (struct checker *); void checker_disable (struct checker *); int checker_check (struct checker *, int); -int checker_selected (struct checker *); +int checker_selected(const struct checker *); +int checker_is_sync(const struct checker *); const char *checker_name (const struct checker *); char *checker_message (const struct checker *); void checker_clear_message (struct checker *c); -void checker_get (char *, struct checker *, char *); +void checker_get(const char *, struct checker *, const char *); /* Prototypes for symbols exported by path checker dynamic libraries (.so) */ int libcheck_check(struct checker *); diff --git a/libmultipath/checkers/directio.c b/libmultipath/checkers/directio.c index c4a0712e..1b00b775 100644 --- a/libmultipath/checkers/directio.c +++ b/libmultipath/checkers/directio.c @@ -202,7 +202,7 @@ int libcheck_check (struct checker * c) if (!ct) return PATH_UNCHECKED; - ret = check_state(c->fd, ct, c->sync, c->timeout); + ret = check_state(c->fd, ct, checker_is_sync(c), c->timeout); switch (ret) { diff --git a/libmultipath/checkers/tur.c b/libmultipath/checkers/tur.c index a27474f9..63b19624 100644 --- a/libmultipath/checkers/tur.c +++ b/libmultipath/checkers/tur.c @@ -323,7 +323,7 @@ int libcheck_check(struct checker * c) if (!ct) return PATH_UNCHECKED; - if (c->sync) + if (checker_is_sync(c)) return tur_check(c->fd, c->timeout, &c->msgid); /* diff --git a/libmultipath/print.c b/libmultipath/print.c index 7b610b94..fc40b0f0 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -615,7 +615,7 @@ static int snprint_path_checker (char * buff, size_t len, const struct path * pp) { const struct checker * c = &pp->checker; - return snprint_str(buff, len, c->name); + return snprint_str(buff, len, checker_name(c)); } static int diff --git a/libmultipath/propsel.c b/libmultipath/propsel.c index fdb5953a..970a3b5c 100644 --- a/libmultipath/propsel.c +++ b/libmultipath/propsel.c @@ -479,26 +479,27 @@ check_rdac(struct path * pp) int select_checker(struct config *conf, struct path *pp) { const char *origin; - char *checker_name; + char *ckr_name; struct checker * c = &pp->checker; if (pp->detect_checker == DETECT_CHECKER_ON) { origin = autodetect_origin; if (check_rdac(pp)) { - checker_name = RDAC; + ckr_name = RDAC; goto out; } else if (pp->tpgs > 0) { - checker_name = TUR; + ckr_name = TUR; goto out; } } - do_set(checker_name, conf->overrides, checker_name, overrides_origin); - do_set_from_hwe(checker_name, pp, checker_name, hwe_origin); - do_set(checker_name, conf, checker_name, conf_origin); - do_default(checker_name, DEFAULT_CHECKER); + do_set(checker_name, conf->overrides, ckr_name, overrides_origin); + do_set_from_hwe(checker_name, pp, ckr_name, hwe_origin); + do_set(checker_name, conf, ckr_name, conf_origin); + do_default(ckr_name, DEFAULT_CHECKER); out: - checker_get(conf->multipath_dir, c, checker_name); - condlog(3, "%s: path_checker = %s %s", pp->dev, c->name, origin); + checker_get(conf->multipath_dir, c, ckr_name); + condlog(3, "%s: path_checker = %s %s", pp->dev, + checker_name(c), origin); if (conf->checker_timeout) { c->timeout = conf->checker_timeout; condlog(3, "%s: checker timeout = %u s %s", From patchwork Tue Oct 30 21:06:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10661765 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-2.web.codeaurora.org (Postfix) with ESMTP id 3C1DC1751 for ; Tue, 30 Oct 2018 22:39:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 280B22AB73 for ; Tue, 30 Oct 2018 22:39:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C5432AB79; Tue, 30 Oct 2018 22:39:39 +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 AAA402AB73 for ; Tue, 30 Oct 2018 22:39:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC612308FB9E; Tue, 30 Oct 2018 22:39:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A008560C1D; Tue, 30 Oct 2018 22:39:37 +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 65D6B4CAA0; Tue, 30 Oct 2018 22:39:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9UL81f6001180 for ; Tue, 30 Oct 2018 17:08:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6AADF65969; Tue, 30 Oct 2018 21:08:01 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DCEE6533E; Tue, 30 Oct 2018 21:07:58 +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 7BB252D7F1; Tue, 30 Oct 2018 21:07:57 +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); Tue, 30 Oct 2018 15:07:46 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 30 Oct 2018 22:06:53 +0100 Message-Id: <20181030210653.29677-23-mwilck@suse.com> In-Reply-To: <20181030210653.29677-1-mwilck@suse.com> References: <20181030210653.29677-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 21:07:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 Oct 2018 21:07:57 +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.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Martin Wilck , dm-devel@redhat.com Subject: [dm-devel] [PATCH v3 22/22] libmultipath: make checker_message thread safe 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Tue, 30 Oct 2018 22:39:38 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Get rid of the static char buffer in checker_message() introduced in the previous "replace message by msgid" patch. Signed-off-by: Martin Wilck --- libmultipath/checkers.c | 23 ++++++++++++++++++----- libmultipath/checkers.h | 4 +++- libmultipath/discovery.c | 9 ++++++--- multipathd/main.c | 11 +++++------ 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c index 9a19c9a6..f65a9476 100644 --- a/libmultipath/checkers.c +++ b/libmultipath/checkers.c @@ -309,16 +309,29 @@ static const char *_checker_message(const struct checker *c) return NULL; } +int checker_has_message(const struct checker *c) +{ + const char *msg = _checker_message(c); + + if (msg == NULL || *msg == '\0') + return 0; + return 1; +} + char *checker_message(const struct checker *c) { - static char buf[CHECKER_MSG_LEN]; + char *buf; const char *msg = _checker_message(c); + int len; if (msg == NULL || *msg == '\0') - *buf = '\0'; - else - snprintf(buf, sizeof(buf), "%s checker%s", - c->cls->name, msg); + return NULL; + + len = CHECKER_NAME_LEN + 8 + CHECKER_MSG_LEN; + buf = MALLOC(len); + if (buf == NULL) + return NULL; + snprintf(buf, len, "%s checker%s", c->cls->name, msg); return buf; } diff --git a/libmultipath/checkers.h b/libmultipath/checkers.h index 834efcfe..2c71e40c 100644 --- a/libmultipath/checkers.h +++ b/libmultipath/checkers.h @@ -145,7 +145,9 @@ int checker_check (struct checker *, int); int checker_selected(const struct checker *); int checker_is_sync(const struct checker *); const char *checker_name (const struct checker *); -char *checker_message (const struct checker *); +/* checker_message(): returned pointer is malloc()d */ +char *checker_message(const struct checker *); +int checker_has_message(const struct checker *); void checker_clear_message (struct checker *c); void checker_get(const char *, struct checker *, const char *); diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index 467ece7a..0bcd3c39 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1588,9 +1588,12 @@ get_state (struct path * pp, struct config *conf, int daemon, int oldstate) condlog(3, "%s: %s state = %s", pp->dev, checker_name(c), checker_state_name(state)); if (state != PATH_UP && state != PATH_GHOST && - strlen(checker_message(c))) - condlog(3, "%s: checker msg is \"%s\"", - pp->dev, checker_message(c)); + checker_has_message(c)) { + char *msg = checker_message(c); + + condlog(3, "%s: checker msg is \"%s\"", pp->dev, msg); + FREE(msg); + } return state; } diff --git a/multipathd/main.c b/multipathd/main.c index e80ac906..fcf0d2db 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -95,14 +95,13 @@ do { \ if (pp->offline) \ condlog(lvl, "%s: %s - path offline", \ pp->mpp->alias, pp->dev); \ - else { \ - const char *__m = \ + else if (checker_has_message(&pp->checker)) { \ + char *__m = \ checker_message(&pp->checker); \ \ - if (strlen(__m)) \ - condlog(lvl, "%s: %s - %s", \ - pp->mpp->alias, \ - pp->dev, __m); \ + condlog(lvl, "%s: %s - %s", \ + pp->mpp->alias, pp->dev, __m); \ + FREE(__m); \ } \ } \ } while(0)