Skip to content

Commit 387688b

Browse files
committed
libnvme/ioctl: introduce ioctl_io64 nvme transport direct handle
Since currently only NVME_IOCTL_ADMIN64_CMD checked for ioctrl64. But NVME_IOCTL_IO64_CMD not checked as same. Also currently NVME_IOCTL_IO64_CMD not supported for the char dev. Therefore introduce the ioctl_io64 flag to use NVME_IOCTL_IO64_CMD. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 9e36c66 commit 387688b

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

libnvme/src/nvme/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
178178
int nvme_submit_io_passthru(struct nvme_transport_handle *hdl,
179179
struct nvme_passthru_cmd *cmd)
180180
{
181-
if (hdl->ioctl64)
181+
if (hdl->ioctl_io64)
182182
return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd);
183183
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd);
184184
}

libnvme/src/nvme/lib.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ static int __nvme_transport_handle_open_direct(
160160

161161
if (hdl->ctx->ioctl_probing) {
162162
ret = ioctl(hdl->fd, NVME_IOCTL_ADMIN64_CMD, &dummy);
163-
if (ret > 0)
163+
if (ret > 0) {
164164
hdl->ioctl64 = true;
165+
ret = ioctl(hdl->fd, NVME_IOCTL_IO64_CMD, &dummy);
166+
if (ret != -1 || errno != ENOTTY)
167+
hdl->ioctl_io64 = true;
168+
}
165169
}
166170

167171
return 0;

libnvme/src/nvme/private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct nvme_transport_handle {
114114
int fd;
115115
struct stat stat;
116116
bool ioctl64;
117+
bool ioctl_io64;
117118

118119
/* mi */
119120
struct nvme_mi_ep *ep;

0 commit comments

Comments
 (0)