All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Hannes Reinecke <hare@suse.de>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com
Subject: [PATCH v2 08/12] libmultipath: don't treat multi-linear mappings as partitions
Date: Mon, 15 May 2017 17:37:18 +0200	[thread overview]
Message-ID: <20170515153722.11508-9-mwilck@suse.com> (raw)
In-Reply-To: <20170515153722.11508-1-mwilck@suse.com>

dm_type is used in libmultipath only to check whether a mapping
is "linear", with the intention to test if it represents a
"partition". This test returns TRUE also for mappings with
multiple targets, the first of which happens to be a linear
mapping into the target device. This is questionable, it's
hard to assign a "type" to such maps anyway.

Fix this by returning an error for multi-target maps.
This is analogous to the patch
"kpartx: don't treat multi-linear mappings as partitions".

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/devmapper.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 5fb9d9ac..c19dcb62 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -572,7 +572,7 @@ out:
  * returns:
  *    1 : match
  *    0 : no match
- *   -1 : empty map
+ *   -1 : empty map, or more than 1 target
  */
 int dm_type(const char *name, char *type)
 {
@@ -594,10 +594,11 @@ int dm_type(const char *name, char *type)
 		goto out;
 
 	/* Fetch 1st target */
-	dm_get_next_target(dmt, NULL, &start, &length,
-			   &target_type, &params);
-
-	if (!target_type)
+	if (dm_get_next_target(dmt, NULL, &start, &length,
+			       &target_type, &params) != NULL)
+		/* multiple targets */
+		r = -1;
+	else if (!target_type)
 		r = -1;
 	else if (!strcmp(target_type, type))
 		r = 1;
@@ -1185,9 +1186,9 @@ do_foreach_partmaps (const char * mapname,
 	do {
 		if (
 		    /*
-		     * if devmap target is "linear"
+		     * if there is only a single "linear" target
 		     */
-		    (dm_type(names->name, TGT_PART) > 0) &&
+		    (dm_type(names->name, TGT_PART) == 1) &&
 
 		    /*
 		     * and both uuid end with same suffix starting
-- 
2.12.2

  parent reply	other threads:[~2017-05-15 15:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 15:37 [PATCH v2 00/12] fixes for kpartx -d Martin Wilck
2017-05-15 15:37 ` [PATCH v2 01/12] kpartx: test-kpartx: new unit test program Martin Wilck
2017-05-15 15:37 ` [PATCH v2 02/12] kpartx: remove "no_partitions" support Martin Wilck
2017-05-15 15:37 ` [PATCH v2 03/12] kpartx: remove is_loop_device Martin Wilck
2017-05-15 15:37 ` [PATCH v2 04/12] kpartx: relax and improve UUID check in dm_compare_uuid Martin Wilck
2017-05-15 15:37 ` [PATCH v2 05/12] kpartx: dm_remove_partmaps: support non-dm devices Martin Wilck
2017-05-15 15:37 ` [PATCH v2 06/12] kpartx: dm_devn: return error for non-existent device Martin Wilck
2017-05-15 15:37 ` [PATCH v2 07/12] kpartx: don't treat multi-linear mappings as partitions Martin Wilck
2017-05-15 15:37 ` Martin Wilck [this message]
2017-05-15 15:37 ` [PATCH v2 09/12] kpartx: use partition UUID for non-DM devices Martin Wilck
2017-05-15 15:37 ` [PATCH v2 10/12] kpartx: use absolute path for regular files Martin Wilck
2017-05-15 15:37 ` [PATCH v2 11/12] kpartx: find_loop_by_file: use sysfs Martin Wilck
2017-05-15 15:37 ` [PATCH v2 12/12] kpartx: include sys/sysmacros.h Martin Wilck
2017-05-17 17:06 ` [PATCH v2 00/12] fixes for kpartx -d Benjamin Marzinski
2017-05-17 22:25   ` Christophe Varoqui

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=20170515153722.11508-9-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    /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.