@@ -1163,7 +1163,7 @@ dm_flush_map_nopaths(const char * mapname,
int dm_flush_maps (int retries)
{
- int r = 1;
+ int r = DM_FLUSH_FAIL;
struct dm_task *dmt;
struct dm_names *names;
unsigned next = 0;
@@ -1181,12 +1181,16 @@ int dm_flush_maps (int retries)
if (!(names = dm_task_get_names (dmt)))
goto out;
- r = 0;
+ r = DM_FLUSH_OK;
if (!names->dev)
goto out;
do {
- r |= dm_suspend_and_flush_map(names->name, retries) != DM_FLUSH_OK;
+ int ret;
+ ret = dm_suspend_and_flush_map(names->name, retries);
+ if (ret == DM_FLUSH_FAIL ||
+ (r != DM_FLUSH_FAIL && ret == DM_FLUSH_BUSY))
+ r = ret;
next = names->next;
names = (void *) names + next;
} while (next);
@@ -1082,7 +1082,8 @@ main (int argc, char *argv[])
goto out;
}
else if (cmd == CMD_FLUSH_ALL) {
- r = dm_flush_maps(retries) ? RTVL_FAIL : RTVL_OK;
+ r = (dm_flush_maps(retries) != DM_FLUSH_OK) ?
+ RTVL_FAIL : RTVL_OK;
goto out;
}
while ((r = configure(conf, cmd, dev_type, dev)) == RTVL_RETRY)
@@ -767,18 +767,25 @@ cli_del_maps (void *v, struct strbuf *reply, void *data)
{
struct vectors * vecs = (struct vectors *)data;
struct multipath *mpp;
- int i, ret = 0;
+ int i, ret, r = 0;
condlog(2, "remove maps (operator)");
vector_foreach_slot(vecs->mpvec, mpp, i) {
- if (flush_map(mpp, vecs))
- ret++;
- else
+ ret = flush_map(mpp, vecs);
+ if (ret == DM_FLUSH_OK)
i--;
+ else if (ret == DM_FLUSH_BUSY && r != 1)
+ r = -EBUSY;
+ else
+ r = 1;
}
/* flush any multipath maps that aren't currently known by multipathd */
- ret |= dm_flush_maps(0);
- return ret;
+ ret = dm_flush_maps(0);
+ if (ret == DM_FLUSH_BUSY && r != 1)
+ r = -EBUSY;
+ else if (ret != DM_FLUSH_OK)
+ r = 1;
+ return r;
}
static int