|
|
c896fb |
---
|
|
|
c896fb |
libmultipath/devmapper.c | 45 +++++++++++++++++++++++++++++++++++++--------
|
|
|
c896fb |
libmultipath/devmapper.h | 2 +-
|
|
|
c896fb |
2 files changed, 38 insertions(+), 9 deletions(-)
|
|
|
c896fb |
|
|
|
c896fb |
Index: multipath-tools-130222/libmultipath/devmapper.c
|
|
|
c896fb |
===================================================================
|
|
|
c896fb |
--- multipath-tools-130222.orig/libmultipath/devmapper.c
|
|
|
c896fb |
+++ multipath-tools-130222/libmultipath/devmapper.c
|
|
|
c896fb |
@@ -33,6 +33,9 @@
|
|
|
c896fb |
#define UUID_PREFIX_LEN 6
|
|
|
c896fb |
|
|
|
c896fb |
static int dm_cancel_remove_partmaps(const char * mapname);
|
|
|
c896fb |
+static int do_foreach_partmaps (const char * mapname,
|
|
|
c896fb |
+ int (*partmap_func)(const char *, void *),
|
|
|
c896fb |
+ void *data);
|
|
|
c896fb |
|
|
|
c896fb |
#ifndef LIBDM_API_COOKIE
|
|
|
c896fb |
static inline int dm_task_set_cookie(struct dm_task *dmt, uint32_t *c, int a)
|
|
|
c896fb |
@@ -709,6 +712,26 @@ out:
|
|
|
c896fb |
return r;
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
+static int
|
|
|
c896fb |
+partmap_in_use(const char *name, void *data)
|
|
|
c896fb |
+{
|
|
|
c896fb |
+ int part_count, *ret_count = (int *)data;
|
|
|
c896fb |
+ int open_count = dm_get_opencount(name);
|
|
|
c896fb |
+
|
|
|
c896fb |
+ if (ret_count)
|
|
|
c896fb |
+ (*ret_count)++;
|
|
|
c896fb |
+ part_count = 0;
|
|
|
c896fb |
+ if (open_count) {
|
|
|
c896fb |
+ if (do_foreach_partmaps(name, partmap_in_use, &part_count))
|
|
|
c896fb |
+ return 1;
|
|
|
c896fb |
+ if (open_count != part_count) {
|
|
|
c896fb |
+ condlog(2, "%s: map in use", name);
|
|
|
c896fb |
+ return 1;
|
|
|
c896fb |
+ }
|
|
|
c896fb |
+ }
|
|
|
c896fb |
+ return 0;
|
|
|
c896fb |
+}
|
|
|
c896fb |
+
|
|
|
c896fb |
extern int
|
|
|
c896fb |
_dm_flush_map (const char * mapname, int need_sync, int deferred_remove)
|
|
|
c896fb |
{
|
|
|
c896fb |
@@ -717,6 +740,11 @@ _dm_flush_map (const char * mapname, int
|
|
|
c896fb |
if (!dm_is_mpath(mapname))
|
|
|
c896fb |
return 0; /* nothing to do */
|
|
|
c896fb |
|
|
|
c896fb |
+ /* If you aren't doing a deferred remove, make sure that no
|
|
|
c896fb |
+ * devices are in use */
|
|
|
c896fb |
+ if (!do_deferred(deferred_remove) && partmap_in_use(mapname, NULL))
|
|
|
c896fb |
+ return 1;
|
|
|
c896fb |
+
|
|
|
c896fb |
if (dm_remove_partmaps(mapname, need_sync, deferred_remove))
|
|
|
c896fb |
return 1;
|
|
|
c896fb |
|
|
|
c896fb |
@@ -825,7 +853,7 @@ dm_flush_maps (void)
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
int
|
|
|
c896fb |
-dm_message(char * mapname, char * message)
|
|
|
c896fb |
+dm_message(const char * mapname, char * message)
|
|
|
c896fb |
{
|
|
|
c896fb |
int r = 1;
|
|
|
c896fb |
struct dm_task *dmt;
|
|
|
c896fb |
@@ -1076,7 +1104,8 @@ bad:
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
static int
|
|
|
c896fb |
-do_foreach_partmaps (const char * mapname, int (*partmap_func)(char *, void *),
|
|
|
c896fb |
+do_foreach_partmaps (const char * mapname,
|
|
|
c896fb |
+ int (*partmap_func)(const char *, void *),
|
|
|
c896fb |
void *data)
|
|
|
c896fb |
{
|
|
|
c896fb |
struct dm_task *dmt;
|
|
|
c896fb |
@@ -1149,7 +1178,7 @@ struct remove_data {
|
|
|
c896fb |
};
|
|
|
c896fb |
|
|
|
c896fb |
static int
|
|
|
c896fb |
-remove_partmap(char *name, void *data)
|
|
|
c896fb |
+remove_partmap(const char *name, void *data)
|
|
|
c896fb |
{
|
|
|
c896fb |
struct remove_data *rd = (struct remove_data *)data;
|
|
|
c896fb |
|
|
|
c896fb |
@@ -1176,7 +1205,7 @@ dm_remove_partmaps (const char * mapname
|
|
|
c896fb |
#ifdef LIBDM_API_DEFERRED
|
|
|
c896fb |
|
|
|
c896fb |
static int
|
|
|
c896fb |
-cancel_remove_partmap (char *name, void *unused)
|
|
|
c896fb |
+cancel_remove_partmap (const char *name, void *unused)
|
|
|
c896fb |
{
|
|
|
c896fb |
if (dm_get_opencount(name))
|
|
|
c896fb |
dm_cancel_remove_partmaps(name);
|
|
|
c896fb |
@@ -1296,13 +1325,13 @@ out:
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
struct rename_data {
|
|
|
c896fb |
- char *old;
|
|
|
c896fb |
+ const char *old;
|
|
|
c896fb |
char *new;
|
|
|
c896fb |
char *delim;
|
|
|
c896fb |
};
|
|
|
c896fb |
|
|
|
c896fb |
static int
|
|
|
c896fb |
-rename_partmap (char *name, void *data)
|
|
|
c896fb |
+rename_partmap (const char *name, void *data)
|
|
|
c896fb |
{
|
|
|
c896fb |
char buff[PARAMS_SIZE];
|
|
|
c896fb |
int offset;
|
|
|
c896fb |
@@ -1319,7 +1348,7 @@ rename_partmap (char *name, void *data)
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
int
|
|
|
c896fb |
-dm_rename_partmaps (char * old, char * new)
|
|
|
c896fb |
+dm_rename_partmaps (const char * old, char * new)
|
|
|
c896fb |
{
|
|
|
c896fb |
struct rename_data rd;
|
|
|
c896fb |
|
|
|
c896fb |
@@ -1333,7 +1362,7 @@ dm_rename_partmaps (char * old, char * n
|
|
|
c896fb |
}
|
|
|
c896fb |
|
|
|
c896fb |
int
|
|
|
c896fb |
-dm_rename (char * old, char * new)
|
|
|
c896fb |
+dm_rename (const char * old, char * new)
|
|
|
c896fb |
{
|
|
|
c896fb |
int r = 0;
|
|
|
c896fb |
struct dm_task *dmt;
|
|
|
c896fb |
Index: multipath-tools-130222/libmultipath/devmapper.h
|
|
|
c896fb |
===================================================================
|
|
|
c896fb |
--- multipath-tools-130222.orig/libmultipath/devmapper.h
|
|
|
c896fb |
+++ multipath-tools-130222/libmultipath/devmapper.h
|
|
|
c896fb |
@@ -47,7 +47,7 @@ int dm_remove_partmaps (const char * map
|
|
|
c896fb |
int deferred_remove);
|
|
|
c896fb |
int dm_get_uuid(char *name, char *uuid);
|
|
|
c896fb |
int dm_get_info (char * mapname, struct dm_info ** dmi);
|
|
|
c896fb |
-int dm_rename (char * old, char * new);
|
|
|
c896fb |
+int dm_rename (const char * old, char * new);
|
|
|
c896fb |
int dm_reassign(const char * mapname);
|
|
|
c896fb |
int dm_reassign_table(const char *name, char *old, char *new);
|
|
|
c896fb |
int dm_setgeometry(struct multipath *mpp);
|