From patchwork Wed Feb 12 17:15:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 3641581 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 9A032BF13A for ; Wed, 12 Feb 2014 23:20:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DBAD20165 for ; Wed, 12 Feb 2014 23:20:03 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 8C75C2012D for ; Wed, 12 Feb 2014 23:20:02 +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 s1CNGSR6022151; Wed, 12 Feb 2014 18:16:29 -0500 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 s1CNFjgA030362 for ; Wed, 12 Feb 2014 18:15:46 -0500 Received: from ask-08.lab.msp.redhat.com (ask-08.lab.msp.redhat.com [10.15.85.8]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1CNFjJ7004175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 12 Feb 2014 18:15:45 -0500 Received: from ask-08.lab.msp.redhat.com (localhost [127.0.0.1]) by ask-08.lab.msp.redhat.com (8.14.6/8.14.6) with ESMTP id s1CHFIpR013938; Wed, 12 Feb 2014 11:15:18 -0600 Received: (from root@localhost) by ask-08.lab.msp.redhat.com (8.14.6/8.14.6/Submit) id s1CHFIH0013937; Wed, 12 Feb 2014 11:15:18 -0600 From: Benjamin Marzinski To: device-mapper development Date: Wed, 12 Feb 2014 11:15:16 -0600 Message-Id: <1392225317-13898-2-git-send-email-bmarzins@redhat.com> In-Reply-To: <1392225317-13898-1-git-send-email-bmarzins@redhat.com> References: <1392225317-13898-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: Peter Rajnoha , Christophe Varoqui Subject: [dm-devel] [PATCH 1/2] New udev rules to deal with stacked devices 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.6 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 This new rules file sets some DM_* udev environment variables to keep device mapper for doing unnecessary work on multipath device uevents. Previously, devices with no valid paths were being scanned. Also devices were being rescanned on uevents caused by paths being added or removed. These are now avoided. Signed-off-by: Peter Rajnoha Signed-off-by: Benjamin Marzinski --- Makefile.inc | 1 + multipath/11-dm-mpath.rules | 34 ++++++++++++++++++++++++++++++++++ multipath/Makefile | 3 +++ 3 files changed, 38 insertions(+) create mode 100644 multipath/11-dm-mpath.rules diff --git a/Makefile.inc b/Makefile.inc index f445160..0669d32 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -31,6 +31,7 @@ prefix = exec_prefix = $(prefix) bindir = $(exec_prefix)/sbin libudevdir = ${prefix}/lib/udev +udevrulesdir = $(libudevdir)/rules.d multipathdir = $(TOPDIR)/libmultipath mandir = $(prefix)/usr/share/man/man8 man5dir = $(prefix)/usr/share/man/man5 diff --git a/multipath/11-dm-mpath.rules b/multipath/11-dm-mpath.rules new file mode 100644 index 0000000..69c24b5 --- /dev/null +++ b/multipath/11-dm-mpath.rules @@ -0,0 +1,34 @@ +ACTION!="add|change", GOTO="mpath_end" +ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="mpath_end" +ENV{DM_UUID}!="mpath-?*", GOTO="mpath_end" + +# Do not initiate scanning if no path is available, +# otherwise there would be a hang or IO error on access. +# We'd like to avoid this, especially within udev processing. +ENV{DM_NR_VALID_PATHS}!="?*", IMPORT{db}="DM_NR_VALID_PATHS" +ENV{DM_NR_VALID_PATHS}=="0", ENV{DM_NOSCAN}="1" + +# Also skip all foreign rules if no path is available. +# Remember the original value of DM_DISABLE_OTHER_RULES_FLAG +# and restore it back once we have at least one path available. +IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD" +ENV{DM_ACTION}=="PATH_FAILED",\ + ENV{DM_NR_VALID_PATHS}=="0",\ + ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}=="",\ + ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}",\ + ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1" +ENV{DM_ACTION}=="PATH_REINSTATED",\ + ENV{DM_NR_VALID_PATHS}=="1",\ + ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}",\ + ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="",\ + ENV{DM_ACTIVATION}="1" + +# DM_SUBSYSTEM_UDEV_FLAG0 is the "RELOAD" flag for multipath subsystem. +# Drop the DM_ACTIVATION flag here as mpath reloads tables if any of its +# paths are lost/recovered. For any stack above the mpath device, this is not +# something that should be reacted upon since it would be useless extra work. +# It's exactly mpath's job to provide *seamless* device access to any of the +# paths that are available underneath. +ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_ACTIVATION}="0" + +LABEL="mpath_end" diff --git a/multipath/Makefile b/multipath/Makefile index 5e5958d..e295676 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -21,6 +21,8 @@ $(EXEC): $(OBJS) install: $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/ + $(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) + $(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) $(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir) $(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir) $(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir) @@ -28,6 +30,7 @@ install: uninstall: rm $(DESTDIR)$(bindir)/$(EXEC) + rm $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules rm $(DESTDIR)$(mandir)/$(EXEC).8.gz rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz