You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
3.8 KiB

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