From: Yingjie Wang <x-professor@outlook.com>
To: "Martin K . Petersen" <mkp@kernel.org>,
"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
Jens Axboe <axboe@kernel.dk>
Cc: Yingjie Wang <x-professor@outlook.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
Yang Xiuwei <yangxiuwei@kylinos.cn>,
James Houghton <jthoughton@google.com>,
Pavel Begunkov <asml.silence@gmail.com>,
"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [RFC PATCH v3 0/6] scsi: release completed passthrough requests before user copyback
Date: Sat, 7 Nov 2026 09:50:21 +0000 [thread overview]
Message-ID: <cover.1794045010.git.x-professor@outlook.com> (raw)
This rerolls the request-lifetime series after the v2 review:
https://lore.kernel.org/r/cover.1793003363.git.x-professor@outlook.com
The two BSG copyback fixes and James Houghton's cancellation fix that were
prerequisites for the previous draft are now in the SCSI fixes tree as
a52f2ad45726, ffb7b533a479 and 2b2bb55990cf. This series is based on
04feb5fd2c23 from that tree.
The affected passthrough paths can copy data to userspace, or unmap a user
buffer that requires copyback, while still retaining a completed request.
If that access faults and the fault needs I/O from the same queue, the task
can wait for a tag held by the request it would release only after the fault
returns.
Changes since v2:
- 1/6 through 4/6 are unchanged apart from rebasing onto the merged
prerequisites.
- 5/6 adds an io_uring helper that transfers the storage reserved for the
command's copied SQE to the driver after every SQE field has been consumed.
The transfer invalidates ioucmd->sqe, rejects multishot users, and makes a
later -EAGAIN return fail instead of reissuing a command whose SQE storage
has been overwritten. It adds neither an allocation nor object growth.
- 6/6 uses 96 bytes of that storage for the bounded SCSI sense snapshot.
End-I/O saves the result and sense data, queues task work, and returns
RQ_END_IO_FREE for every completion. Task work only uses the saved BIO,
result and sense data; it never accesses the request or scsi_cmnd. A
canceled task-work callback or failed sense copy reports a zero sense
length.
Compared with the v3 plan I posted on October 29, this removes the remaining
sense-bearing case that would have held its tag until task work:
https://lore.kernel.org/r/20261029.scsi-lifetime-v3-plan.7ad5c4111d3b@outlook.com
It also avoids the extra per-command sense allocation discussed during v2
review. I am marking this RFC because the new io_uring helper and its
no-reissue contract need review from the io_uring side.
Validation used the exact tip below:
- Each of the six intermediate commits builds independently with W=1 on
x86-64. The final tree also builds the affected objects on i386 and on
x86-64 with CONFIG_IO_URING disabled and SCSI modular.
- A full x86-64 KASAN and lockdep bzImage builds successfully.
- In QEMU with virtio-scsi disk and CD-ROM devices, 20 regression iterations
passed 960 assertions plus 6 linked-SQE assertions. The linked test wrote
a real 18-byte sense snapshot over the reused SQE storage before completing
the linked command.
- Trace validation passed 100 synchronous and 20 deferred lifecycle windows.
Every deferred window retained zero completed requests before task work.
The run recorded 40 CDDA calls and no BUG, WARNING, KASAN, UBSAN or lockdep
report.
- Four independent exact-image performance runs with successful depth-16
INQUIRY and a 96-byte response buffer measured 12.825 us/request in normal
mode and 13.004 us/request with DEFER_TASKRUN. The existing baseline was
13.726 and 12.559 us/request, while the sent v2 allocation measured 17.647
and 16.665 us/request. These debug-kernel virtual-device numbers show that
the v2 allocation overhead is absent; their run-to-run spread does not
support a general performance claim.
The i386 configuration was build-tested but not booted. CDDA testing covers
the virtual device's expected error path, not audio extraction from real
media. Transport BSG (block/bsg-lib.c) remains outside this series because
it uses a separate queue and needs an independent dependency analysis.
v1: https://lore.kernel.org/r/cover.1792237341.git.x-professor@outlook.com
Review follow-up: https://lore.kernel.org/r/20261022.scsi-copyback-review.31b8d6a70f4c@outlook.com
CDDA reply: https://lore.kernel.org/r/20261022.scsi-cdda-lifetime.8f31a2c97b42@outlook.com
Yingjie Wang (6):
scsi: core: release SG_IO request before user copyback
scsi: core: release legacy ioctl request before user copyback
scsi: sr: release CDDA request before user copyback
scsi: bsg: release synchronous request before user copyback
io_uring/cmd: allow reusing SQE storage for completion data
scsi: bsg: release io_uring requests from end-I/O
drivers/scsi/scsi_bsg.c | 116 +++++++++++++++++++++++------------
drivers/scsi/scsi_ioctl.c | 34 +++++++---
drivers/scsi/sr.c | 3 +
include/linux/io_uring/cmd.h | 24 ++++++++
io_uring/uring_cmd.c | 22 +++++++
5 files changed, 151 insertions(+), 48 deletions(-)
base-commit: 04feb5fd2c23894ebc2cdaf4a4cc38b8667b17ac
--
2.43.0
next reply other threads:[~2026-11-07 9:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 9:50 Yingjie Wang [this message]
2026-11-07 9:50 ` [RFC PATCH v3 1/6] scsi: core: release SG_IO request " Yingjie Wang
2026-11-07 9:50 ` [RFC PATCH v3 2/6] scsi: core: release legacy ioctl " Yingjie Wang
2026-11-07 9:50 ` [RFC PATCH v3 3/6] scsi: sr: release CDDA " Yingjie Wang
2026-11-07 9:50 ` [RFC PATCH v3 4/6] scsi: bsg: release synchronous " Yingjie Wang
2026-11-07 9:50 ` [RFC PATCH v3 5/6] io_uring/cmd: allow reusing SQE storage for completion data Yingjie Wang
2026-11-07 9:50 ` [RFC PATCH v3 6/6] scsi: bsg: release io_uring requests from end-I/O Yingjie Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1794045010.git.x-professor@outlook.com \
--to=x-professor@outlook.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=io-uring@vger.kernel.org \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=yangxiuwei@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®