From patchwork Thu Mar 25 17:52:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 88299 Received: from mx02.colomx.prod.int.phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2PI79Xb032499 for ; Thu, 25 Mar 2010 18:07:45 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx02.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2PI4kk6009293; Thu, 25 Mar 2010 14:04:47 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2PI4iq2007094 for ; Thu, 25 Mar 2010 14:04:44 -0400 Received: from ether.msp.redhat.com (ether.msp.redhat.com [10.15.80.119]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2PI4dRD017407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Mar 2010 14:04:39 -0400 Received: from ether.msp.redhat.com (localhost.localdomain [127.0.0.1]) by ether.msp.redhat.com (8.14.1/8.14.1) with ESMTP id o2PHq6k5009198 for ; Thu, 25 Mar 2010 12:52:06 -0500 Received: (from bmarzins@localhost) by ether.msp.redhat.com (8.14.1/8.14.1/Submit) id o2PHq6KL009197 for dm-devel@redhat.com; Thu, 25 Mar 2010 12:52:06 -0500 Date: Thu, 25 Mar 2010 12:52:06 -0500 From: Benjamin Marzinski To: device-mapper development Message-ID: <20100325175205.GG23952@ether.msp.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] multipath: don't let init script stop multipathd for root 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: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 25 Mar 2010 18:07:45 +0000 (UTC) Index: multipath-tools-100322/multipathd/multipathd.init.redhat =================================================================== --- multipath-tools-100322.orig/multipathd/multipathd.init.redhat +++ multipath-tools-100322/multipathd/multipathd.init.redhat @@ -2,7 +2,7 @@ # # multipathd Starts the multipath daemon # -# chkconfig: - 13 87 +# chkconfig: - 06 87 # description: Manages device-mapper multipath devices ### BEGIN INIT INFO @@ -17,6 +17,7 @@ prog=`basename $DAEMON` initdir=/etc/rc.d/init.d lockdir=/var/lock/subsys sysconfig=/etc/sysconfig +syspath=/sys/block . $initdir/functions @@ -25,6 +26,36 @@ test -r $sysconfig/$prog && . $sysconfig RETVAL=0 +teardown_slaves() +{ +pushd $1 > /dev/null +if [ -d "slaves" ]; then +for slave in slaves/*; +do + if [ "$slave" = "slaves/*" ]; then + read dev < $1/dev + tablename=`dmsetup table --target multipath | sed -n "s/\(.*\): .* $dev .*/\1/p"` + if ! [ -z $tablename ]; then + echo "Root is on a multipathed device, multipathd can not be stopped" + exit 1 + fi + else + local_slave=`readlink -f $slave`; + teardown_slaves $local_slave; + fi + done + +else + read dev < $1/dev + tablename=`dmsetup table --target multipath | sed -n "s/\(.*\): .* $dev .*/\1/p"` + if ! [ -z $tablename ]; then + echo "Root is on a multipathed device, multipathd can not be stopped" + exit 1 + fi +fi +popd > /dev/null +} + # # See how we were called. # @@ -39,6 +70,11 @@ start() { } stop() { + root_dev=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/mtab) + dm_num=`dmsetup info -c --noheadings -o minor $root_dev` + root_dm_device="dm-$dm_num" + [ -d $syspath/$root_dm_device ] && teardown_slaves $syspath/$root_dm_device + echo -n $"Stopping $prog daemon: " killproc $DAEMON RETVAL=$?