From patchwork Tue Mar 29 03:13:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 8681691 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 80213C0554 for ; Tue, 29 Mar 2016 03:17:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 801D420220 for ; Tue, 29 Mar 2016 03:17:29 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F9062010C for ; Tue, 29 Mar 2016 03:17:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2T3EhIv013807; Mon, 28 Mar 2016 23:14:43 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2T3DO75014204 for ; Mon, 28 Mar 2016 23:13:24 -0400 Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u2T3DMBV019841; Mon, 28 Mar 2016 23:13:23 -0400 Received: by redhat.com (sSMTP sendmail emulation); Mon, 28 Mar 2016 22:13:22 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Mon, 28 Mar 2016 22:13:02 -0500 Message-Id: <1459221194-23222-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1459221194-23222-1-git-send-email-bmarzins@redhat.com> References: <1459221194-23222-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 05/17] libmultipath: add ignore_new_boot_devs option 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-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When multipath relies on the wwids file to determine whether a device is a multipath path (with "multipath -c"), it will fail the first time a new multipathable device is discovered, since the wwid clearly won't be in the wwids file. This is usually fine. Multipath will still set itself up on the device, and add the wwid to the wwids file. However, this causes a race, where multipath won't claim the path immediately, and something else may. Later multipath will try, and possibly succeed at, setting itself up on that device. I've seen cases where this can cause problems during boot on and immediately after install, where multipath racing with LVM on an already labelled device can get the machine into a state where boot fails. This can be avoided if multipath simply doesn't set itself up on any devices that it didn't claim (with "multipath -c") in the initramfs. It can still safely attempt to set itself up on these devices later in boot, after the regular filesystem has been set up. To allow this, this patch adds a new multipahtd commandline option, -n. When multipathd is run with this set, it will not create multipath devices if their wwid isn't already in the wwids file. This means that only devices that are claimed by "multipath -c" will be used by multipathd. Signed-off-by: Benjamin Marzinski --- libmultipath/config.h | 1 + libmultipath/configure.c | 3 +-- libmultipath/wwids.c | 19 ++++++++++++------- multipathd/main.c | 9 ++++++--- multipathd/multipathd.8 | 4 ++++ 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index 372eace..d6a1d4f 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -137,6 +137,7 @@ struct config { int uxsock_timeout; int retrigger_tries; int retrigger_delay; + int ignore_new_devs; unsigned int version[3]; char * dev; diff --git a/libmultipath/configure.c b/libmultipath/configure.c index 3c9badd..1ab3324 100644 --- a/libmultipath/configure.c +++ b/libmultipath/configure.c @@ -778,8 +778,7 @@ coalesce_paths (struct vectors * vecs, vector newmp, char * refwwid, int force_r continue; /* If find_multipaths was selected check if the path is valid */ - if (conf->find_multipaths && !refwwid && - !should_multipath(pp1, pathvec)) { + if (!refwwid && !should_multipath(pp1, pathvec)) { orphan_path(pp1, "only one path"); continue; } diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c index f6f8ea8..567c93d 100644 --- a/libmultipath/wwids.c +++ b/libmultipath/wwids.c @@ -266,14 +266,19 @@ should_multipath(struct path *pp1, vector pathvec) int i; struct path *pp2; + if (!conf->find_multipaths && !conf->ignore_new_devs) + return 1; + condlog(4, "checking if %s should be multipathed", pp1->dev); - vector_foreach_slot(pathvec, pp2, i) { - if (pp1->dev == pp2->dev) - continue; - if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) { - condlog(3, "found multiple paths with wwid %s, " - "multipathing %s", pp1->wwid, pp1->dev); - return 1; + if (!conf->ignore_new_devs) { + vector_foreach_slot(pathvec, pp2, i) { + if (pp1->dev == pp2->dev) + continue; + if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) { + condlog(3, "found multiple paths with wwid %s, " + "multipathing %s", pp1->wwid, pp1->dev); + return 1; + } } } if (check_wwids_file(pp1->wwid, 0) < 0) { diff --git a/multipathd/main.c b/multipathd/main.c index 21df7be..8f4fb58 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -518,8 +518,7 @@ rescan: mpp->flush_on_last_del = FLUSH_UNDEF; mpp->action = ACT_RELOAD; } else { - if (conf->find_multipaths && - !should_multipath(pp, vecs->pathvec)) { + if (!should_multipath(pp, vecs->pathvec)) { orphan_path(pp, "only one path"); return 0; } @@ -1572,6 +1571,7 @@ reconfigure (struct vectors * vecs) dm_drv_version(conf->version, TGT_MPATH); conf->verbosity = old->verbosity; conf->bindings_read_only = old->bindings_read_only; + conf->ignore_new_devs = old->ignore_new_devs; conf->daemon = 1; configure(vecs, 1); free_config(old); @@ -2076,7 +2076,7 @@ main (int argc, char *argv[]) if (!conf) exit(1); - while ((arg = getopt(argc, argv, ":dsv:k::B")) != EOF ) { + while ((arg = getopt(argc, argv, ":dsv:k::Bn")) != EOF ) { switch(arg) { case 'd': foreground = 1; @@ -2102,6 +2102,9 @@ main (int argc, char *argv[]) case 'B': conf->bindings_read_only = 1; break; + case 'n': + conf->ignore_new_devs = 1; + break; default: ; } diff --git a/multipathd/multipathd.8 b/multipathd/multipathd.8 index 7fe6597..77f6e72 100644 --- a/multipathd/multipathd.8 +++ b/multipathd/multipathd.8 @@ -35,6 +35,10 @@ will use its WWID as its alias. .TP .B -k multipathd will enter interactive mode. From this mode, the available commands can be viewed by entering "help". When you are finished entering commands, press CTRL-D to quit. +.TP +.B -n +ignore new devices. Multipathd will not create a multipath device unless the +wwid for the device is already listed in the wwids file. .SH COMMANDS .TP