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, bvanassche@acm.org,
Yang Xiuwei <yangxiuwei@kylinos.cn>
Subject: [RFC PATCH v4 0/3] bsg: add io_uring command support for SCSI passthrough
Date: Thu, 22 Jan 2026 09:56:50 +0800 [thread overview]
Message-ID: <20260122015653.703188-1-yangxiuwei@kylinos.cn> (raw)
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-yangxiuwei@kylinos.cn/
- v3: https://lore.kernel.org/r/cover.1768536312.git.yangxiuwei@kylinos.cn
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
next reply other threads:[~2026-01-22 1:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 1:56 Yang Xiuwei [this message]
2026-01-22 1:56 ` [RFC PATCH v4 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
2026-01-22 1:56 ` [RFC PATCH v4 2/3] bsg: add uring_cmd support to BSG generic layer Yang Xiuwei
2026-01-22 1:56 ` [RFC PATCH v4 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=20260122015653.703188-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-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