Skip to content

Commit b944e3b

Browse files
ikegami-tigaw
authored andcommitted
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]> [wagi: renamed ioctl64 to ioctl_admin64] Signed-off-by: Daniel Wagner <[email protected]>
1 parent 9e36c66 commit b944e3b

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

libnvme/src/nvme/ioctl.c

Lines changed: 2 additions & 2 deletions
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
}
@@ -188,7 +188,7 @@ int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl,
188188
{
189189
switch (hdl->type) {
190190
case NVME_TRANSPORT_HANDLE_TYPE_DIRECT:
191-
if (hdl->ioctl64)
191+
if (hdl->ioctl_admin64)
192192
return nvme_submit_passthru64(hdl,
193193
NVME_IOCTL_ADMIN64_CMD, cmd);
194194
if (cmd->opcode == nvme_admin_fabrics)

libnvme/src/nvme/lib.c

Lines changed: 7 additions & 3 deletions
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)
164-
hdl->ioctl64 = true;
163+
if (ret > 0) {
164+
hdl->ioctl_admin64 = 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;
@@ -211,7 +215,7 @@ int nvme_open(struct nvme_global_ctx *ctx, const char *name,
211215
hdl->fd = 0xFD;
212216

213217
if (!strcmp(name, "NVME_TEST_FD64"))
214-
hdl->ioctl64 = true;
218+
hdl->ioctl_admin64 = true;
215219

216220
*hdlp = hdl;
217221
return 0;

libnvme/src/nvme/private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ struct nvme_transport_handle {
113113
/* direct */
114114
int fd;
115115
struct stat stat;
116-
bool ioctl64;
116+
bool ioctl_admin64;
117+
bool ioctl_io64;
117118

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

0 commit comments

Comments
 (0)