From: Yang Xiuwei <yangxiuwei@kylinos.cn>
To: fujita.tomonori@lab.ntt.co.jp, axboe@kernel.dk,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com
Cc: bvanassche@acm.org, linux-scsi@vger.kernel.org,
linux-block@vger.kernel.org, io-uring@vger.kernel.org,
linux-kernel@vger.kernel.org, Yang Xiuwei <yangxiuwei@kylinos.cn>
Subject: [PATCH v6 0/3] bsg: add io_uring command support for SCSI passthrough
Date: Thu, 5 Mar 2026 09:28:54 +0800 [thread overview]
Message-ID: <20260305012857.2136525-1-yangxiuwei@kylinos.cn> (raw)
In-Reply-To: <20260304080313.675768-1-yangxiuwei@kylinos.cn>
This series adds io_uring command support to the BSG SCSI passthrough
path.
The goal is to allow userspace to submit SCSI passthrough commands via
IORING_OP_URING_CMD, in addition to the existing sg_io interface.
The io_uring path mirrors the existing BSG behaviour: it currently only
supports BSG_PROTOCOL_SCSI + BSG_SUB_PROTOCOL_SCSI_CMD and does not
support BIDI transfers.
Patch 1 defines struct bsg_uring_cmd in the UAPI so that userspace can
describe SCSI passthrough requests for io_uring.
Patch 2 extends the generic BSG layer with an .uring_cmd file operation
and a bsg_uring_cmd_fn callback, allowing transport-specific handlers to
be registered.
Patch 3 implements the SCSI BSG io_uring handler. It builds a SCSI
request from struct bsg_uring_cmd, maps user buffers (including fixed
buffers), and completes asynchronously via a request end_io callback and
task_work. Completion returns SCSI device/host/driver status, residual
length and sense data length packed into the CQE result.
Changes since v5:
- Fixed compilation errors:
* Use io_uring_sqe128_cmd() instead of io_uring_sqe_cmd()
* Update scsi_bsg_uring_cmd_done() signature to match rq_end_io_fn typedef
Compared to the earlier RFC v4 series [1], this version only includes
minor code cleanups (mainly comments and wording), without changing the
behaviour or logic of the implementation.
[1] https://lore.kernel.org/linux-block/20260122015653.703188-1-yangxiuwei@kylinos.cn/
Testing
-------
Testing was done inside a VM on a disk with:
/sys/block/sdd/mq/0/nr_tags = 1024
/sys/block/sdd/queue/nr_requests = 256
The following SCSI INQUIRY micro-benchmark was run with N=100000:
sg+SG_IO (v3), /dev/sg4:
avg = 139.0 us, p50 = 128.9 us, p90 = 149.7 us, p99 = 301.0 us
bsg+SG_IO (v4), /dev/bsg/2:0:0:0:
avg = 97.2 us, p50 = 92.7 us, p90 = 111.5 us, p99 = 150.9 us
bsg+io_uring, /dev/bsg/2:0:0:0:
avg = 105.9 us, p50 = 95.4 us, p90 = 116.2 us, p99 = 175.0 us
bsg+io_uring (batch=64), /dev/bsg/2:0:0:0:
avg = 61.9 us, p50 = 60.9 us, p90 = 63.9 us, p99 = 94.6 us
These results show that the new io_uring path is comparable to the
existing BSG SG_IO interface for single-command workloads, and that
batched io_uring submission can significantly improve latency for
high-concurrency workloads when the device supports sufficient queue
depth.
Yang Xiuwei (3):
bsg: add bsg_uring_cmd uapi structure
bsg: add io_uring command support to generic layer
scsi: bsg: add io_uring passthrough handler
block/bsg-lib.c | 2 +-
block/bsg.c | 32 +++++-
drivers/scsi/scsi_bsg.c | 207 ++++++++++++++++++++++++++++++++++++++-
include/linux/bsg.h | 6 +-
include/uapi/linux/bsg.h | 21 ++++
5 files changed, 264 insertions(+), 4 deletions(-)
base-commit: af4e9ef3d78420feb8fe58cd9a1ab80c501b3c08
--
2.25.1
next prev parent reply other threads:[~2026-03-05 1:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 8:03 [PATCH v5 0/3] bsg: add io_uring command support for SCSI passthrough Yang Xiuwei
2026-03-04 8:03 ` [PATCH v5 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-03-04 8:03 ` [PATCH v5 2/3] bsg: add io_uring command support to generic layer Yang Xiuwei
2026-03-04 8:03 ` [PATCH v5 3/3] scsi: bsg: add io_uring passthrough handler Yang Xiuwei
2026-03-04 13:50 ` kernel test robot
2026-03-05 1:28 ` Yang Xiuwei [this message]
2026-03-05 1:28 ` [PATCH v6 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-03-05 15:14 ` Bart Van Assche
2026-03-06 2:54 ` Yang Xiuwei
2026-03-05 1:28 ` [PATCH v6 2/3] bsg: add io_uring command support to generic layer Yang Xiuwei
2026-03-05 15:17 ` Bart Van Assche
2026-03-06 3:03 ` Yang Xiuwei
2026-03-05 1:28 ` [PATCH v6 3/3] scsi: bsg: add io_uring passthrough handler Yang Xiuwei
2026-03-05 15:39 ` Bart Van Assche
2026-03-06 3:04 ` Yang Xiuwei
2026-03-05 15:12 ` [PATCH v6 0/3] bsg: add io_uring command support for SCSI passthrough Bart Van Assche
2026-03-06 2:46 ` Yang Xiuwei
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=20260305012857.2136525-1-yangxiuwei@kylinos.cn \
--to=yangxiuwei@kylinos.cn \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=io-uring@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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