@@ -1071,7 +1071,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
char *params = NULL;
if (dm_is_mpath(mapname) != 1)
- return 0; /* nothing to do */
+ return DM_FLUSH_OK; /* nothing to do */
/* if the device currently has no partitions, do not
run kpartx on it if you fail to delete it */
@@ -1081,7 +1081,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
/* 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;
+ return DM_FLUSH_FAIL;
if (need_suspend &&
dm_get_map(mapname, &mapsize, ¶ms) == DMP_OK &&
@@ -1096,11 +1096,11 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
params = NULL;
if (dm_remove_partmaps(mapname, need_sync, deferred_remove))
- return 1;
+ return DM_FLUSH_FAIL;
if (!do_deferred(deferred_remove) && dm_get_opencount(mapname)) {
condlog(2, "%s: map in use", mapname);
- return 1;
+ return DM_FLUSH_FAIL;
}
do {
@@ -1114,14 +1114,14 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
&& dm_map_present(mapname)) {
condlog(4, "multipath map %s remove deferred",
mapname);
- return 2;
+ return DM_FLUSH_DEFERRED;
}
condlog(4, "multipath map %s removed", mapname);
- return 0;
+ return DM_FLUSH_OK;
} else if (dm_is_mpath(mapname) != 1) {
condlog(4, "multipath map %s removed externally",
mapname);
- return 0; /*we raced with someone else removing it */
+ return DM_FLUSH_OK; /* raced. someone else removed it */
} else {
condlog(2, "failed to remove multipath map %s",
mapname);
@@ -1137,7 +1137,7 @@ int _dm_flush_map (const char * mapname, int need_sync, int deferred_remove,
if (queue_if_no_path == 1)
_dm_queue_if_no_path(mapname, 1);
- return 1;
+ return DM_FLUSH_FAIL;
}
#ifdef LIBDM_API_DEFERRED
@@ -1184,7 +1184,7 @@ int dm_flush_maps (int retries)
goto out;
do {
- r |= dm_suspend_and_flush_map(names->name, retries);
+ r |= dm_suspend_and_flush_map(names->name, retries) != DM_FLUSH_OK;
next = names->next;
names = (void *) names + next;
} while (next);
@@ -48,6 +48,13 @@ int dm_get_map(const char *, unsigned long long *, char **);
int dm_get_status(const char *, char **);
int dm_type(const char *, char *);
int dm_is_mpath(const char *);
+
+enum {
+ DM_FLUSH_OK = 0,
+ DM_FLUSH_FAIL,
+ DM_FLUSH_DEFERRED,
+};
+
int _dm_flush_map (const char *, int, int, int, int);
int dm_flush_map_nopaths(const char * mapname, int deferred_remove);
#define dm_flush_map(mapname) _dm_flush_map(mapname, 1, 0, 0, 0)
@@ -1070,7 +1070,7 @@ main (int argc, char *argv[])
r = RTVL_FAIL;
goto out;
}
- r = dm_suspend_and_flush_map(dev, retries) ?
+ r = (dm_suspend_and_flush_map(dev, retries) != DM_FLUSH_OK) ?
RTVL_FAIL : RTVL_OK;
goto out;
}
@@ -598,13 +598,13 @@ flush_map_nopaths(struct multipath *mpp, struct vectors *vecs) {
dm_queue_if_no_path(mpp, 0);
}
r = dm_flush_map_nopaths(mpp->alias, mpp->deferred_remove);
- if (r) {
- if (r == 1)
- condlog(0, "%s: can't flush", mpp->alias);
- else {
+ if (r != DM_FLUSH_OK) {
+ if (r == DM_FLUSH_DEFERRED) {
condlog(2, "%s: devmap deferred remove", mpp->alias);
mpp->deferred_remove = DEFERRED_REMOVE_IN_PROGRESS;
}
+ else
+ condlog(0, "%s: can't flush", mpp->alias);
return false;
}
@@ -746,7 +746,7 @@ coalesce_maps(struct vectors *vecs, vector nmpv)
* remove all current maps not allowed by the
* current configuration
*/
- if (dm_flush_map(ompp->alias)) {
+ if (dm_flush_map(ompp->alias) != DM_FLUSH_OK) {
condlog(0, "%s: unable to flush devmap",
ompp->alias);
/*
@@ -789,7 +789,7 @@ int
flush_map(struct multipath * mpp, struct vectors * vecs)
{
int r = dm_suspend_and_flush_map(mpp->alias, 0);
- if (r) {
+ if (r != DM_FLUSH_OK) {
condlog(0, "%s: can't flush", mpp->alias);
return r;
}