From 6baa067271165004ba1c9503079e1a30377256d0 Mon Sep 17 00:00:00 2001 From: Steven Seungcheol Lee Date: Fri, 26 Jun 2020 19:09:51 +0900 Subject: [PATCH] zns: nsid is used for zone-mgmt-send exception handling Signed-off-by: Steven Seungcheol Lee --- plugins/zns/zns.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index c75b7c5..73e37a8 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -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); -- 2.50.1