* [PATCH] nvme-cli: allow block device for delete-ns
@ 2018-05-02 4:48 Chaitanya Kulkarni
2018-05-02 11:57 ` Johannes Thumshirn
0 siblings, 1 reply; 3+ messages in thread
From: Chaitanya Kulkarni @ 2018-05-02 4:48 UTC (permalink / raw)
This patch allows block device to be used for the
NVMe delete-ns command while keeping the -n options
as it is.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
nvme.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/nvme.c b/nvme.c
index 4b62daf..f0a1474 100644
--- a/nvme.c
+++ b/nvme.c
@@ -853,6 +853,18 @@ static int list_ns(int argc, char **argv, struct command *cmd, struct plugin *pl
return err;
}
+static int get_nsid(int fd)
+{
+ int nsid = nvme_get_nsid(fd);
+
+ if (nsid <= 0) {
+ fprintf(stderr,
+ "%s: failed to return namespace id\n",
+ devicename);
+ }
+ return nsid;
+}
+
static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
const char *desc = "Delete the given namespace by "\
@@ -881,7 +893,13 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *
if (fd < 0)
return fd;
- if (!cfg.namespace_id) {
+ if (S_ISBLK(nvme_stat.st_mode)) {
+ cfg.namespace_id = get_nsid(fd);
+ if (cfg.namespace_id == 0) {
+ err = EINVAL;
+ goto close_fd;
+ }
+ } else if (!cfg.namespace_id) {
fprintf(stderr, "%s: namespace-id parameter required\n",
cmd->name);
err = EINVAL;
@@ -1526,18 +1544,6 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
return 0;
}
-static int get_nsid(int fd)
-{
- int nsid = nvme_get_nsid(fd);
-
- if (nsid <= 0) {
- fprintf(stderr,
- "%s: failed to return namespace id\n",
- devicename);
- }
- return nsid;
-}
-
int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, void (*vs)(__u8 *vs, struct json_object *root))
{
const char *desc = "Send an Identify Controller command to "\
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] nvme-cli: allow block device for delete-ns
2018-05-02 4:48 [PATCH] nvme-cli: allow block device for delete-ns Chaitanya Kulkarni
@ 2018-05-02 11:57 ` Johannes Thumshirn
2018-05-02 15:27 ` Keith Busch
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2018-05-02 11:57 UTC (permalink / raw)
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
--
Johannes Thumshirn Storage
jthumshirn at suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] nvme-cli: allow block device for delete-ns
2018-05-02 11:57 ` Johannes Thumshirn
@ 2018-05-02 15:27 ` Keith Busch
0 siblings, 0 replies; 3+ messages in thread
From: Keith Busch @ 2018-05-02 15:27 UTC (permalink / raw)
Thanks, applied with a minor fixup to check for nsid <= 0 instead of
just == 0.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-02 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-02 4:48 [PATCH] nvme-cli: allow block device for delete-ns Chaitanya Kulkarni
2018-05-02 11:57 ` Johannes Thumshirn
2018-05-02 15:27 ` Keith Busch
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.