For anyone thinking of testing this patchset, it also applies clean to
lk 4.19 release.
Doug Gilbert
On 2018-10-26 12:48 p.m., Douglas Gilbert wrote:
The intention is to add two new ioctls as proposed by Linus Torvalds:
SG_IOSUBMIT and SG_IORECEIVE to replace the write()/read() async
interface.
But first, clean up the driver and remove the SG_MAX_QUEUE limit of
no more than 16 queued commands on a file descriptor at a time. A
free list has been added and the de-allocation of sg_request
objects is deferred until the close() of a file. Locking is
extensively reworked, especially at the struct sg_fd and
sg_request level.
A new SG_SET_GET_EXTENDED ioctl has been added. It allows multiple
integer values and booleans to be written to and/or read from the
driver. An example is changing and/or reading the reserved request
data length (there is one of these per fd). An example of a new
feature is changing and/or reading the per-fd upper limit on the
sum of outstanding data buffer sizes (default is 16 MB). An
example of a boolean is a bit to do all following command
timekeeping in nanoseconds rather that the default millseconds.
A later patchset will add implementations for the SG_IOSUBMIT and
SG_IORECEIVE plus handling of the sg v4 interface with the
existing SG_IO ioctl.
This patchset is against Martin Petersen's 4.20/scsi-queue branch.
ToDo:
- work out more modern technique for logging function invocations
info with some error paths.
Changes since v2:
- fix problem with reserve request not being placed on fl
- fix locking problem with sg_reserved_sz()
- fix sum_fd_dlens counting problem
- change new ioctl base numbers back to 0x22
- arrange fl in ascending dlen order apart from dlen=0
entries at tail
- SG_GET_REQUEST_TABLE ioctl first fill from active list
then, if there is room, it fills from the free list
- add SG_SEIRV_DEV_FL_RQS to fetch count of all free list
entries on the device the fd is associated with
Changes since v1:
- remove redundant casts from private_data field
- introduce atomic to address locking problems around
sg_fd::sum_fd_dlens
- replace rq_state defines with an enumeration
- add __must_hold() annotation to sg_fill_request_table()
- fix compile/build problem around the 4th and 5th patches
- add read_value[SG_SEIRV_*] options in SG_SET_GET_EXTENDED
ioctl and increase structure size from 64 to 96 bytes
Douglas Gilbert (8):
sg: types and naming cleanup
sg: introduce sg_log macro
sg: split header, expand and correct descriptions
sg: expand request states
sg: add free list, rework locking
sg: complete locking changes on ioctl+debug
sg: rework ioctl handling
sg: user controls for q_at_head, read_value
drivers/scsi/sg.c | 2621 ++--
include/scsi/sg.h | 268 +---
include/uapi/scsi/sg.h | 414 +++
3 files changed, 2156 insertions(+), 1147 deletions(-)
create mode 100644 include/uapi/scsi/sg.h