From patchwork Sat Oct 29 02:55:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 9403049 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2278C60588 for ; Sat, 29 Oct 2016 02:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 139202A6A6 for ; Sat, 29 Oct 2016 02:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 077EA2A6B5; Sat, 29 Oct 2016 02:58: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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (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 963DE2A6A6 for ; Sat, 29 Oct 2016 02:58:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9T2uTdf029954; Fri, 28 Oct 2016 22:56:29 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.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 u9T2teWA026847 for ; Fri, 28 Oct 2016 22:55:40 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u9T2tcHv011283; Fri, 28 Oct 2016 22:55:38 -0400 Received: by redhat.com (sSMTP sendmail emulation); Fri, 28 Oct 2016 21:55:38 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Fri, 28 Oct 2016 21:55:23 -0500 Message-Id: <1477709726-5442-8-git-send-email-bmarzins@redhat.com> In-Reply-To: <1477709726-5442-1-git-send-email-bmarzins@redhat.com> References: <1477709726-5442-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 07/10] recover from errors in multipathd startup X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Virus-Scanned: ClamAV using ClamSMTP When multipathd does it's initial configuration during startup, it fails the daemon for many errors that it would simply recover from if they occured when adding paths or maps later. It should recover from these errors during startup as well. Also, if multipathd hits a nonrecoverable error, it should log a message before quitting. Signed-off-by: Benjamin Marzinski Reviewed-by: Hannes Reinecke --- libmultipath/configure.c | 8 +++++--- multipathd/main.c | 45 ++++++++++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 48f100b..d428099 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -809,8 +809,10 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r * at this point, we know we really got a new mp */ mpp = add_map_with_path(vecs, pp1, 0); - if (!mpp) - return 1; + if (!mpp) { + orphan_path(pp1, "failed to create multipath device"); + continue; + } if (pp1->priority == PRIO_UNDEF) mpp->action = ACT_REJECT; @@ -862,7 +864,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r condlog(3, "%s: domap (%u) failure " "for create/reload map", mpp->alias, r); - if (r == DOMAP_FAIL) { + if (r == DOMAP_FAIL || is_daemon) { condlog(2, "%s: %s map", mpp->alias, (mpp->action == ACT_CREATE)? "ignoring" : "removing"); diff --git a/multipathd/main.c b/multipathd/main.c index 15c957a..f423e35 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1017,7 +1017,7 @@ map_discovery (struct vectors * vecs) vector_foreach_slot (vecs->mpvec, mpp, i) if (setup_multipath(vecs, mpp)) - return 1; + i--; return 0; } @@ -1910,21 +1910,29 @@ configure (struct vectors * vecs, int start_waiters) int i, ret; struct config *conf; - if (!vecs->pathvec && !(vecs->pathvec = vector_alloc())) + if (!vecs->pathvec && !(vecs->pathvec = vector_alloc())) { + condlog(0, "couldn't allocate path vec in configure"); return 1; + } - if (!vecs->mpvec && !(vecs->mpvec = vector_alloc())) + if (!vecs->mpvec && !(vecs->mpvec = vector_alloc())) { + condlog(0, "couldn't allocate multipath vec in configure"); return 1; + } - if (!(mpvec = vector_alloc())) + if (!(mpvec = vector_alloc())) { + condlog(0, "couldn't allocate new maps vec in configure"); return 1; + } /* * probe for current path (from sysfs) and map (from dm) sets */ ret = path_discovery(vecs->pathvec, DI_ALL); - if (ret < 0) + if (ret < 0) { + condlog(0, "configure failed at path discovery"); return 1; + } vector_foreach_slot (vecs->pathvec, pp, i){ conf = get_multipath_config(); @@ -1937,21 +1945,27 @@ configure (struct vectors * vecs, int start_waiters) pp->checkint = conf->checkint; put_multipath_config(conf); } - if (map_discovery(vecs)) + if (map_discovery(vecs)) { + condlog(0, "configure failed at map discovery"); return 1; + } /* * create new set of maps & push changed ones into dm */ - if (coalesce_paths(vecs, mpvec, NULL, 1, CMD_NONE)) + if (coalesce_paths(vecs, mpvec, NULL, 1, CMD_NONE)) { + condlog(0, "configure failed while coalescing paths"); return 1; + } /* * may need to remove some maps which are no longer relevant * e.g., due to blacklist changes in conf file */ - if (coalesce_maps(vecs, mpvec)) + if (coalesce_maps(vecs, mpvec)) { + condlog(0, "configure failed while coalescing maps"); return 1; + } dm_lib_release(); @@ -1976,11 +1990,16 @@ configure (struct vectors * vecs, int start_waiters) * start dm event waiter threads for these new maps */ vector_foreach_slot(vecs->mpvec, mpp, i) { - if (setup_multipath(vecs, mpp)) - return 1; - if (start_waiters) - if (start_waiter_thread(mpp, vecs)) - return 1; + if (setup_multipath(vecs, mpp)) { + i--; + continue; + } + if (start_waiters) { + if (start_waiter_thread(mpp, vecs)) { + remove_map(mpp, vecs, 1); + i--; + } + } } return 0; }