From patchwork Thu Jul 19 08:07:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junichi Nomura X-Patchwork-Id: 1215791 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork1.kernel.org (Postfix) with ESMTP id 1CE983FD4F for ; Thu, 19 Jul 2012 08:11:45 +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 q6J889t0017187; Thu, 19 Jul 2012 04:08:12 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6J8887v030935 for ; Thu, 19 Jul 2012 04:08:08 -0400 Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6J883Xx022811 for ; Thu, 19 Jul 2012 04:08:03 -0400 Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [202.32.8.193]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6J881l6002222 for ; Thu, 19 Jul 2012 04:08:01 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.160]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id q6J880v2020709 for ; Thu, 19 Jul 2012 17:08:00 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id q6J880X08794 for dm-devel@redhat.com; Thu, 19 Jul 2012 17:08:00 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id q6J880hl022853 for ; Thu, 19 Jul 2012 17:08:00 +0900 (JST) Received: from kogoro.jp.nec.com ([10.26.220.12] [10.26.220.12]) by mail01b.kamome.nec.co.jp with ESMTP id BT-MMP-486502; Thu, 19 Jul 2012 17:07:31 +0900 Received: from xzibit.linux.bs1.fc.nec.co.jp ([10.34.125.175] [10.34.125.175]) by mail.jp.nec.com with ESMTPA id BT-MMP-46364; Thu, 19 Jul 2012 17:07:31 +0900 Message-ID: <5007C043.4000006@ce.jp.nec.com> Date: Thu, 19 Jul 2012 17:07:31 +0900 From: "Jun'ichi Nomura" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: device-mapper development X-RedHat-Spam-Score: -4.202 (BAYES_00, RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.19 X-loop: dm-devel@redhat.com Subject: [dm-devel] [RFC PATCH] multipath-tools: Preventing silent swapping of underlying LUNs 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 Hi, I found multipathd could unexpectedly swaps underlying LUNs when it should swap names. Suppose someone has following /etc/multipath/bindings: mpathA mpathB and created those multipath devices. If he modified bindings as below and do 'multipathd -kreconfigure': mpathB mpathA I think it is natural to expect the mpath device for ("mpathA") is renamed to "mpathB" and vice versa. However, what actually happens is mpathA's underlying device is changed to LUN1 and mpathB's underlying device is changed to LUN0. As a result, users of those devices (mounted file systems, LVs, etc.) could get errors and/or corrupt data. (This not just about dynamic reconfiguration. Similar thing could happen if you forget to rebuild initrd after modifying bindings.) If there is smarter solution such as swapping aliases correctly, it would be nice. But I think it's good to have a patch like this at a minimum to prevent the bad thing from happening. Comments? --- Jun'ichi Nomura, NEC Corporation Given alias/wwid pair in config, if there is a mpath with the wwid and different alias, the mpath should be renamed to the given alias. If there is already other mpath with the alias, though, we could not simply rename it. However, we must NOT try to create a mpath with the given alias/wwid by changing the wwid (i.e. mappings) of the other mpath, that could corrupt data. The patch checks this case and give up processing. -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff -urp multipath-tools.orig/libmultipath/configure.c multipath-tools.new/libmultipath/configure.c --- multipath-tools.orig/libmultipath/configure.c 2012-07-19 15:17:40.368622358 +0900 +++ multipath-tools.new/libmultipath/configure.c 2012-07-19 15:29:23.360746687 +0900 @@ -150,6 +150,7 @@ static void select_action (struct multipath * mpp, vector curmp, int force_reload) { struct multipath * cmpp; + struct multipath * cmpp_tmp; cmpp = find_mp_by_alias(curmp, mpp->alias); @@ -169,7 +170,8 @@ select_action (struct multipath * mpp, v return; } - if (!find_mp_by_wwid(curmp, mpp->wwid)) { + cmpp_tmp = find_mp_by_wwid(curmp, mpp->wwid); + if (!cmpp_tmp) { condlog(2, "%s: remove (wwid changed)", cmpp->alias); dm_flush_map(mpp->alias); strncpy(cmpp->wwid, mpp->wwid, WWID_SIZE); @@ -180,6 +182,14 @@ select_action (struct multipath * mpp, v return; } + if (cmpp != cmpp_tmp) { + condlog(2, "%s: unable to rename %s to %s (%s is used by %s)", + mpp->wwid, cmpp_tmp->alias, mpp->alias, + mpp->alias, cmpp->wwid); + mpp->action = ACT_NOTHING; + return; + } + if (pathcount(mpp, PATH_UP) == 0) { mpp->action = ACT_NOTHING; condlog(3, "%s: set ACT_NOTHING (no usable path)",