From patchwork Fri Nov 2 12:23:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665385 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 CFD3E14E2 for ; Fri, 2 Nov 2018 12:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4A6D2B2D5 for ; Fri, 2 Nov 2018 12:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A75E72B2E3; Fri, 2 Nov 2018 12:31: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 4EBA92B2D5 for ; Fri, 2 Nov 2018 12:31:58 +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 12BA9D5543; Fri, 2 Nov 2018 12:31:57 +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 D23E760C55; Fri, 2 Nov 2018 12:31:56 +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 72EB64BB79; Fri, 2 Nov 2018 12:31:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wA2COXKi011901 for ; Fri, 2 Nov 2018 08:24:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4FA1611AB; Fri, 2 Nov 2018 12:24:33 +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 0C66760921; Fri, 2 Nov 2018 12:24:29 +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 07FEE3082E72; Fri, 2 Nov 2018 12:24:28 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:20 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:23:56 +0100 Message-Id: <20181102122402.31145-2-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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]); Fri, 02 Nov 2018 12:24:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 02 Nov 2018 12:24:28 +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.13 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 1/7] libmultipath: set pp->checkint in store_pathinfo() 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.26]); Fri, 02 Nov 2018 12:31:57 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP store_pathinfo is called with valid conf pointer anyway, so checkint is available. pp->checkint is now valid for every path after path_discovery(). This fixes a bad conf access in cli_add_path(). Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/discovery.c | 1 + multipathd/cli_handlers.c | 1 - multipathd/main.c | 2 -- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index a6159e4a..63558ad8 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -103,6 +103,7 @@ store_pathinfo (vector pathvec, struct config *conf, err = store_path(pathvec, pp); if (err) goto out; + pp->checkint = conf->checkint; out: if (err) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 75000807..4aea4ce7 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -736,7 +736,6 @@ cli_add_path (void * v, char ** reply, int * len, void * data) condlog(0, "%s: failed to store path info", param); return 1; } - pp->checkint = conf->checkint; } return ev_add_path(pp, vecs, 1); blacklisted: diff --git a/multipathd/main.c b/multipathd/main.c index c57aa392..958545a4 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2324,8 +2324,6 @@ configure (struct vectors * vecs) free_path(pp); i--; } - else - pp->checkint = conf->checkint; pthread_cleanup_pop(1); } if (map_discovery(vecs)) { From patchwork Fri Nov 2 12:23:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665493 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 4EBCC13BF for ; Fri, 2 Nov 2018 12:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AE032B51A for ; Fri, 2 Nov 2018 12:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EF3D2B526; Fri, 2 Nov 2018 12:50:41 +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 D4D392B51A for ; Fri, 2 Nov 2018 12:50:40 +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 3F0B899D37; Fri, 2 Nov 2018 12:50:39 +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 ECD095450E; Fri, 2 Nov 2018 12:50: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 A187E3D386; Fri, 2 Nov 2018 12:50:38 +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 wA2COUHd011865 for ; Fri, 2 Nov 2018 08:24:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id E23FF600D7; Fri, 2 Nov 2018 12:24:30 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D73FC600D6; Fri, 2 Nov 2018 12:24:29 +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 2D10FC0495B2; Fri, 2 Nov 2018 12:24:28 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:22 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:23:57 +0100 Message-Id: <20181102122402.31145-3-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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.31]); Fri, 02 Nov 2018 12:24:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 02 Nov 2018 12:24:28 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 2/7] multipathd: remove init_path_check_interval() 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.38]); Fri, 02 Nov 2018 12:50:39 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP After "libmultipath: set pp->checkint in store_pathinfo()", pp-checkint should always be properly initialized, so this code is not needed any more. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/main.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 958545a4..dfc10e54 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2133,19 +2133,6 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) return 1; } -static void init_path_check_interval(struct vectors *vecs) -{ - struct config *conf; - struct path *pp; - unsigned int i; - - vector_foreach_slot (vecs->pathvec, pp, i) { - conf = get_multipath_config(); - pp->checkint = conf->checkint; - put_multipath_config(conf); - } -} - static void * checkerloop (void *ap) { @@ -2729,7 +2716,6 @@ child (void * param) */ post_config_state(DAEMON_CONFIGURE); - init_path_check_interval(vecs); if (poll_dmevents) { if (init_dmevent_waiter(vecs)) { From patchwork Fri Nov 2 12:23:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665499 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 D5A4F15E9 for ; Fri, 2 Nov 2018 12:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C21342B51A for ; Fri, 2 Nov 2018 12:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B69362B526; Fri, 2 Nov 2018 12:51:10 +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 4619C2B51A for ; Fri, 2 Nov 2018 12:51:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6486D307D982; Fri, 2 Nov 2018 12:51:09 +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 2949F1054FD9; Fri, 2 Nov 2018 12:51:09 +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 DD4AC3D386; Fri, 2 Nov 2018 12:51:08 +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 wA2CObQI011916 for ; Fri, 2 Nov 2018 08:24:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0834965930; Fri, 2 Nov 2018 12:24:37 +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 6E59C2A2C8; Fri, 2 Nov 2018 12:24:29 +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 4ACD3309174F; Fri, 2 Nov 2018 12:24:28 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:23 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:23:58 +0100 Message-Id: <20181102122402.31145-4-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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]); Fri, 02 Nov 2018 12:24:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 02 Nov 2018 12:24:28 +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.14 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 3/7] multipathd: print error message if checkint is not initialized 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 02 Nov 2018 12:51:09 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This is just a safety measure in case I overlooked something wrt the checkint initialization. It could be reverted once we know the error message isn't triggered. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- libmultipath/defaults.h | 1 + libmultipath/dict.c | 14 ++++++++++++-- libmultipath/structs.c | 1 + multipathd/main.c | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libmultipath/defaults.h b/libmultipath/defaults.h index 7f3839fc..65769398 100644 --- a/libmultipath/defaults.h +++ b/libmultipath/defaults.h @@ -46,6 +46,7 @@ #define DEFAULT_UNKNOWN_FIND_MULTIPATHS_TIMEOUT 1 #define DEFAULT_ALL_TG_PT ALL_TG_PT_OFF +#define CHECKINT_UNDEF (~0U) #define DEFAULT_CHECKINT 5 #define MAX_CHECKINT(a) (a << 2) diff --git a/libmultipath/dict.c b/libmultipath/dict.c index c3f5a6e6..a81c051f 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -264,7 +264,17 @@ snprint_mp_ ## option (struct config *conf, char * buff, int len, \ return function (buff, len, mpe->option); \ } -declare_def_handler(checkint, set_int) +static int checkint_handler(struct config *conf, vector strvec) +{ + int rc = set_int(strvec, &conf->checkint); + + if (rc) + return rc; + if (conf->checkint == CHECKINT_UNDEF) + conf->checkint--; + return 0; +} + declare_def_snprint(checkint, print_int) declare_def_handler(max_checkint, set_int) @@ -1563,7 +1573,7 @@ init_keywords(vector keywords) { install_keyword_root("defaults", NULL); install_keyword("verbosity", &def_verbosity_handler, &snprint_def_verbosity); - install_keyword("polling_interval", &def_checkint_handler, &snprint_def_checkint); + install_keyword("polling_interval", &checkint_handler, &snprint_def_checkint); install_keyword("max_polling_interval", &def_max_checkint_handler, &snprint_def_max_checkint); install_keyword("reassign_maps", &def_reassign_maps_handler, &snprint_def_reassign_maps); install_keyword("multipath_dir", &def_multipath_dir_handler, &snprint_def_multipath_dir); diff --git a/libmultipath/structs.c b/libmultipath/structs.c index caa178a6..fee899bd 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -100,6 +100,7 @@ alloc_path (void) pp->fd = -1; pp->tpgs = TPGS_UNDEF; pp->priority = PRIO_UNDEF; + pp->checkint = CHECKINT_UNDEF; checker_clear(&pp->checker); dm_path_to_gen(pp)->ops = &dm_gen_path_ops; pp->hwe = vector_alloc(); diff --git a/multipathd/main.c b/multipathd/main.c index dfc10e54..a022bdb5 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1842,6 +1842,12 @@ check_path (struct vectors * vecs, struct path * pp, int ticks) max_checkint = conf->max_checkint; verbosity = conf->verbosity; put_multipath_config(conf); + + if (pp->checkint == CHECKINT_UNDEF) { + condlog(0, "%s: BUG: checkint is not set", pp->dev); + pp->checkint = checkint; + }; + if (!pp->mpp && pp->initialized == INIT_MISSING_UDEV) { if (pp->retriggers < retrigger_tries) { condlog(2, "%s: triggering change event to reinitialize", From patchwork Fri Nov 2 12:23:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665471 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 0938715E9 for ; Fri, 2 Nov 2018 12:48:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5EA62B489 for ; Fri, 2 Nov 2018 12:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D90972B49B; Fri, 2 Nov 2018 12:48:22 +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 68F522B489 for ; Fri, 2 Nov 2018 12:48: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 69231307DAA3; Fri, 2 Nov 2018 12:48:21 +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 2238517F8D; Fri, 2 Nov 2018 12:48: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 D997F3D384; Fri, 2 Nov 2018 12:48:20 +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 wA2CObSh011917 for ; Fri, 2 Nov 2018 08:24:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 100895DA62; Fri, 2 Nov 2018 12:24:37 +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 6EDCB18E3F; Fri, 2 Nov 2018 12:24:29 +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 69BAF308124A; Fri, 2 Nov 2018 12:24:28 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:24 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:23:59 +0100 Message-Id: <20181102122402.31145-5-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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]); Fri, 02 Nov 2018 12:24:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 02 Nov 2018 12:24:28 +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.14 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 4/7] multipathd: open client socket early 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.42]); Fri, 02 Nov 2018 12:48:21 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Open the unix socket in multipathd code and pass the fd to uxsock_listen(). This will enable us to make the main thread wait for successful socket initialization in a follow-up patch. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- multipathd/main.c | 27 ++++++++++++++++++++++----- multipathd/uxlsnr.c | 14 ++------------ multipathd/uxlsnr.h | 5 +++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index a022bdb5..a91a14c6 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -66,6 +66,7 @@ static int use_watchdog; #include "pgpolicies.h" #include "uevent.h" #include "log.h" +#include "uxsock.h" #include "mpath_cmd.h" #include "mpath_persist.h" @@ -1496,12 +1497,24 @@ uevqloop (void * ap) static void * uxlsnrloop (void * ap) { + long ux_sock; + + pthread_cleanup_push(rcu_unregister, NULL); + rcu_register_thread(); + + ux_sock = ux_socket_listen(DEFAULT_SOCKET); + if (ux_sock == -1) { + condlog(1, "could not create uxsock: %d", errno); + exit_daemon(); + goto out; + } + pthread_cleanup_push(uxsock_cleanup, (void *)ux_sock); + if (cli_init()) { condlog(1, "Failed to init uxsock listener"); - return NULL; + exit_daemon(); + goto out_sock; } - pthread_cleanup_push(rcu_unregister, NULL); - rcu_register_thread(); set_handler_callback(LIST+PATHS, cli_list_paths); set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt); set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw); @@ -1556,8 +1569,12 @@ uxlsnrloop (void * ap) set_handler_callback(UNSETPRKEY+MAP, cli_unsetprkey); umask(077); - uxsock_listen(&uxsock_trigger, ap); - pthread_cleanup_pop(1); + uxsock_listen(&uxsock_trigger, ux_sock, ap); + +out_sock: + pthread_cleanup_pop(1); /* uxsock_cleanup */ +out: + pthread_cleanup_pop(1); /* rcu_unregister */ return NULL; } diff --git a/multipathd/uxlsnr.c b/multipathd/uxlsnr.c index 6f666663..773bc878 100644 --- a/multipathd/uxlsnr.c +++ b/multipathd/uxlsnr.c @@ -165,24 +165,15 @@ void uxsock_cleanup(void *arg) /* * entry point */ -void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data) +void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, long ux_sock, + void * trigger_data) { - long ux_sock; int rlen; char *inbuf; char *reply; sigset_t mask; int old_clients = MIN_POLLS; - ux_sock = ux_socket_listen(DEFAULT_SOCKET); - - if (ux_sock == -1) { - condlog(1, "could not create uxsock: %d", errno); - exit_daemon(); - } - - pthread_cleanup_push(uxsock_cleanup, (void *)ux_sock); - condlog(3, "uxsock: startup listener"); polls = (struct pollfd *)MALLOC((MIN_POLLS + 1) * sizeof(struct pollfd)); if (!polls) { @@ -322,6 +313,5 @@ void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, void * trigger_data) } } - pthread_cleanup_pop(1); return NULL; } diff --git a/multipathd/uxlsnr.h b/multipathd/uxlsnr.h index d51a8f99..18f008d7 100644 --- a/multipathd/uxlsnr.h +++ b/multipathd/uxlsnr.h @@ -5,7 +5,8 @@ typedef int (uxsock_trigger_fn)(char *, char **, int *, bool, void *); -void * uxsock_listen(uxsock_trigger_fn uxsock_trigger, - void * trigger_data); +void uxsock_cleanup(void *arg); +void *uxsock_listen(uxsock_trigger_fn uxsock_trigger, long ux_sock, + void * trigger_data); #endif From patchwork Fri Nov 2 12:24:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665495 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 979C913BF for ; Fri, 2 Nov 2018 12:50:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84A952B51A for ; Fri, 2 Nov 2018 12:50:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 792A52B526; Fri, 2 Nov 2018 12:50: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 17C972B51A for ; Fri, 2 Nov 2018 12:50:50 +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 25CF23082A47; Fri, 2 Nov 2018 12:50:49 +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 E727F5D781; Fri, 2 Nov 2018 12:50: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 A964F3D384; Fri, 2 Nov 2018 12:50:48 +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 wA2COUKL011866 for ; Fri, 2 Nov 2018 08:24:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4143600D6; Fri, 2 Nov 2018 12:24:30 +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 D7300600D1; Fri, 2 Nov 2018 12:24:29 +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 8A0C12D7EF; Fri, 2 Nov 2018 12:24:28 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:26 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:24:00 +0100 Message-Id: <20181102122402.31145-6-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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]); Fri, 02 Nov 2018 12:24:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 02 Nov 2018 12:24:29 +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: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 5/7] multipathd: set DAEMON_CONFIGURE from uxlsnr thread 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.45]); Fri, 02 Nov 2018 12:50:49 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Commit ee01e841 had the intention to make multipathd quit if the client socket couldn't be set up, because the unix socket listener is vital for signal handling in multipathd. But during startup, this condition might be lost if the main thread doesn't wait for the unix listener to initialize. Fixes: ee01e841 "multipathd: handle errors in uxlsnr as fatal" Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/main.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index a91a14c6..9052b56d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -207,9 +207,8 @@ static void config_cleanup(void *arg) pthread_mutex_unlock(&config_lock); } -void post_config_state(enum daemon_status state) +static void __post_config_state(enum daemon_status state) { - pthread_mutex_lock(&config_lock); if (state != running_state) { enum daemon_status old_state = running_state; @@ -219,7 +218,14 @@ void post_config_state(enum daemon_status state) do_sd_notify(old_state); #endif } - pthread_mutex_unlock(&config_lock); +} + +void post_config_state(enum daemon_status state) +{ + pthread_mutex_lock(&config_lock); + pthread_cleanup_push(config_cleanup, NULL); + __post_config_state(state); + pthread_cleanup_pop(1); } int set_config_state(enum daemon_status state) @@ -1515,6 +1521,10 @@ uxlsnrloop (void * ap) exit_daemon(); goto out_sock; } + + /* Tell main thread that thread has started */ + post_config_state(DAEMON_CONFIGURE); + set_handler_callback(LIST+PATHS, cli_list_paths); set_handler_callback(LIST+PATHS+FMT, cli_list_paths_fmt); set_handler_callback(LIST+PATHS+RAW+FMT, cli_list_paths_raw); @@ -2734,11 +2744,26 @@ child (void * param) */ conf = NULL; - /* - * Signal start of configuration - */ - post_config_state(DAEMON_CONFIGURE); + pthread_cleanup_push(config_cleanup, NULL); + pthread_mutex_lock(&config_lock); + __post_config_state(DAEMON_IDLE); + rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs); + if (!rc) { + /* Wait for uxlsnr startup */ + while (running_state == DAEMON_IDLE) + pthread_cond_wait(&config_cond, &config_lock); + } + pthread_cleanup_pop(1); + + if (rc) { + condlog(0, "failed to create cli listener: %d", rc); + goto failed; + } + else if (running_state != DAEMON_CONFIGURE) { + condlog(0, "cli listener failed to start"); + goto failed; + } if (poll_dmevents) { if (init_dmevent_waiter(vecs)) { @@ -2761,10 +2786,6 @@ child (void * param) goto failed; } pthread_attr_destroy(&uevent_attr); - if ((rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs))) { - condlog(0, "failed to create cli listener: %d", rc); - goto failed; - } /* * start threads From patchwork Fri Nov 2 12:24:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665503 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 A310015E9 for ; Fri, 2 Nov 2018 12:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5CF2B542 for ; Fri, 2 Nov 2018 12:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80E5D2B5AA; Fri, 2 Nov 2018 12:51:32 +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 0FD4E2B543 for ; Fri, 2 Nov 2018 12:51:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E474307EAA1; Fri, 2 Nov 2018 12:51:31 +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 CFBC11054FCF; Fri, 2 Nov 2018 12:51:30 +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 521B4180B5B7; Fri, 2 Nov 2018 12:51:30 +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 wA2COk41011957 for ; Fri, 2 Nov 2018 08:24:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id A5571610C7; Fri, 2 Nov 2018 12:24:46 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 182FD6251E; Fri, 2 Nov 2018 12:24:39 +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 02C497F419; Fri, 2 Nov 2018 12:24:38 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:27 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:24:01 +0100 Message-Id: <20181102122402.31145-7-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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.25]); Fri, 02 Nov 2018 12:24:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 02 Nov 2018 12:24:38 +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.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 6/7] multipathd: make DAEMON_SHUTDOWN a terminal state 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 02 Nov 2018 12:51:31 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP It can happen that, before the main thread reacts on DAEMON_SHUTDOWN and starts cancelling threads, another thread resets the state to something else. Fix that. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/cli_handlers.c | 9 +++++++-- multipathd/main.c | 10 +++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 4aea4ce7..a0d57a53 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1124,12 +1124,17 @@ cli_switch_group(void * v, char ** reply, int * len, void * data) int cli_reconfigure(void * v, char ** reply, int * len, void * data) { + int rc; + condlog(2, "reconfigure (operator)"); - if (set_config_state(DAEMON_CONFIGURE) == ETIMEDOUT) { + rc = set_config_state(DAEMON_CONFIGURE); + if (rc == ETIMEDOUT) { condlog(2, "timeout starting reconfiguration"); return 1; - } + } else if (rc == EINVAL) + /* daemon shutting down */ + return 1; return 0; } diff --git a/multipathd/main.c b/multipathd/main.c index 9052b56d..3cccc9f8 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -209,7 +209,7 @@ static void config_cleanup(void *arg) static void __post_config_state(enum daemon_status state) { - if (state != running_state) { + if (state != running_state && running_state != DAEMON_SHUTDOWN) { enum daemon_status old_state = running_state; running_state = state; @@ -237,7 +237,9 @@ int set_config_state(enum daemon_status state) if (running_state != state) { enum daemon_status old_state = running_state; - if (running_state != DAEMON_IDLE) { + if (running_state == DAEMON_SHUTDOWN) + rc = EINVAL; + else if (running_state != DAEMON_IDLE) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -2212,7 +2214,9 @@ checkerloop (void *ap) if (rc == ETIMEDOUT) { condlog(4, "timeout waiting for DAEMON_IDLE"); continue; - } + } else if (rc == EINVAL) + /* daemon shutdown */ + break; pthread_cleanup_push(cleanup_lock, &vecs->lock); lock(&vecs->lock); From patchwork Fri Nov 2 12:24:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10665501 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 8CD6D13BF for ; Fri, 2 Nov 2018 12:51:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78C022B51A for ; Fri, 2 Nov 2018 12:51:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CBB52B529; Fri, 2 Nov 2018 12:51:21 +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 0C4D02B51A for ; Fri, 2 Nov 2018 12:51:21 +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 E68A2C0495B1; Fri, 2 Nov 2018 12:51:19 +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 B05F9519C1; Fri, 2 Nov 2018 12:51: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 5DCEF180B5B7; Fri, 2 Nov 2018 12:51:19 +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 wA2COgcx011947 for ; Fri, 2 Nov 2018 08:24:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D2CA600CD; Fri, 2 Nov 2018 12:24:42 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A25C600C9; Fri, 2 Nov 2018 12:24:39 +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 2683DC07DE93; Fri, 2 Nov 2018 12:24:38 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Fri, 02 Nov 2018 06:24:28 -0600 From: Martin Wilck To: Christophe Varoqui , Benjamin Marzinski Date: Fri, 2 Nov 2018 13:24:02 +0100 Message-Id: <20181102122402.31145-8-mwilck@suse.com> In-Reply-To: <20181102122402.31145-1-mwilck@suse.com> References: <20181102122402.31145-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.31]); Fri, 02 Nov 2018 12:24:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 02 Nov 2018 12:24:38 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH v3 7/7] multipathd: only grab conf once for filter_path() 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.31]); Fri, 02 Nov 2018 12:51:20 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This saves a possibly large number of cleanup push/pop calls and slightly improves readability. Reviewed-by: Benjamin Marzinski Signed-off-by: Martin Wilck --- multipathd/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 3cccc9f8..a445b050 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -2340,16 +2340,17 @@ configure (struct vectors * vecs) goto fail; } + conf = get_multipath_config(); + pthread_cleanup_push(put_multipath_config, conf); vector_foreach_slot (vecs->pathvec, pp, i){ - conf = get_multipath_config(); - pthread_cleanup_push(put_multipath_config, conf); if (filter_path(conf, pp) > 0){ vector_del_slot(vecs->pathvec, i); free_path(pp); i--; } - pthread_cleanup_pop(1); } + pthread_cleanup_pop(1); + if (map_discovery(vecs)) { condlog(0, "configure failed at map discovery"); goto fail;