]> www.infradead.org Git - nvme.git/commit
nvme/ioctl: move fixed buffer lookup to nvme_uring_cmd_io()
authorCaleb Sander Mateos <csander@purestorage.com>
Fri, 28 Mar 2025 15:46:47 +0000 (09:46 -0600)
committerKeith Busch <kbusch@kernel.org>
Mon, 31 Mar 2025 15:48:25 +0000 (08:48 -0700)
commit2da7e6be532516d958d353cdf5b8f5d25191ff97
treefe903f61f5e70a6cd893c6cc9ec8a2a111b88f11
parenta4b84793e6ba8b15fd25d39e15b38a31f1638bdb
nvme/ioctl: move fixed buffer lookup to nvme_uring_cmd_io()

nvme_map_user_request() is called from both nvme_submit_user_cmd() and
nvme_uring_cmd_io(). But the ioucmd branch is only applicable to
nvme_uring_cmd_io(). Move it to nvme_uring_cmd_io() and just pass the
resulting iov_iter to nvme_map_user_request().

For NVMe passthru operations with fixed buffers, the fixed buffer lookup
happens in io_uring_cmd_import_fixed(). But nvme_uring_cmd_io() can
return -EAGAIN first from nvme_alloc_user_request() if all tags in the
tag set are in use. This ordering difference is observable when using
UBLK_U_IO_{,UN}REGISTER_IO_BUF SQEs to modify the fixed buffer table. If
the NVMe passthru operation is followed by UBLK_U_IO_UNREGISTER_IO_BUF
to unregister the fixed buffer and the NVMe passthru goes async, the
fixed buffer lookup will fail because it happens after the unregister.

Userspace should not depend on the order in which io_uring issues SQEs
submitted in parallel, but it may try submitting the SQEs together and
fall back on a slow path if the fixed buffer lookup fails. To make the
fast path more likely, do the import before nvme_alloc_user_request().

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/ioctl.c