]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Decode an reservation errors code to strings
authorYongseok Oh <yongseok.oh@sk.com>
Wed, 14 Dec 2016 03:05:55 +0000 (12:05 +0900)
committerKeith Busch <keith.busch@intel.com>
Wed, 14 Dec 2016 16:21:26 +0000 (09:21 -0700)
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 <keith.busch@intel.com>
nvme-print.c
nvme.c

index 620b421e8372ac7bc81999c4a3c88636ada6856f..2467d27989e04c9e379fff244644179581c377b9 100644 (file)
@@ -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 42c59c557e119c8af2265a3ebd57e507f0bcec49..ef0959b0467effb65bd1a79ddae8977998b9f903 100644 (file)
--- 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;