From patchwork Tue Jan 8 13:53:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 1946221 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id C5D283FC5A for ; Tue, 8 Jan 2013 13:58:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r08Dtx3b002319; Tue, 8 Jan 2013 08:55:59 -0500 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 r08Dsbus004761 for ; Tue, 8 Jan 2013 08:54:37 -0500 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r08DsbQC024562 for ; Tue, 8 Jan 2013 08:54:37 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r08DsVMp003162 for ; Tue, 8 Jan 2013 08:54:32 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id B4D76A5203; Tue, 8 Jan 2013 14:54:28 +0100 (CET) From: Hannes Reinecke To: Christophe Varoqui Date: Tue, 8 Jan 2013 14:53:58 +0100 Message-Id: <1357653259-62650-21-git-send-email-hare@suse.de> In-Reply-To: <1357653259-62650-1-git-send-email-hare@suse.de> References: <1357653259-62650-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -7.299 (BAYES_00, DCC_REPUT_00_12, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: [dm-devel] [PATCH 20/42] Switch off 'queue_if_no_path' before removing maps 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 Before we try to flush a map we have to switch off the 'queue_if_no_path' setting to flush any outstanding I/O. Signed-off-by: Hannes Reinecke --- libmultipath/devmapper.c | 26 +++++++++++++++++++++++++- libmultipath/devmapper.h | 1 + multipath/main.c | 6 +++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 051ecb2..a6e7150 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -707,6 +707,30 @@ _dm_flush_map (const char * mapname, int need_sync) } extern int +dm_suspend_and_flush_map (const char * mapname) +{ + int s; + + if (!dm_map_present(mapname)) + return 0; + + if (dm_type(mapname, TGT_MPATH) <= 0) + return 0; /* nothing to do */ + + s = dm_queue_if_no_path((char *)mapname, 0); + if (!s) + s = dm_simplecmd_flush(DM_DEVICE_SUSPEND, mapname, 0); + + if (!dm_flush_map(mapname)) { + condlog(4, "multipath map %s removed", mapname); + return 0; + } + condlog(2, "failed to remove multipath map %s", mapname); + dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname); + return 1; +} + +extern int dm_flush_maps (void) { int r = 0; @@ -729,7 +753,7 @@ dm_flush_maps (void) goto out; do { - r |= dm_flush_map(names->name); + r |= dm_suspend_and_flush_map(names->name); next = names->next; names = (void *) names + next; } while (next); diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h index 0c2e03f..b08aa31 100644 --- a/libmultipath/devmapper.h +++ b/libmultipath/devmapper.h @@ -22,6 +22,7 @@ int dm_type(const char *, char *); int _dm_flush_map (const char *, int); #define dm_flush_map(mapname) _dm_flush_map(mapname, 1) #define dm_flush_map_nosync(mapname) _dm_flush_map(mapname, 0) +int dm_suspend_and_flush_map(const char * mapname); int dm_flush_maps (void); int dm_fail_path(char * mapname, char * path); int dm_reinstate_path(char * mapname, char * path); diff --git a/multipath/main.c b/multipath/main.c index 6208995..396c4b9 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -555,9 +555,9 @@ main (int argc, char *argv[]) goto out; } if (conf->remove == FLUSH_ONE) { - if (conf->dev_type == DEV_DEVMAP) - r = dm_flush_map(conf->dev); - else + if (conf->dev_type == DEV_DEVMAP) { + r = dm_suspend_and_flush_map(conf->dev); + } else condlog(0, "must provide a map name to remove"); goto out;