public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] bsg: add io_uring command support for SCSI passthrough
@ 2026-01-12  8:46 Yang Xiuwei
  2026-01-12  8:46 ` [RFC PATCH 1/3] bsg: add bsg_uring_cmd uapi structure Yang Xiuwei
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yang Xiuwei @ 2026-01-12  8:46 UTC (permalink / raw)
  To: linux-scsi, linux-block, io-uring
  Cc: fujita.tomonori, axboe, James.Bottomley, martin.petersen,
	Yang Xiuwei

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-13  1:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12  8:46 [RFC PATCH 0/3] bsg: add io_uring command support for SCSI passthrough Yang Xiuwei
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox