6738b34a0b
- 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
190 lines
5.2 KiB
Diff
190 lines
5.2 KiB
Diff
---
|
|
kpartx/devmapper.c | 17 +++++++++++++--
|
|
kpartx/devmapper.h | 2 -
|
|
kpartx/kpartx.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++---
|
|
3 files changed, 69 insertions(+), 7 deletions(-)
|
|
|
|
Index: multipath-tools-130222/kpartx/devmapper.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/kpartx/devmapper.c
|
|
+++ multipath-tools-130222/kpartx/devmapper.c
|
|
@@ -140,12 +140,16 @@ addout:
|
|
}
|
|
|
|
extern int
|
|
-dm_map_present (char * str)
|
|
+dm_map_present (char * str, char **uuid)
|
|
{
|
|
int r = 0;
|
|
struct dm_task *dmt;
|
|
+ const char *uuidtmp;
|
|
struct dm_info info;
|
|
|
|
+ if (uuid)
|
|
+ *uuid = NULL;
|
|
+
|
|
if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
|
|
return 0;
|
|
|
|
@@ -160,8 +164,15 @@ dm_map_present (char * str)
|
|
if (!dm_task_get_info(dmt, &info))
|
|
goto out;
|
|
|
|
- if (info.exists)
|
|
- r = 1;
|
|
+ if (!info.exists)
|
|
+ goto out;
|
|
+
|
|
+ r = 1;
|
|
+ if (uuid) {
|
|
+ uuidtmp = dm_task_get_uuid(dmt);
|
|
+ if (uuidtmp && strlen(uuidtmp))
|
|
+ *uuid = strdup(uuidtmp);
|
|
+ }
|
|
out:
|
|
dm_task_destroy(dmt);
|
|
return r;
|
|
Index: multipath-tools-130222/kpartx/devmapper.h
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/kpartx/devmapper.h
|
|
+++ multipath-tools-130222/kpartx/devmapper.h
|
|
@@ -14,7 +14,7 @@ int dm_prereq (char *, int, int, int);
|
|
int dm_simplecmd (int, const char *, int, uint32_t *, uint16_t);
|
|
int dm_addmap (int, const char *, const char *, const char *, uint64_t,
|
|
int, const char *, int, mode_t, uid_t, gid_t, uint32_t *);
|
|
-int dm_map_present (char *);
|
|
+int dm_map_present (char *, char **);
|
|
char * dm_mapname(int major, int minor);
|
|
dev_t dm_get_first_dep(char *devname);
|
|
char * dm_mapuuid(int major, int minor);
|
|
Index: multipath-tools-130222/kpartx/kpartx.c
|
|
===================================================================
|
|
--- multipath-tools-130222.orig/kpartx/kpartx.c
|
|
+++ multipath-tools-130222/kpartx/kpartx.c
|
|
@@ -191,6 +191,21 @@ get_hotplug_device(void)
|
|
return device;
|
|
}
|
|
|
|
+static int
|
|
+check_uuid(char *uuid, char *part_uuid, char **err_msg) {
|
|
+ char *map_uuid = strchr(part_uuid, '-');
|
|
+ if (!map_uuid || strncmp(part_uuid, "part", 4) != 0) {
|
|
+ *err_msg = "not a kpartx partition";
|
|
+ return -1;
|
|
+ }
|
|
+ map_uuid++;
|
|
+ if (strcmp(uuid, map_uuid) != 0) {
|
|
+ *err_msg = "a partition of a different device";
|
|
+ return -1;
|
|
+ }
|
|
+ return 0;
|
|
+}
|
|
+
|
|
int
|
|
main(int argc, char **argv){
|
|
int i, j, m, n, op, off, arg, ro=0;
|
|
@@ -410,6 +425,8 @@ main(int argc, char **argv){
|
|
|
|
case DELETE:
|
|
for (j = MAXSLICES-1; j >= 0; j--) {
|
|
+ char *part_uuid, *reason;
|
|
+
|
|
if (safe_sprintf(partname, "%s%s%d",
|
|
mapname, delim, j+1)) {
|
|
fprintf(stderr, "partname too small\n");
|
|
@@ -417,9 +434,18 @@ main(int argc, char **argv){
|
|
}
|
|
strip_slash(partname);
|
|
|
|
- if (!dm_map_present(partname))
|
|
+ if (!dm_map_present(partname, &part_uuid))
|
|
continue;
|
|
|
|
+ if (part_uuid && uuid) {
|
|
+ if (check_uuid(uuid, part_uuid, &reason) != 0) {
|
|
+ fprintf(stderr, "%s is %s. Not removing\n", partname, reason);
|
|
+ free(part_uuid);
|
|
+ continue;
|
|
+ }
|
|
+ free(part_uuid);
|
|
+ }
|
|
+
|
|
if (!dm_simplecmd(DM_DEVICE_REMOVE, partname,
|
|
0, &cookie, 0)) {
|
|
r++;
|
|
@@ -444,6 +470,8 @@ main(int argc, char **argv){
|
|
case UPDATE:
|
|
/* ADD and UPDATE share the same code that adds new partitions. */
|
|
for (j = 0; j < n; j++) {
|
|
+ char *part_uuid, *reason;
|
|
+
|
|
if (slices[j].size == 0)
|
|
continue;
|
|
|
|
@@ -460,9 +488,19 @@ main(int argc, char **argv){
|
|
exit(1);
|
|
}
|
|
|
|
- op = (dm_map_present(partname) ?
|
|
+ op = (dm_map_present(partname, &part_uuid) ?
|
|
DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
|
|
|
|
+ if (part_uuid && uuid) {
|
|
+ if (check_uuid(uuid, part_uuid, &reason) != 0) {
|
|
+ fprintf(stderr, "%s is already in use, and %s\n", partname, reason);
|
|
+ r++;
|
|
+ free(part_uuid);
|
|
+ continue;
|
|
+ }
|
|
+ free(part_uuid);
|
|
+ }
|
|
+
|
|
if (!dm_addmap(op, partname, DM_TARGET, params,
|
|
slices[j].size, ro, uuid, j+1,
|
|
buf.st_mode & 0777, buf.st_uid,
|
|
@@ -470,6 +508,7 @@ main(int argc, char **argv){
|
|
fprintf(stderr, "create/reload failed on %s\n",
|
|
partname);
|
|
r++;
|
|
+ continue;
|
|
}
|
|
if (op == DM_DEVICE_RELOAD &&
|
|
!dm_simplecmd(DM_DEVICE_RESUME, partname,
|
|
@@ -477,6 +516,7 @@ main(int argc, char **argv){
|
|
fprintf(stderr, "resume failed on %s\n",
|
|
partname);
|
|
r++;
|
|
+ continue;
|
|
}
|
|
dm_devn(partname, &slices[j].major,
|
|
&slices[j].minor);
|
|
@@ -494,6 +534,7 @@ main(int argc, char **argv){
|
|
}
|
|
|
|
for (j = MAXSLICES-1; j >= 0; j--) {
|
|
+ char *part_uuid, *reason;
|
|
if (safe_sprintf(partname, "%s%s%d",
|
|
mapname, delim, j+1)) {
|
|
fprintf(stderr, "partname too small\n");
|
|
@@ -501,9 +542,19 @@ main(int argc, char **argv){
|
|
}
|
|
strip_slash(partname);
|
|
|
|
- if (slices[j].size || !dm_map_present(partname))
|
|
+ if (slices[j].size ||
|
|
+ !dm_map_present(partname, &part_uuid))
|
|
continue;
|
|
|
|
+ if (part_uuid && uuid) {
|
|
+ if (check_uuid(uuid, part_uuid, &reason) != 0) {
|
|
+ fprintf(stderr, "%s is %s. Not removing\n", partname, reason);
|
|
+ free(part_uuid);
|
|
+ continue;
|
|
+ }
|
|
+ free(part_uuid);
|
|
+ }
|
|
+
|
|
if (!dm_simplecmd(DM_DEVICE_REMOVE,
|
|
partname, 1, &cookie, 0)) {
|
|
r++;
|