]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: Add nvme_ns_mgmt_delete_timeout()
authorTokunori Ikegami <ikegami.t@gmail.com>
Wed, 10 Apr 2024 16:08:26 +0000 (01:08 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 11 Apr 2024 10:01:37 +0000 (12:01 +0200)
The existing nvme_ns_mgmt_delete() does not support the timeout.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
src/nvme/ioctl.h

index 99179080289a128e3ef9742d70900b866f257285..5a1760d9e83554a8423307d251515b75107b02c6 100644 (file)
@@ -3647,9 +3647,11 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns,
 }
 
 /**
- * nvme_ns_mgmt_delete() - Delete a non attached namespace
+ * nvme_ns_mgmt_delete_timeout() - Delete a non attached namespace with timeout
  * @fd:                File descriptor of nvme device
  * @nsid:      Namespace identifier to delete
+ * @timeout:   Override the default timeout to this value in milliseconds;
+ *             set to 0 to use the system default.
  *
  * It is recommended that a namespace being deleted is not attached to any
  * controller. Use the nvme_ns_detach_ctrls() first if the namespace is still
@@ -3658,7 +3660,7 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns,
  * Return: The nvme command status if a response was received (see
  * &enum nvme_status_field) or -1 with errno set otherwise.
  */
-static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
+static inline int nvme_ns_mgmt_delete_timeout(int fd, __u32 nsid, __u32 timeout)
 {
        __u32 result = 0;
        int err;
@@ -3667,7 +3669,7 @@ static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
                .ns = NULL,
                .args_size = sizeof(args),
                .fd = fd,
-               .timeout = 0,
+               .timeout = timeout,
                .nsid = nsid,
                .sel = NVME_NS_MGMT_SEL_DELETE,
                .csi = 0,
@@ -3682,6 +3684,23 @@ static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
        return err;
 }
 
+/**
+ * nvme_ns_mgmt_delete() - Delete a non attached namespace
+ * @fd:                File descriptor of nvme device
+ * @nsid:      Namespace identifier to delete
+ *
+ * It is recommended that a namespace being deleted is not attached to any
+ * controller. Use the nvme_ns_detach_ctrls() first if the namespace is still
+ * attached.
+ *
+ * Return: The nvme command status if a response was received (see
+ * &enum nvme_status_field) or -1 with errno set otherwise.
+ */
+static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
+{
+       return nvme_ns_mgmt_delete_timeout(fd, nsid, 0);
+}
+
 /**
  * nvme_ns_attach() - Attach or detach namespace to controller(s)
  * @args:      &struct nvme_ns_attach_args Argument structure