Skip to content

Commit

Permalink
fabrics: update return values for dim
Browse files Browse the repository at this point in the history
The nvme dim command returns a zero even for failure scenarios
as shown below:

nvme0 DIM register command error. Status:0xffffffff -
Operation not supported

echo $?
0

Fix this by ensuring appropriate values are returned for success
and failure scenarios. And while at it, remove a couple of
superfluous braces too here.

Signed-off-by: Martin George <[email protected]>
  • Loading branch information
martin-gpy authored and igaw committed Nov 22, 2024
1 parent a3d887e commit 98b34e4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ int nvmf_config(const char *desc, int argc, char **argv)
return 0;
}

static void dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name)
static int dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name)
{
static const char * const task[] = {
[NVMF_DIM_TAS_REGISTER] = "register",
Expand All @@ -1451,6 +1451,8 @@ static void dim_operation(nvme_ctrl_t c, enum nvmf_dim_tas tas, const char *name
fprintf(stderr, "%s DIM %s command error. Result:0x%04x, Status:0x%04x - %s\n",
name, t, result, status, nvme_status_to_string(status, false));
}

return nvme_status_to_errno(status, true);
}

int nvmf_dim(const char *desc, int argc, char **argv)
Expand Down Expand Up @@ -1530,9 +1532,8 @@ int nvmf_dim(const char *desc, int argc, char **argv)
nvme_for_each_subsystem(h, s) {
if (strcmp(nvme_subsystem_get_nqn(s), p))
continue;
nvme_subsystem_for_each_ctrl(s, c) {
dim_operation(c, tas, p);
}
nvme_subsystem_for_each_ctrl(s, c)
ret = dim_operation(c, tas, p);
}
}
}
Expand All @@ -1551,9 +1552,9 @@ int nvmf_dim(const char *desc, int argc, char **argv)
p, nvme_strerror(errno));
return -errno;
}
dim_operation(c, tas, p);
ret = dim_operation(c, tas, p);
}
}

return 0;
return ret;
}

0 comments on commit 98b34e4

Please sign in to comment.