From patchwork Thu Jun 18 00:24:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611005 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86531912 for ; Thu, 18 Jun 2020 00:24:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E912080D for ; Thu, 18 Jun 2020 00:24:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YBCQXtRC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45E912080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439891; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=M2fNJS7FobnW+rn/MBq7uOTVJLgb86BSwJVeVRh8Pbc=; b=YBCQXtRCDEuqJUnCmeiz84ws2KOH96Uukb2wWM2tj8Y7pezgwLUjo0gb1QoQJStTffRIH9 kUmIxt3VpIvaJQ1lIEuhef565b6RWm884NUocXajQKst2gWGS+CNF2D+igunK2yoOWP4zA BVheIbfhL0GPaub8h3OZwCKr6nN4rDA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-202-cIbDhFDtOdWSv8gKcTGvXg-1; Wed, 17 Jun 2020 20:24:44 -0400 X-MC-Unique: cIbDhFDtOdWSv8gKcTGvXg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DDD08018AD; Thu, 18 Jun 2020 00:24:39 +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 EC26479310; Thu, 18 Jun 2020 00:24: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 278B81809547; Thu, 18 Jun 2020 00:24:34 +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 05I0OXSb026480 for ; Wed, 17 Jun 2020 20:24:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id F28D25D9E5; Thu, 18 Jun 2020 00:24:32 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47EFB5D9E4; Thu, 18 Jun 2020 00:24:31 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OT1D018469; Wed, 17 Jun 2020 19:24:30 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OT3Z018468; Wed, 17 Jun 2020 19:24:29 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:21 -0500 Message-Id: <1592439867-18427-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 1/7] libmultipath: change do_get_info returns 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Make do_get_info() differentiate between dm failures and missing devices, and update callers to retain their current behavior. Also, rename it and make it external. These changes will be used by future commits. Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 29 ++++++++++++++++------------- libmultipath/devmapper.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 27d52398..b44f7545 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -496,8 +496,14 @@ int dm_addmap_reload(struct multipath *mpp, char *params, int flush) return 0; } -static int -do_get_info(const char *name, struct dm_info *info) +/* + * Returns: + * -1: Error + * 0: device does not exist + * 1: device exists + */ +int +do_dm_get_info(const char *name, struct dm_info *info) { int r = -1; struct dm_task *dmt; @@ -516,10 +522,7 @@ do_get_info(const char *name, struct dm_info *info) if (!dm_task_get_info(dmt, info)) goto out; - if (!info->exists) - goto out; - - r = 0; + r = !!info->exists; out: dm_task_destroy(dmt); return r; @@ -529,7 +532,7 @@ int dm_map_present(const char * str) { struct dm_info info; - return (do_get_info(str, &info) == 0); + return (do_dm_get_info(str, &info) == 1); } int dm_get_map(const char *name, unsigned long long *size, char *outparams) @@ -820,7 +823,7 @@ dm_dev_t (const char * mapname, char * dev_t, int len) { struct dm_info info; - if (do_get_info(mapname, &info) != 0) + if (do_dm_get_info(mapname, &info) != 1) return 1; if (snprintf(dev_t, len, "%i:%i", info.major, info.minor) > len) @@ -862,7 +865,7 @@ dm_get_major_minor(const char *name, int *major, int *minor) { struct dm_info info; - if (do_get_info(name, &info) != 0) + if (do_dm_get_info(name, &info) != 1) return -1; *major = info.major; @@ -1199,7 +1202,7 @@ dm_geteventnr (const char *name) { struct dm_info info; - if (do_get_info(name, &info) != 0) + if (do_dm_get_info(name, &info) != 1) return -1; return info.event_nr; @@ -1210,7 +1213,7 @@ dm_is_suspended(const char *name) { struct dm_info info; - if (do_get_info(name, &info) != 0) + if (do_dm_get_info(name, &info) != 1) return -1; return info.suspended; @@ -1383,7 +1386,7 @@ dm_get_deferred_remove (const char * mapname) { struct dm_info info; - if (do_get_info(mapname, &info) != 0) + if (do_dm_get_info(mapname, &info) != 1) return -1; return info.deferred_remove; @@ -1442,7 +1445,7 @@ dm_get_info (const char * mapname, struct dm_info ** dmi) if (!*dmi) return 1; - if (do_get_info(mapname, *dmi) != 0) { + if (do_dm_get_info(mapname, *dmi) != 1) { memset(*dmi, 0, sizeof(struct dm_info)); FREE(*dmi); *dmi = NULL; diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 5ed7edc5..79c9afb2 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -66,6 +66,7 @@ char * dm_mapname(int major, int minor); int dm_remove_partmaps (const char * mapname, int need_sync, int deferred_remove); int dm_get_uuid(const char *name, char *uuid, int uuid_len); +int do_dm_get_info(const char *, struct dm_info *); int dm_get_info (const char * mapname, struct dm_info ** dmi); int dm_rename (const char * old, char * new, char * delim, int skip_kpartx); int dm_reassign(const char * mapname); From patchwork Thu Jun 18 00:24:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611007 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8728F618 for ; Thu, 18 Jun 2020 00:25:07 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43CA92080D for ; Thu, 18 Jun 2020 00:25:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Mh0pCjVg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43CA92080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439906; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rKXJFj5ZymWDUl1CpdlNgFoCIAPHZ5SJBMi2kz86/7Q=; b=Mh0pCjVg3w/RgNa7KjhKIueIQTrMP6UvyIXpojlm56UETeIPSZnUhjhCkfGAF8PGTWf6HJ 6jm6QfrMiqwc0elywJlHIDcW9rzJkgesvegt30MClr0leCx1LXbkrJcBZ3hiOGJnPW+cbH Iu9QmTyKGfILEoGC8Qs9AsWy2ko839g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-kgGj5TyIMY254GowNImCyQ-1; Wed, 17 Jun 2020 20:25:04 -0400 X-MC-Unique: kgGj5TyIMY254GowNImCyQ-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87144A0C00; Thu, 18 Jun 2020 00:24:59 +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 6AB2860E1C; Thu, 18 Jun 2020 00:24:59 +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 2D66F833D0; Thu, 18 Jun 2020 00:24:59 +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 05I0OZuR026505 for ; Wed, 17 Jun 2020 20:24:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3AB7B1002388; Thu, 18 Jun 2020 00:24:35 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7480A1001E91; Thu, 18 Jun 2020 00:24:32 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OVid018473; Wed, 17 Jun 2020 19:24:31 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OUhl018472; Wed, 17 Jun 2020 19:24:30 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:22 -0500 Message-Id: <1592439867-18427-3-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 2/7] multipathd: fix check_path errors with removed map 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com If a multipath device is removed during, or immediately before the call to check_path(), multipathd can behave incorrectly. A missing multpath device will cause update_multipath_strings() to fail, setting pp->dmstate to PSTATE_UNDEF. If the path is up, this state will cause reinstate_path() to be called, which will also fail. This will trigger a reload, restoring the recently removed device. If update_multipath_strings() fails because there is no multipath device, check_path should just quit, since the remove dmevent and uevent are likely already queued up. Also, I don't see any reason to reload the multipath device if reinstate fails. This code was added by fac68d7a99ef17d496079538a5c6836acd7911ab, which clamined that reinstate could fail if the path was disabled. Looking through the current kernel code, I can't see any reason why a reinstate would fail, where a reload would help. If the path was missing from the multipath device, update_multipath_strings() would already catch that, and quit check_path() early, which make more sense to me than reloading does. Signed-off-by: Benjamin Marzinski --- multipathd/main.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 6b7db2c0..8fb73922 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1611,22 +1611,18 @@ fail_path (struct path * pp, int del_active) /* * caller must have locked the path list before calling that function */ -static int +static void reinstate_path (struct path * pp) { - int ret = 0; - if (!pp->mpp) - return 0; + return; - if (dm_reinstate_path(pp->mpp->alias, pp->dev_t)) { + if (dm_reinstate_path(pp->mpp->alias, pp->dev_t)) condlog(0, "%s: reinstate failed", pp->dev_t); - ret = 1; - } else { + else { condlog(2, "%s: reinstated", pp->dev_t); update_queue_mode_add_path(pp->mpp); } - return ret; } static void @@ -2088,8 +2084,13 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) * Synchronize with kernel state */ if (update_multipath_strings(pp->mpp, vecs->pathvec, 1)) { + struct dm_info info; condlog(1, "%s: Could not synchronize with kernel state", pp->dev); + if (pp->mpp && pp->mpp->alias && + do_dm_get_info(pp->mpp->alias, &info) == 0) + /* multipath device missing. Likely removed */ + return 0; pp->dmstate = PSTATE_UNDEF; } /* if update_multipath_strings orphaned the path, quit early */ @@ -2179,12 +2180,8 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) /* * reinstate this path */ - if (!disable_reinstate && reinstate_path(pp)) { - condlog(3, "%s: reload map", pp->dev); - ev_add_path(pp, vecs, 1); - pp->tick = 1; - return 0; - } + if (!disable_reinstate) + reinstate_path(pp); new_path_up = 1; if (oldchkrstate != PATH_UP && oldchkrstate != PATH_GHOST) @@ -2200,15 +2197,10 @@ check_path (struct vectors * vecs, struct path * pp, unsigned int ticks) else if (newstate == PATH_UP || newstate == PATH_GHOST) { if ((pp->dmstate == PSTATE_FAILED || pp->dmstate == PSTATE_UNDEF) && - !disable_reinstate) { + !disable_reinstate) /* Clear IO errors */ - if (reinstate_path(pp)) { - condlog(3, "%s: reload map", pp->dev); - ev_add_path(pp, vecs, 1); - pp->tick = 1; - return 0; - } - } else { + reinstate_path(pp); + else { LOG_MSG(4, verbosity, pp); if (pp->checkint != max_checkint) { /* From patchwork Thu Jun 18 00:24:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611001 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 37C3913A0 for ; Thu, 18 Jun 2020 00:24:48 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A179720897 for ; Thu, 18 Jun 2020 00:24:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R0G4ER3r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A179720897 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439886; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=J9gbNmcFP49PY9FDFALzjtfGyTnvqH14YqXOTHSsKhY=; b=R0G4ER3rYijP18m31Tz3MwPo3YCj1iDn24nGqEBHrNhgV5CKz4ccOgJt3c9RhU2be8ylG0 t2EvOgPzpi2wq9RYebb53Mx05HYYvG9nEY/9gw7nffiGpIChFybvQC5u5tde5gl/kjMPWf ZO4rYZiTTcN5uJeK6rWQZAkoJFvIg6E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-ePTHolYfMcaY3eURMIZYXA-1; Wed, 17 Jun 2020 20:24:43 -0400 X-MC-Unique: ePTHolYfMcaY3eURMIZYXA-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C42B10059A8; Thu, 18 Jun 2020 00:24: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 EF54260BF4; Thu, 18 Jun 2020 00:24: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 83D53833C6; Thu, 18 Jun 2020 00:24:36 +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 05I0OZbJ026500 for ; Wed, 17 Jun 2020 20:24:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D2A21002393; Thu, 18 Jun 2020 00:24:35 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E48F1002388; Thu, 18 Jun 2020 00:24:33 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OWBG018477; Wed, 17 Jun 2020 19:24:32 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OVbB018476; Wed, 17 Jun 2020 19:24:31 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:23 -0500 Message-Id: <1592439867-18427-4-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 3/7] libmultipath: make dm_flush_maps only return 0 on success 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com dm_flush_maps() returned both 0 and 1 on error, depending on which part of the function it was in, but the caller was always treating 0 as a success. Make dm_flush_maps() always return 1 on error and 0 on success. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/devmapper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index b44f7545..682c0038 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -993,13 +993,13 @@ dm_flush_map_nopaths(const char * mapname, int deferred_remove) int dm_flush_maps (int retries) { - int r = 0; + int r = 1; struct dm_task *dmt; struct dm_names *names; unsigned next = 0; if (!(dmt = libmp_dm_task_create (DM_DEVICE_LIST))) - return 0; + return r; dm_task_no_open_count(dmt); @@ -1012,6 +1012,7 @@ int dm_flush_maps (int retries) if (!names->dev) goto out; + r = 0; do { r |= dm_suspend_and_flush_map(names->name, retries); next = names->next; From patchwork Thu Jun 18 00:24:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611009 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2AA6618 for ; Thu, 18 Jun 2020 00:25:08 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 625B52080D for ; Thu, 18 Jun 2020 00:25:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YpoDyFpL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 625B52080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439907; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wxasVJpGIvJr8tZ3HABmc3occagERsH4icTuicPRkvY=; b=YpoDyFpLDMhT1GfLNXKe9OxGk27vklFgjy0pdV2Vbbs7TU0TVzyQr2RU/kPCcgOjcs2c6L B7H8jF+8424hc+tx+7PneXD8QVlCN/SNjp0//aRtznkj2Wm79EyqUHdD3tKhhLBmWE9sCk 0PK0egIkCdQXkybQ9Pod3lg0zl+idXU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-e5mll3ujNRSofughyEYEQg-1; Wed, 17 Jun 2020 20:25:03 -0400 X-MC-Unique: e5mll3ujNRSofughyEYEQg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F740184D142; Thu, 18 Jun 2020 00:24:59 +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 541BA7A029; Thu, 18 Jun 2020 00:24:59 +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 2D903833D1; Thu, 18 Jun 2020 00:24:59 +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 05I0ObEb026523 for ; Wed, 17 Jun 2020 20:24:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79E2A5C220; Thu, 18 Jun 2020 00:24:37 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE8DA5C1D6; Thu, 18 Jun 2020 00:24:34 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OXKd018481; Wed, 17 Jun 2020 19:24:33 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OW1a018480; Wed, 17 Jun 2020 19:24:32 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:24 -0500 Message-Id: <1592439867-18427-5-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 4/7] multipathd: add "del maps" multipathd command 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com This will flush all multipath devices. Signed-off-by: Benjamin Marzinski --- libmultipath/devmapper.c | 7 +++++-- libmultipath/devmapper.h | 2 +- multipath/main.c | 2 +- multipathd/cli.c | 1 + multipathd/cli_handlers.c | 19 +++++++++++++++++++ multipathd/cli_handlers.h | 1 + multipathd/main.c | 3 ++- multipathd/main.h | 1 + 8 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 682c0038..a5e0d298 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -991,7 +991,7 @@ dm_flush_map_nopaths(const char * mapname, int deferred_remove) #endif -int dm_flush_maps (int retries) +int dm_flush_maps (int need_suspend, int retries) { int r = 1; struct dm_task *dmt; @@ -1014,7 +1014,10 @@ int dm_flush_maps (int retries) r = 0; do { - r |= dm_suspend_and_flush_map(names->name, retries); + if (need_suspend) + r |= dm_suspend_and_flush_map(names->name, retries); + else + r |= dm_flush_map(names->name); next = names->next; names = (void *) names + next; } while (next); diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 79c9afb2..adf89342 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -51,7 +51,7 @@ int dm_flush_map_nopaths(const char * mapname, int deferred_remove); #define dm_suspend_and_flush_map(mapname, retries) \ _dm_flush_map(mapname, 1, 0, 1, retries) int dm_cancel_deferred_remove(struct multipath *mpp); -int dm_flush_maps (int retries); +int dm_flush_maps (int need_suspend, int retries); int dm_fail_path(const char * mapname, char * path); int dm_reinstate_path(const char * mapname, char * path); int dm_queue_if_no_path(const char *mapname, int enable); diff --git a/multipath/main.c b/multipath/main.c index c4740fab..d89f0a91 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -1096,7 +1096,7 @@ main (int argc, char *argv[]) goto out; } else if (conf->remove == FLUSH_ALL) { - r = dm_flush_maps(retries) ? RTVL_FAIL : RTVL_OK; + r = dm_flush_maps(1, retries) ? RTVL_FAIL : RTVL_OK; goto out; } while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY) diff --git a/multipathd/cli.c b/multipathd/cli.c index 800c0fbe..bdc9fb10 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -568,6 +568,7 @@ cli_init (void) { add_handler(DEL+PATH, NULL); add_handler(ADD+MAP, NULL); add_handler(DEL+MAP, NULL); + add_handler(DEL+MAPS, NULL); add_handler(SWITCH+MAP+GROUP, NULL); add_handler(RECONFIGURE, NULL); add_handler(SUSPEND+MAP, NULL); diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 31c3d9fd..782bb003 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -852,6 +852,25 @@ cli_del_map (void * v, char ** reply, int * len, void * data) return rc; } +int +cli_del_maps (void *v, char **reply, int *len, void *data) +{ + struct vectors * vecs = (struct vectors *)data; + struct multipath *mpp; + int i, ret = 0; + + condlog(2, "remove maps (operator)"); + vector_foreach_slot(vecs->mpvec, mpp, i) { + if (flush_map(mpp, vecs, 0)) + ret++; + else + i--; + } + /* flush any multipath maps that aren't currently known by multipathd */ + ret |= dm_flush_maps(0, 0); + return ret; +} + int cli_reload(void *v, char **reply, int *len, void *data) { diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 0f451064..6f57b429 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -26,6 +26,7 @@ int cli_add_path (void * v, char ** reply, int * len, void * data); int cli_del_path (void * v, char ** reply, int * len, void * data); int cli_add_map (void * v, char ** reply, int * len, void * data); int cli_del_map (void * v, char ** reply, int * len, void * data); +int cli_del_maps (void * v, char ** reply, int * len, void * data); int cli_switch_group(void * v, char ** reply, int * len, void * data); int cli_reconfigure(void * v, char ** reply, int * len, void * data); int cli_resize(void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 8fb73922..8f055646 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -631,7 +631,7 @@ sync_maps_state(vector mpvec) sync_map_state(mpp); } -static int +int flush_map(struct multipath * mpp, struct vectors * vecs, int nopaths) { int r; @@ -1551,6 +1551,7 @@ uxlsnrloop (void * ap) set_handler_callback(DEL+PATH, cli_del_path); set_handler_callback(ADD+MAP, cli_add_map); set_handler_callback(DEL+MAP, cli_del_map); + set_handler_callback(DEL+MAPS, cli_del_maps); set_handler_callback(SWITCH+MAP+GROUP, cli_switch_group); set_unlocked_handler_callback(RECONFIGURE, cli_reconfigure); set_handler_callback(SUSPEND+MAP, cli_suspend); diff --git a/multipathd/main.h b/multipathd/main.h index 7bb8463f..5dff17e5 100644 --- a/multipathd/main.h +++ b/multipathd/main.h @@ -28,6 +28,7 @@ int ev_add_path (struct path *, struct vectors *, int); int ev_remove_path (struct path *, struct vectors *, int); int ev_add_map (char *, const char *, struct vectors *); int ev_remove_map (char *, char *, int, struct vectors *); +int flush_map(struct multipath *, struct vectors *, int); int set_config_state(enum daemon_status); void * mpath_alloc_prin_response(int prin_sa); int prin_do_scsi_ioctl(char *, int rq_servact, struct prin_resp * resp, From patchwork Thu Jun 18 00:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611011 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8C3A618 for ; Thu, 18 Jun 2020 00:25:09 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 868892080D for ; Thu, 18 Jun 2020 00:25:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XYn0FANM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 868892080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439908; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lxQVoBecy1ArmjnB3ty+N6CqquxohsffaWz0hlSv3sY=; b=XYn0FANMJ6ESe3Oi/z8JukEHxXNwaGRvYMYq/Miw1V0RN0tSU/NL36lch9qJTNaeMpwEEQ l36An3IvaCyKl8j2ho+x6yqPoIhWAc226JBM3jIypFBYBY4STIy7tpCucE6He+TwWuvNiU 1hOVBmMeTV1iLYfhZO+y6wp0mCmVk0g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-sAaCoqhZOcObmCmYaWGhAg-1; Wed, 17 Jun 2020 20:25:04 -0400 X-MC-Unique: sAaCoqhZOcObmCmYaWGhAg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B960464; Thu, 18 Jun 2020 00:24:59 +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 512CE5C1D6; Thu, 18 Jun 2020 00:24:59 +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 297C91809554; Thu, 18 Jun 2020 00:24:59 +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 05I0Ock2026535 for ; Wed, 17 Jun 2020 20:24:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9022279302; Thu, 18 Jun 2020 00:24:38 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA2D7512FE; Thu, 18 Jun 2020 00:24:35 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OYxv018485; Wed, 17 Jun 2020 19:24:34 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OYk7018484; Wed, 17 Jun 2020 19:24:34 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:25 -0500 Message-Id: <1592439867-18427-6-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 5/7] multipath: make flushing maps work like other commands 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The config structure doesn't need a special variable just for removes. Multipath can just use the cmd variable, like it does for the other commands. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- libmultipath/config.h | 3 ++- libmultipath/configure.h | 3 --- multipath/main.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index ceecff2d..55569360 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -38,6 +38,8 @@ enum mpath_cmds { CMD_ADD_WWID, CMD_USABLE_PATHS, CMD_DUMP_CONFIG, + CMD_FLUSH_ONE, + CMD_FLUSH_ALL, }; enum force_reload_types { @@ -142,7 +144,6 @@ struct config { unsigned int max_checkint; bool use_watchdog; int pgfailback; - int remove; int rr_weight; int no_path_retry; int user_friendly_names; diff --git a/libmultipath/configure.h b/libmultipath/configure.h index d7509000..0e33bf40 100644 --- a/libmultipath/configure.h +++ b/libmultipath/configure.h @@ -45,9 +45,6 @@ enum { CP_RETRY, }; -#define FLUSH_ONE 1 -#define FLUSH_ALL 2 - struct vectors; int setup_map (struct multipath * mpp, char * params, int params_size, diff --git a/multipath/main.c b/multipath/main.c index d89f0a91..101fd656 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -909,10 +909,10 @@ main (int argc, char *argv[]) cmd = CMD_DRY_RUN; break; case 'f': - conf->remove = FLUSH_ONE; + cmd = CMD_FLUSH_ONE; break; case 'F': - conf->remove = FLUSH_ALL; + cmd = CMD_FLUSH_ALL; break; case 'l': if (optarg && !strncmp(optarg, "l", 1)) @@ -1053,6 +1053,10 @@ main (int argc, char *argv[]) condlog(0, "the -w option requires a device"); goto out; } + if (cmd == CMD_FLUSH_ONE && dev_type != DEV_DEVMAP) { + condlog(0, "the -f option requires a map name to remove"); + goto out; + } switch(delegate_to_multipathd(cmd, dev, dev_type, conf)) { case DELEGATE_OK: @@ -1086,16 +1090,12 @@ main (int argc, char *argv[]) } if (retries < 0) retries = conf->remove_retries; - if (conf->remove == FLUSH_ONE) { - if (dev_type == DEV_DEVMAP) { - r = dm_suspend_and_flush_map(dev, retries) ? - RTVL_FAIL : RTVL_OK; - } else - condlog(0, "must provide a map name to remove"); - + if (cmd == CMD_FLUSH_ONE) { + r = dm_suspend_and_flush_map(dev, retries) ? + RTVL_FAIL : RTVL_OK; goto out; } - else if (conf->remove == FLUSH_ALL) { + else if (cmd == CMD_FLUSH_ALL) { r = dm_flush_maps(1, retries) ? RTVL_FAIL : RTVL_OK; goto out; } From patchwork Thu Jun 18 00:24:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611015 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92E5E912 for ; Thu, 18 Jun 2020 00:26:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 518932080D for ; Thu, 18 Jun 2020 00:26:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="J5b9hAuk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 518932080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439966; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FcAXNZqeLDTUeJ6UIiRt9oud5lRwXpa2yRV3ajP0fbM=; b=J5b9hAukLD2bDfNPUr2auRvnPws2MTibHgdIzlOkrdwX6aOuNwOt0fR2cOD5JGeIw0RvQs oXcdEFDQFQEFn8f6FtnH1HkBpIxirWzqajs5/pQUbwigtw2rq8MrDUGLLK1ctLFot2mFU3 fB5W0NUtRrCQLpJeKRsGoZZZgCWFBU8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-hk-2Zu0lMJafCYULmvLvAg-1; Wed, 17 Jun 2020 20:25:09 -0400 X-MC-Unique: hk-2Zu0lMJafCYULmvLvAg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75550184D151; Thu, 18 Jun 2020 00:25:01 +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 5859560BF4; Thu, 18 Jun 2020 00:25:01 +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 30CFB1809557; Thu, 18 Jun 2020 00:25:01 +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 05I0OdRm026546 for ; Wed, 17 Jun 2020 20:24:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD2F47CAAA; Thu, 18 Jun 2020 00:24:39 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA2C4709D7; Thu, 18 Jun 2020 00:24:36 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0OZRX018489; Wed, 17 Jun 2020 19:24:35 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OZo1018488; Wed, 17 Jun 2020 19:24:35 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:26 -0500 Message-Id: <1592439867-18427-7-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 6/7] multipath: delegate flushing maps to multipathd 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Since there can be problems with removing maps outside of multipathd, multipath should attempt to delegate this command to multipathd. However, multipathd doesn't attempt to suspend the device, in order to avoid potential hangs. If delegating to multipathd fails, multipath should try the remove itself. Signed-off-by: Benjamin Marzinski Reviewed-by: Martin Wilck --- multipath/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/multipath/main.c b/multipath/main.c index 101fd656..6a24e483 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -820,6 +820,20 @@ int delegate_to_multipathd(enum mpath_cmds cmd, if (cmd == CMD_CREATE && conf->force_reload == FORCE_RELOAD_YES) { p += snprintf(p, n, "reconfigure"); } + else if (cmd == CMD_FLUSH_ONE && dev && dev_type == DEV_DEVMAP) { + p += snprintf(p, n, "del map %s", dev); + /* multipathd doesn't try as hard, to avoid potentially + * hanging. If it fails, retry with the regular multipath + * command */ + r = NOT_DELEGATED; + } + else if (cmd == CMD_FLUSH_ALL) { + p += snprintf(p, n, "del maps"); + /* multipathd doesn't try as hard, to avoid potentially + * hanging. If it fails, retry with the regular multipath + * command */ + r = NOT_DELEGATED; + } /* Add other translations here */ if (strlen(command) == 0) From patchwork Thu Jun 18 00:24:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 11611013 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45B52912 for ; Thu, 18 Jun 2020 00:25:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 023672080D for ; Thu, 18 Jun 2020 00:25:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Bo9QGES/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 023672080D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592439909; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=X1jz0CebPYLjCACkQOUV7JAQZQOmv9a+PpgfU3b0vlU=; b=Bo9QGES/BO5iQ7x26OxCirQXwRW7obkpuQJHJwvc3l6fOlBh6L/rAVzaHhfnbgN4GYKbiE 9sgz484u0f096Yy/IhncK8lmpo+7Cr6duCGh//0wKDRX58Vmk22SmFUo+CB9W2zFMbp2V5 03lqnU6Veh7XPldPrdXwS0sEjGEXsTk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-K7zU95bmM8e8roK_yBxZlw-1; Wed, 17 Jun 2020 20:25:07 -0400 X-MC-Unique: K7zU95bmM8e8roK_yBxZlw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B94F10059A6; Thu, 18 Jun 2020 00:25:03 +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 1C6BE1001E91; Thu, 18 Jun 2020 00:25:03 +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 EC22E833BD; Thu, 18 Jun 2020 00:25:02 +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 05I0Ofsq026557 for ; Wed, 17 Jun 2020 20:24:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0C50E5EE0E; Thu, 18 Jun 2020 00:24:41 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from octiron.msp.redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 237357E59A; Thu, 18 Jun 2020 00:24:38 +0000 (UTC) Received: from octiron.msp.redhat.com (localhost.localdomain [127.0.0.1]) by octiron.msp.redhat.com (8.14.9/8.14.9) with ESMTP id 05I0Oa6X018493; Wed, 17 Jun 2020 19:24:36 -0500 Received: (from bmarzins@localhost) by octiron.msp.redhat.com (8.14.9/8.14.9/Submit) id 05I0OaRt018492; Wed, 17 Jun 2020 19:24:36 -0500 From: Benjamin Marzinski To: Christophe Varoqui Date: Wed, 17 Jun 2020 19:24:27 -0500 Message-Id: <1592439867-18427-8-git-send-email-bmarzins@redhat.com> In-Reply-To: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> References: <1592439867-18427-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: device-mapper development , Martin Wilck Subject: [dm-devel] [PATCH 7/7] multipath: add option to skip multipathd delegation 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-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add the -D option to allow users to skip delegating commands to multipathd. Signed-off-by: Benjamin Marzinski --- libmultipath/config.h | 1 + multipath/main.c | 15 +++++++++++---- multipath/multipath.8 | 16 +++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libmultipath/config.h b/libmultipath/config.h index 55569360..92c61a0d 100644 --- a/libmultipath/config.h +++ b/libmultipath/config.h @@ -190,6 +190,7 @@ struct config { int ghost_delay; int find_multipaths_timeout; int marginal_pathgroups; + int skip_delegate; unsigned int version[3]; unsigned int sequence_nr; diff --git a/multipath/main.c b/multipath/main.c index 6a24e483..0cf7608f 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -130,9 +130,9 @@ usage (char * progname) { fprintf (stderr, VERSION_STRING); fprintf (stderr, "Usage:\n"); - fprintf (stderr, " %s [-v level] [-B|-d|-i|-q|-r] [-b file] [-p policy] [device]\n", progname); - fprintf (stderr, " %s [-v level] [-R retries] -f device\n", progname); - fprintf (stderr, " %s [-v level] [-R retries] -F\n", progname); + fprintf (stderr, " %s [-v level] [-B|-d|-D|-i|-q|-r] [-b file] [-p policy] [device]\n", progname); + fprintf (stderr, " %s [-v level] [-D|-R retries] -f device\n", progname); + fprintf (stderr, " %s [-v level] [-D|-R retries] -F\n", progname); fprintf (stderr, " %s [-v level] [-l|-ll] [device]\n", progname); fprintf (stderr, " %s [-v level] [-a|-w] device\n", progname); fprintf (stderr, " %s [-v level] -W\n", progname); @@ -153,6 +153,7 @@ usage (char * progname) " -C check if a multipath device has usable paths\n" " -q allow queue_if_no_path when multipathd is not running\n" " -d dry run, do not create or update devmaps\n" + " -D Do not delegate command to multipathd\n" " -t display the currently used multipathd configuration\n" " -T display the multipathd configuration without builtin defaults\n" " -r force devmap reload\n" @@ -817,6 +818,9 @@ int delegate_to_multipathd(enum mpath_cmds cmd, *p = '\0'; n = sizeof(command); + if (conf->skip_delegate) + return NOT_DELEGATED; + if (cmd == CMD_CREATE && conf->force_reload == FORCE_RELOAD_YES) { p += snprintf(p, n, "reconfigure"); } @@ -890,7 +894,7 @@ main (int argc, char *argv[]) multipath_conf = conf; conf->retrigger_tries = 0; conf->force_sync = 1; - while ((arg = getopt(argc, argv, ":adcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) { + while ((arg = getopt(argc, argv, ":adDcChl::eFfM:v:p:b:BrR:itTquUwW")) != EOF ) { switch(arg) { case 1: printf("optarg : %s\n",optarg); break; @@ -922,6 +926,9 @@ main (int argc, char *argv[]) if (cmd == CMD_CREATE) cmd = CMD_DRY_RUN; break; + case 'D': + conf->skip_delegate = 1; + break; case 'f': cmd = CMD_FLUSH_ONE; break; diff --git a/multipath/multipath.8 b/multipath/multipath.8 index 6fb8645a..16a27363 100644 --- a/multipath/multipath.8 +++ b/multipath/multipath.8 @@ -22,7 +22,7 @@ multipath \- Device mapper target autoconfig. .B multipath .RB [\| \-v\ \c .IR level \|] -.RB [\| \-B | \-d | \-i | \-q | \-r \|] +.RB [\| \-B | \-d | \-D | \-i | \-q | \-r \|] .RB [\| \-b\ \c .IR file \|] .RB [\| \-p\ \c @@ -33,7 +33,7 @@ multipath \- Device mapper target autoconfig. .B multipath .RB [\| \-v\ \c .IR level \|] -.RB [\| \-R\ \c +.RB [\| \-D | \-R\ \c .IR retries \|] .B \-f device . @@ -41,7 +41,7 @@ multipath \- Device mapper target autoconfig. .B multipath .RB [\| \-v\ \c .IR level \|] -.RB [\| \-R\ \c +.RB [\| \-D | \-R\ \c .IR retries \|] .B \-F . @@ -125,11 +125,11 @@ the system. Other operation modes are chosen by using one of the following command line switches: .TP .B \-f -Flush (remove) a multipath device map specified as parameter, if unused. +Flush (remove) a multipath device map specified as parameter, if unused. This operation is delegated to the multipathd daemon if it's running. . .TP .B \-F -Flush (remove) all unused multipath device maps. +Flush (remove) all unused multipath device maps. This operation is delegated to the multipathd daemon if it's running. . .TP .B \-l @@ -223,6 +223,12 @@ The verbosity level also controls the level of log and debug messages printed to Dry run, do not create or update devmaps. . .TP +.B \-D +Do not delegate operation to multipathd. By default, multipath delegates +forced reloads and flushes (removes) to multipathd. Setting this option will +cause the multipath command to execute these operations itself. +. +.TP .B \-e Enable all foreign libraries. This overrides the .I enable_foreign