device-mapper-multipath/0134-RHBZ-1241528-check-mpath-prefix.patch

169 lines
4.7 KiB
Diff
Raw Normal View History

device-mapper-multipath-0.4.9-82 - Modify 0005-RH-add-mpathconf.patch * changed warning message - Modify 0102-RHBZ-1160478-mpathconf-template.patch * updated man page - Modify 0104-RHBZ-631009-deferred-remove.patch * refactor code and minor fix - Refresh 0107-RHBZ-1169935-no-new-devs.patch - Refresh 0112-RHBZ-1194917-add-config_dir-option.patch - Refresh 0126-RHBZ-1211383-alias-collision.patch - Add 0133-RHBZ-1296979-fix-define.patch * look for the correct libudev function to set define - Add 0134-RHBZ-1241528-check-mpath-prefix.patch * only touch devices with a "mpath-" dm uuid prefix - Add 0135-RHBZ-1299600-path-dev-uevents.patch * trigger path uevent the first time a path is claimed by multipath - Add 0136-RHBZ-1304687-wait-for-map-add.patch * wait for the device to finish being added before reloading it. - Add 0137-RHBZ-1280524-clear-chkr-msg.patch - Add 0138-RHBZ-1288660-fix-mpathconf-allow.patch * don't remove existing lines from blacklist_exceptions section - Add 0139-RHBZ-1273173-queue-no-daemon-doc.patch - Add 0140-RHBZ-1299647-fix-help.patch - Add 0141-RHBZ-1303953-mpathpersist-typo.patch - Add 0142-RHBZ-1283750-kpartx-fix.patch * only remove devices if their uuid says that they are the correct partition device - Add 0143-RHBZ-1299648-kpartx-sync.patch * default to using udev sync mode - Add 0144-RHBZ-1299652-alua-pref-arg.patch * allow "exclusive_pref_bit" argument to alua prioritizer - Add 0145-UP-resize-help-msg.patch - Add 0146-UPBZ-1299651-raw-output.patch * allow raw format mutipathd show commands, that remove headers and padding - Add 0147-RHBZ-1272620-fail-rm-msg.patch - Add 0148-RHBZ-1292599-verify-before-remove.patch * verify that all partitions are unused before attempting to remove a device - Add 0149-RHBZ-1292599-restore-removed-parts.patch * don't disable kpartx when restoring the first path of a device. - Add 0150-RHBZ-1253913-fix-startup-msg.patch * wait for multipathd daemon to write pidfile before returning - Add 0151-RHBZ-1297456-weighted-fix.patch * add wwn keyword to weighted prioritizer for persistent naming - Add 0152-RHBZ-1269293-fix-blk-unit-file.patch * use "Wants" instead of "Requires" - Add 0153-RH-fix-i686-size-bug.patch * use 64-bit keycodes for multipathd client commands - Add 0154-UPBZ-1291406-disable-reinstate.patch * don't automatically reinstate ghost paths for implicit alua devices - Add 0155-UPBZ-1300415-PURE-config.patch * Add default config for PURE FlashArray - Add 0156-UPBZ-1313324-dont-fail-discovery.patch * don't fail discovery because individual paths failed. - Add 0157-RHBZ-1319853-multipath-c-error-msg.patch * better error reporting for multipath -c - Add 0158-RHBZ-1318581-timestamp-doc-fix.patch * add documentation for -T - Add 0159-UPBZ-1255885-udev-waits.patch * make multipath and kpartx wait after for udev after each command
2016-04-22 02:27:49 +00:00
---
libmpathpersist/mpath_persist.c | 4 +-
libmultipath/devmapper.c | 67 +++++++++++++++++++++++++++++-----------
libmultipath/devmapper.h | 1
multipathd/main.c | 2 -
4 files changed, 53 insertions(+), 21 deletions(-)
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
===================================================================
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
@@ -160,7 +160,7 @@ int mpath_persistent_reserve_in (int fd,
condlog(3, "alias = %s", alias);
map_present = dm_map_present(alias);
- if (map_present && dm_type(alias, TGT_MPATH) <= 0){
+ if (map_present && !dm_is_mpath(alias)){
condlog( 0, "%s: not a multipath device.", alias);
ret = MPATH_PR_DMMP_ERROR;
goto out;
@@ -250,7 +250,7 @@ int mpath_persistent_reserve_out ( int f
condlog(3, "alias = %s", alias);
map_present = dm_map_present(alias);
- if (map_present && dm_type(alias, TGT_MPATH) <= 0){
+ if (map_present && !dm_is_mpath(alias)){
condlog(3, "%s: not a multipath device.", alias);
ret = MPATH_PR_DMMP_ERROR;
goto out;
Index: multipath-tools-130222/libmultipath/devmapper.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/devmapper.c
+++ multipath-tools-130222/libmultipath/devmapper.c
@@ -564,6 +564,48 @@ out:
return r;
}
+extern int
+dm_is_mpath(const char * name)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ struct dm_info info;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *params;
+ const char *uuid;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TABLE)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ dm_task_no_open_count(dmt);
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!dm_task_get_info(dmt, &info) || !info.exists)
+ goto out;
+
+ uuid = dm_task_get_uuid(dmt);
+
+ if (!uuid || strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN) != 0)
+ goto out;
+
+ /* Fetch 1st target */
+ dm_get_next_target(dmt, NULL, &start, &length, &target_type, &params);
+
+ if (!target_type || strcmp(target_type, TGT_MPATH) != 0)
+ goto out;
+
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
static int
dm_dev_t (const char * mapname, char * dev_t, int len)
{
@@ -672,10 +714,7 @@ _dm_flush_map (const char * mapname, int
{
int r;
- if (!dm_map_present(mapname))
- return 0;
-
- if (dm_type(mapname, TGT_MPATH) <= 0)
+ if (!dm_is_mpath(mapname))
return 0; /* nothing to do */
if (dm_remove_partmaps(mapname, need_sync, deferred_remove))
@@ -725,10 +764,7 @@ dm_suspend_and_flush_map (const char * m
unsigned long long mapsize;
char params[PARAMS_SIZE] = {0};
- if (!dm_map_present(mapname))
- return 0;
-
- if (dm_type(mapname, TGT_MPATH) <= 0)
+ if (!dm_is_mpath(mapname))
return 0; /* nothing to do */
if (!dm_get_map(mapname, &mapsize, params)) {
@@ -899,7 +935,6 @@ dm_get_maps (vector mp)
{
struct multipath * mpp;
int r = 1;
- int info;
struct dm_task *dmt;
struct dm_names *names;
unsigned next = 0;
@@ -924,9 +959,7 @@ dm_get_maps (vector mp)
}
do {
- info = dm_type(names->name, TGT_MPATH);
-
- if (info <= 0)
+ if (!dm_is_mpath(names->name))
goto next;
mpp = alloc_multipath();
@@ -939,13 +972,11 @@ dm_get_maps (vector mp)
if (!mpp->alias)
goto out1;
- if (info > 0) {
- if (dm_get_map(names->name, &mpp->size, NULL))
- goto out1;
+ if (dm_get_map(names->name, &mpp->size, NULL))
+ goto out1;
- dm_get_uuid(names->name, mpp->wwid);
- dm_get_info(names->name, &mpp->dmi);
- }
+ dm_get_uuid(names->name, mpp->wwid);
+ dm_get_info(names->name, &mpp->dmi);
if (!vector_alloc_slot(mp))
goto out1;
Index: multipath-tools-130222/libmultipath/devmapper.h
===================================================================
--- multipath-tools-130222.orig/libmultipath/devmapper.h
+++ multipath-tools-130222/libmultipath/devmapper.h
@@ -23,6 +23,7 @@ int dm_map_present (const char *);
int dm_get_map(const char *, unsigned long long *, char *);
int dm_get_status(char *, char *);
int dm_type(const char *, char *);
+int dm_is_mpath(const char *);
int _dm_flush_map (const char *, int, int);
int dm_flush_map_nopaths(const char * mapname, int deferred_remove);
#define dm_flush_map(mapname) _dm_flush_map(mapname, 1, 0)
Index: multipath-tools-130222/multipathd/main.c
===================================================================
--- multipath-tools-130222.orig/multipathd/main.c
+++ multipath-tools-130222/multipathd/main.c
@@ -285,7 +285,7 @@ ev_add_map (char * dev, char * alias, st
map_present = dm_map_present(alias);
- if (map_present && dm_type(alias, TGT_MPATH) <= 0) {
+ if (map_present && !dm_is_mpath(alias)) {
condlog(4, "%s: not a multipath map", alias);
return 0;
}