From: Yang Xiuwei <yangxiuwei@kylinos.cn>
To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
io-uring@vger.kernel.org
Cc: fujita.tomonori@lab.ntt.co.jp, axboe@kernel.dk,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, Yang Xiuwei <yangxiuwei@kylinos.cn>
Subject: [RFC PATCH 0/3] bsg: add io_uring command support for SCSI passthrough
Date: Mon, 12 Jan 2026 16:46:03 +0800 [thread overview]
Message-ID: <20260112084606.570887-1-yangxiuwei@kylinos.cn> (raw)
This RFC series adds io_uring command support to the BSG (Block layer
SCSI Generic) driver, enabling asynchronous SCSI passthrough operations
via io_uring.
Motivation:
-----------
The current BSG interface uses ioctl() for SCSI passthrough, which is
synchronous and has limitations for high-performance applications. By
integrating with io_uring, we can provide:
1. Asynchronous I/O support for better scalability
2. Zero-copy I/O via io_uring fixed buffers
3. Better integration with modern async I/O frameworks
4. Reduced system call overhead
Design:
-------
The implementation follows the io_uring uring_cmd pattern used by other
drivers (e.g., nvme, ublk). Key design decisions:
1. UAPI Structure: A new bsg_uring_cmd structure is defined that fits
within the 80-byte cmd field of a 128-byte SQE, with 16 bytes reserved
for future extensions.
2. Status Information: SCSI status (device_status, host_status,
driver_status, sense_len, resid_len) is returned in the CQE res2 field
using a compact 64-bit encoding.
3. Zero-copy Support: The implementation supports both traditional
user buffers and io_uring fixed buffers for zero-copy I/O.
4. Async Completion: Command completion is handled via task work to
safely access user space and copy sense data.
5. Non-blocking I/O: Support for IO_URING_F_NONBLOCK flag to enable
non-blocking command submission.
Limitations:
-----------
- Scatter/gather I/O (iovec arrays) is not currently supported, but
the data structure includes fields for future implementation.
- Bidirectional transfers are not supported (consistent with existing
BSG behavior).
Testing:
--------
A user-space test program has been developed to validate the
implementation, including:
- Basic SCSI commands (INQUIRY, READ CAPACITY (10), READ (10),
WRITE (10))
- Zero-copy mode using fixed buffers
- Error handling (invalid flags, unsupported features)
The test program is available separately and can be provided upon request.
Patch Series:
-------------
Patch 1/3: Adds the bsg_uring_cmd UAPI structure
Patch 2/3: Adds uring_cmd handler to the generic BSG layer
Patch 3/3: Implements the SCSI-specific uring_cmd handler
Yang Xiuwei (3):
bsg: add bsg_uring_cmd uapi structure
bsg: add uring_cmd support to BSG generic layer
bsg: implement SCSI BSG uring_cmd handler
include/uapi/linux/bsg.h | 23 +++++++++++++++++++++++
block/bsg.c | 21 +++++++++++++++++++++
drivers/scsi/scsi_bsg.c | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/bsg.h | 4 ++++
4 files changed, 241 insertions(+)
--
2.25.1
next reply other threads:[~2026-01-12 8:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 8:46 Yang Xiuwei [this message]
2026-01-12 8:46 ` [RFC PATCH 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-01-12 17:44 ` Bart Van Assche
2026-01-13 1:26 ` Yang Xiuwei
2026-01-12 8:46 ` [RFC PATCH 2/3] bsg: add uring_cmd support to BSG generic layer Yang Xiuwei
2026-01-12 8:46 ` [RFC PATCH 3/3] bsg: implement SCSI BSG uring_cmd handler 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=20260112084606.570887-1-yangxiuwei@kylinos.cn \
--to=yangxiuwei@kylinos.cn \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=io-uring@vger.kernel.org \
--cc=linux-block@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