From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: [RFC PATCH] multipath-tools: Preventing silent swapping of underlying LUNs
Date: Thu, 19 Jul 2012 17:07:31 +0900 [thread overview]
Message-ID: <5007C043.4000006@ce.jp.nec.com> (raw)
Hi,
I found multipathd could unexpectedly swaps underlying LUNs
when it should swap names.
Suppose someone has following /etc/multipath/bindings:
mpathA <wwid of LUN0>
mpathB <wwid of LUN1>
and created those multipath devices.
If he modified bindings as below and do 'multipathd -kreconfigure':
mpathB <wwid of LUN0>
mpathA <wwid of LUN1>
I think it is natural to expect the mpath device for <wwid of LUN0>
("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.
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)",
next reply other threads:[~2012-07-19 8:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 8:07 Jun'ichi Nomura [this message]
2012-08-17 8:40 ` [PATCH] multipath-tools: prevent unexpected swapping of underlying LUNs Jun'ichi Nomura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5007C043.4000006@ce.jp.nec.com \
--to=j-nomura@ce.jp.nec.com \
--cc=dm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.