| From: |
| Yang Xiuwei <yangxiuwei-AT-kylinos.cn> |
| To: |
| linux-scsi-AT-vger.kernel.org, linux-block-AT-vger.kernel.org, io-uring-AT-vger.kernel.org |
| Subject: |
| [RFC PATCH v4 0/3] bsg: add io_uring command support for SCSI passthrough |
| Date: |
| Thu, 22 Jan 2026 09:56:50 +0800 |
| Message-ID: |
| <20260122015653.703188-1-yangxiuwei@kylinos.cn> |
| Cc: |
| fujita.tomonori-AT-lab.ntt.co.jp, axboe-AT-kernel.dk, James.Bottomley-AT-HansenPartnership.com, martin.petersen-AT-oracle.com, bvanassche-AT-acm.org, Yang Xiuwei <yangxiuwei-AT-kylinos.cn> |
| Archive-link: |
| Article |
Hi all,
This RFC series adds io_uring command support to the BSG (Block layer
SCSI Generic) driver, enabling asynchronous SCSI passthrough operations
with zero-copy support via fixed buffers.
The implementation follows the io_uring uring_cmd pattern used by other
drivers (e.g., nvme). A new bsg_uring_cmd structure fits within the 80-byte
cmd field of a 128-byte SQE, with 8 bytes reserved for future extensions.
The structure uses protocol-agnostic field names and follows the sg_io_v4
design with separate din_xferp/dout_xferp fields. SCSI status information
is returned in the CQE res2 field using a compact 64-bit encoding.
Currently only BSG_SUB_PROTOCOL_SCSI_CMD is implemented. Scatter/gather
I/O and bidirectional transfers are not yet supported.
The implementation has been tested with a user-space test program covering
basic SCSI commands (INQUIRY, READ CAPACITY, READ, WRITE), zero-copy mode,
and error handling.
The v4 implementation uses a callback function pointer pattern to maintain
independence of the generic BSG layer from specific protocol implementations,
avoiding build-time dependencies on SCSI-specific code.
Previous versions:
- v1: https://lore.kernel.org/all/20260112084606.570887-1-yangx...
- v3: https://lore.kernel.org/r/cover.1768536312.git.yangxiuwei...
Changes since v1:
-----------------
- Protocol-agnostic field names (request/request_len instead of cdb_addr/cdb_len)
- Removed __packed attribute for better code generation
Why v2 was superseded:
----------------------
v2 unified din_xferp/dout_xferp into a single xfer_addr field, which
diverged from the established sg_io_v4 interface. v3 reverts to separate
din_xferp/dout_xferp fields to maintain consistency with the existing
BSG interface.
Changes since v3:
- Fixed undefined symbol error by using callback function pointer pattern
instead of direct function calls
- Removed protocol-specific validation from generic layer (moved to
scsi_bsg_uring_cmd)
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
block/bsg-lib.c | 2 +-
block/bsg.c | 35 ++++++-
drivers/scsi/scsi_bsg.c | 210 ++++++++++++++++++++++++++++++++++++++-
include/linux/bsg.h | 6 +-
include/uapi/linux/bsg.h | 21 ++++
5 files changed, 270 insertions(+), 4 deletions(-)
--
2.25.1