@@ -788,15 +788,6 @@ fail:
return 1;
}
-/*
- * Return value:
- */
-#define DOMAP_RETRY -1
-#define DOMAP_FAIL 0
-#define DOMAP_OK 1
-#define DOMAP_EXIST 2
-#define DOMAP_DRY 3
-
int domap(struct multipath *mpp, char *params, int is_daemon)
{
int r = DOMAP_FAIL;
@@ -23,6 +23,18 @@ enum actions {
ACT_IMPOSSIBLE,
};
+/*
+ * Return value of domap()
+ * DAEMON_RETRY is only used for ACT_CREATE (see domap()).
+ */
+enum {
+ DOMAP_RETRY = -1,
+ DOMAP_FAIL = 0,
+ DOMAP_OK = 1,
+ DOMAP_EXIST = 2,
+ DOMAP_DRY = 3
+};
+
/*
* Return value of coalesce_paths()
* CP_RETRY is only used in non-daemon case (multipath).
@@ -893,7 +893,7 @@ int resize_map(struct multipath *mpp, unsigned long long size,
}
mpp->action = ACT_RESIZE;
mpp->force_udev_reload = 1;
- if (domap(mpp, params, 1) <= 0) {
+ if (domap(mpp, params, 1) == DOMAP_FAIL) {
condlog(0, "%s: failed to resize map : %s", mpp->alias,
strerror(errno));
mpp->size = orig_size;
@@ -497,7 +497,7 @@ retry:
retries = -1;
goto fail;
}
- if (domap(mpp, params, 1) <= 0 && retries-- > 0) {
+ if (domap(mpp, params, 1) == DOMAP_FAIL && retries-- > 0) {
condlog(0, "%s: map_udate sleep", mpp->alias);
sleep(1);
goto retry;
@@ -995,8 +995,8 @@ rescan:
*/
retry:
ret = domap(mpp, params, 1);
- if (ret <= 0) {
- if (ret < 0 && retries-- > 0) {
+ if (ret == DOMAP_FAIL || ret == DOMAP_RETRY) {
+ if (ret == DOMAP_RETRY && retries-- > 0) {
condlog(0, "%s: retry domap for addition of new "
"path %s", mpp->alias, pp->dev);
sleep(1);
@@ -1152,7 +1152,7 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
* reload the map
*/
mpp->action = ACT_RELOAD;
- if (domap(mpp, params, 1) <= 0) {
+ if (domap(mpp, params, 1) == DOMAP_FAIL) {
condlog(0, "%s: failed in domap for "
"removal of path %s",
mpp->alias, pp->dev);
Use an enum for the already-symbolic return value of domap(), and avoid the use of "<= 0" for the return value, which is against the spirit of symbolic values. A return value less or equal than 0 means DOMAP_FAIL or DOMAP_RETRY. Use the fact that DOMAP_RETRY is only returned in the ACT_CREATE case for simplification of the logic in those cases where ACT_CREATE is not used. Signed-off-by: Martin Wilck <mwilck@suse.com> --- libmultipath/configure.c | 9 --------- libmultipath/configure.h | 12 ++++++++++++ multipathd/cli_handlers.c | 2 +- multipathd/main.c | 8 ++++---- 4 files changed, 17 insertions(+), 14 deletions(-)