]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
zns: nsid is used for zone-mgmt-send exception handling
authorSteven Seungcheol Lee <sc108.lee@samsung.com>
Fri, 26 Jun 2020 10:09:51 +0000 (19:09 +0900)
committerKeith Busch <kbusch@kernel.org>
Fri, 26 Jun 2020 15:27:48 +0000 (09:27 -0600)
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
plugins/zns/zns.c

index c75b7c53abcff05859b297fe52acd6ffd19d317c..73e37a8775253fd2b4bdfe2e8f7b79846810828e 100644 (file)
@@ -130,14 +130,6 @@ static int __zns_mgmt_send(int fd, __u32 namespace_id, __u64 zslba,
 {
        int err;
 
-       if (!namespace_id) {
-               err = namespace_id = nvme_get_nsid(fd);
-               if (err < 0) {
-                       perror("get-namespace-id");
-                       goto close_fd;
-               }
-       }
-
        err = nvme_zns_mgmt_send(fd, namespace_id, zslba, select_all, zsa,
                        data_len, buf);
 close_fd:
@@ -178,6 +170,14 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug
        if (fd < 0)
                goto free;
 
+       if (!namespace_id) {
+               err = namespace_id = nvme_get_nsid(fd);
+               if (err < 0) {
+                       perror("get-namespace-id");
+                       goto free;
+               }
+       }
+
        err = __zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba,
                cfg.select_all, zsa, 0, NULL);
        if (!err)
@@ -251,6 +251,14 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu
        if (fd < 0)
                return errno;
 
+       if (!cfg.namespace_id) {
+               err = cfg.namespace_id = nvme_get_nsid(fd);
+               if (err < 0) {
+                       perror("get-namespace-id");
+                       goto close_fd;
+               }
+       }
+
        if (!cfg.zsa) {
                fprintf(stderr, "zone send action must be specified\n");
                err = -EINVAL;
@@ -386,6 +394,14 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug
        if (fd < 0)
                return errno;
 
+       if (!cfg.namespace_id) {
+               err = cfg.namespace_id = nvme_get_nsid(fd);
+               if (err < 0) {
+                       perror("get-namespace-id");
+                       goto close_fd;
+               }
+       }
+
        err = nvme_identify_ns(fd, cfg.namespace_id, false, &id_ns);
        if (err) {
                nvme_show_status(err);