Skip to content

engines/nvme: fix addr/data_len for no data nvme commands - #2101

Merged
axboe merged 1 commit into
axboe:masterfrom
swarnagh6:fio_5_27
Jun 1, 2026
Merged

axboe merged 1 commit into
axboe:masterfrom
swarnagh6:fio_5_27

Conversation

@swarnagh6

Copy link
Copy Markdown

assign 'cmd->data_len' to xfer_buflen and 'cmd->addr' to xfer_buf for data transfer commands - read, write and compare opcode. Previously, write zeroes had 'cmd->data_len' assigned to xfer_buflen while the address was set to NULL causing bad address error. Any unrecognised opcode returns -ENOTSUP. This ensures no data transfer opcode - write zeroes, uncor and verify have addr and data_len set to 0.

Fixes: #2089 (review)

Copilot AI review requested due to automatic review settings May 30, 2026 01:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates fio_nvme_uring_cmd_prep() buffer handling to only attach user buffers to true data-transfer NVMe opcodes, and rejects unsupported commands early.

Changes:

  • Restricts cmd->addr/cmd->data_len population to read/write/compare.
  • Returns -ENOTSUP for opcodes not explicitly supported by this path.
  • Treats write-zeroes/write-uncorrectable/verify as “allowed but non-data” commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread engines/nvme.c
Comment on lines +393 to +402
/* use buffer only for data transfer commands */
if (cmd->opcode == nvme_cmd_read ||
cmd->opcode == nvme_cmd_write ||
cmd->opcode == nvme_cmd_compare) {
cmd->addr = (__u64)(uintptr_t)io_u->xfer_buf;
else
cmd->addr = (__u64)(uintptr_t)NULL;
cmd->data_len = io_u->xfer_buflen;
cmd->data_len = io_u->xfer_buflen;
} else if (cmd->opcode != nvme_cmd_write_zeroes &&
cmd->opcode != nvme_cmd_write_uncor &&
cmd->opcode != nvme_cmd_verify)
return -ENOTSUP;
Comment thread engines/nvme.c Outdated
Comment on lines +394 to +402
if (cmd->opcode == nvme_cmd_read ||
cmd->opcode == nvme_cmd_write ||
cmd->opcode == nvme_cmd_compare) {
cmd->addr = (__u64)(uintptr_t)io_u->xfer_buf;
else
cmd->addr = (__u64)(uintptr_t)NULL;
cmd->data_len = io_u->xfer_buflen;
cmd->data_len = io_u->xfer_buflen;
} else if (cmd->opcode != nvme_cmd_write_zeroes &&
cmd->opcode != nvme_cmd_write_uncor &&
cmd->opcode != nvme_cmd_verify)
return -ENOTSUP;
@vincentkfu

Copy link
Copy Markdown
Collaborator

Please use a switch command for this code. I think switch would make the intent of this code even clearer. Just break for the no data transfer opcodes and add a comment that the buffer address and length are already zero.

assign 'cmd->data_len' to xfer_buflen and 'cmd->addr' to xfer_buf
for data transfer commands - read, write and compare opcode.
Previously, write zeroes had 'cmd->data_len' assigned to xfer_buflen
while the address was set to NULL causing bad address error.
Any unrecognised opcode returns -ENOTSUP. This ensures no data
transfer opcode - write zeroes, uncor and verify have addr and
data_len set to 0.

Signed-off-by: Swarna Prabhu <s.prabhu@samsung.com>
@axboe
axboe merged commit a2d8ee2 into axboe:master Jun 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ 换网址