From: Yongseok Oh Date: Wed, 14 Dec 2016 03:05:55 +0000 (+0900) Subject: Decode an reservation errors code to strings X-Git-Tag: v1.1~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c005f4412c2e2313bcd17515effb01e07b84a50c;p=users%2Fsagi%2Fnvme-cli.git Decode an reservation errors code to strings If reservation conflict happens with reservation related commands (e.g., resv_register, resv_acquire, and resv_release), show the error as a string. [fixed compile error; reword commit message] Signed-off-by: Keith Busch --- diff --git a/nvme-print.c b/nvme-print.c index 620b421e..2467d279 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -914,6 +914,7 @@ char *nvme_status_to_string(__u32 status) case NVME_SC_LBA_RANGE: return "LBA_RANGE"; case NVME_SC_CAP_EXCEEDED: return "CAP_EXCEEDED"; case NVME_SC_NS_NOT_READY: return "NS_NOT_READY"; + case NVME_SC_RESERVATION_CONFLICT: return "RESERVATION_CONFLICT"; case NVME_SC_CQ_INVALID: return "CQ_INVALID"; case NVME_SC_QID_INVALID: return "QID_INVALID"; case NVME_SC_QUEUE_SIZE: return "QUEUE_SIZE"; diff --git a/nvme.c b/nvme.c index 42c59c55..ef0959b0 100644 --- a/nvme.c +++ b/nvme.c @@ -1951,7 +1951,7 @@ static int resv_acquire(int argc, char **argv, struct command *cmd, struct plugi if (err < 0) perror("reservation acquire"); else if (err != 0) - fprintf(stderr, "NVME IO command error:%04x\n", err); + fprintf(stderr, "NVME IO command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("NVME Reservation Acquire success\n"); return err; @@ -2011,7 +2011,7 @@ static int resv_register(int argc, char **argv, struct command *cmd, struct plug if (err < 0) perror("reservation register"); else if (err != 0) - fprintf(stderr, "NVME IO command error:%04x\n", err); + fprintf(stderr, "NVME IO command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("NVME Reservation success\n"); return err; @@ -2077,7 +2077,7 @@ static int resv_release(int argc, char **argv, struct command *cmd, struct plugi if (err < 0) perror("reservation release"); else if (err != 0) - fprintf(stderr, "NVME IO command error:%04x\n", err); + fprintf(stderr, "NVME IO command error:%s(%x)\n", nvme_status_to_string(err), err); else printf("NVME Reservation Release success\n"); return err;