From patchwork Wed Dec 11 06:43:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 3322531 X-Patchwork-Delegate: christophe.varoqui@free.fr 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 054DBC0D4A for ; Wed, 11 Dec 2013 06:46:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 324B6203F7 for ; Wed, 11 Dec 2013 06:46:42 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 691CF20396 for ; Wed, 11 Dec 2013 06:46:41 +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 rBB6i5kx017754; Wed, 11 Dec 2013 01:44:05 -0500 Received: from int-mx01.intmail.prod.int.phx2.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 rBB6hdfv021200 for ; Wed, 11 Dec 2013 01:43:39 -0500 Received: from dhcp80-209.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBB6hd5q005069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Dec 2013 01:43:39 -0500 Received: from dhcp80-209.msp.redhat.com (localhost [127.0.0.1]) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7) with ESMTP id rBB6hcgT001384; Wed, 11 Dec 2013 00:43:38 -0600 Received: (from bmarzins@localhost) by dhcp80-209.msp.redhat.com (8.14.7/8.14.7/Submit) id rBB6hb4g001383; Wed, 11 Dec 2013 00:43:37 -0600 From: Benjamin Marzinski To: device-mapper development Date: Wed, 11 Dec 2013 00:43:06 -0600 Message-Id: <1386744190-1295-13-git-send-email-bmarzins@redhat.com> In-Reply-To: <1386744190-1295-1-git-send-email-bmarzins@redhat.com> References: <1386744190-1295-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: Christophe Varoqui Subject: [dm-devel] [PATCH 12/16] multipathd: Don't touch the multipath device after setup_multipath fails X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development 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.1 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 If setup_multipath fails, it removes the device. multipath always needs to check its return value and not touch the device if setup_multipath failed. Signed-off-by: Benjamin Marzinski --- multipathd/cli_handlers.c | 3 ++- multipathd/main.c | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 58a5643..baa43c4 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -634,7 +634,8 @@ cli_resize(void *v, char **reply, int *len, void *data) return 1; dm_lib_release(); - setup_multipath(vecs, mpp); + if (setup_multipath(vecs, mpp) != 0) + return 1; sync_map_state(mpp); return 0; diff --git a/multipathd/main.c b/multipathd/main.c index 204fbb1..49e74a6 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -139,7 +139,6 @@ coalesce_maps(struct vectors *vecs, vector nmpv) struct multipath * ompp; vector ompv = vecs->mpvec; unsigned int i; - int j; vector_foreach_slot (ompv, ompp, i) { condlog(3, "%s: coalesce map", ompp->alias); @@ -154,16 +153,17 @@ coalesce_maps(struct vectors *vecs, vector nmpv) /* * may be just because the device is open */ + if (setup_multipath(vecs, ompp) != 0) { + i--; + continue; + } if (!vector_alloc_slot(nmpv)) return 1; vector_set_slot(nmpv, ompp); - setup_multipath(vecs, ompp); - if ((j = find_slot(ompv, (void *)ompp)) != -1) - vector_del_slot(ompv, j); - - continue; + vector_del_slot(ompv, i); + i--; } else { dm_lib_release();