[PATCH 17/19] sg: add multiple request support

2019-05-24 Thread Douglas Gilbert
Before the write() and read() system calls were removed from the bsg driver (around lk 4.15) bsg supported multiple SCSI requests being submitted in a single invocation. It did this by passing an array of struct sg_io_v4 objects to the write() whose third argument (the size the second argument poin

[PATCH 06/19] sg: sense buffer cleanup

2019-05-24 Thread Douglas Gilbert
Only a smaller percentage of SCSI commands should require a sense buffer. Allocate as needed and delete as soon as possible. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 35 ++- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/drivers/scsi

[PATCH 01/19] sg: move functions around

2019-05-24 Thread Douglas Gilbert
Move code around so it has the basic ordering: open(), close(), write(), read(), ioctl(), other system calls (e.g. mmap()), support code and finally debug code. The change was to put the write() associated code before the read() code. The write() system call is associated with submitting SCSI comma

[PATCH 02/19] sg: remove typedefs, type+formatting cleanup

2019-05-24 Thread Douglas Gilbert
Typedefs for structure types are discouraged so those structures that are private to the driver have had their typedefs removed. This also means that most "camel" type variable names (i.e. mixed case) have been removed. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 396

[PATCH 18/19] sg: add slave wait capability

2019-05-24 Thread Douglas Gilbert
In request sharing, the slave side (i.e. the WRITEr) usually needs to wait for the master side to complete before the slave can issue its WRITE (or any other data-out command). This small optimisation allows the slave WRITE to be submitted directly after the master side submits its command (e.g. a

[PATCH 16/19] sg: add shared requests

2019-05-24 Thread Douglas Gilbert
Add request sharing which is invoked on a shared file descriptor by using SGV4_FLAG_SHARE. The file share is asymmetric: the master side is assumed to do data-in command (e.g. READ) first, followed by the slave side doing a data-out command (e.g. WRITE). The master side may also set SG_FLAG_NO_DXFE

[PATCH 07/19] sg: add sg v4 interface support

2019-05-24 Thread Douglas Gilbert
Add support for the sg v4 interface based on struct sg_io_v4 found in include/uapi/linux/bsg.h and only previously supported by the bsg driver. Add ioctl(SG_IOSUBMIT) and ioctl(SG_IORECEIVE) for async (non-blocking) usage of the sg v4 interface. Do not accept the v3 interface with these ioctls. Do

[PATCH 08/19] sg: add 8 byte SCSI LUN to sg_scsi_id

2019-05-24 Thread Douglas Gilbert
The existing ioctl(SG_GET_SCSI_ID) fills a object of type struct sg_scsi_id whose last field is int unused[2]. Add an anonymous union with u8 scsi_lun[8] sharing those last 8 bytes. This patch will place the current device's full LUN in the scsi_lun array using T10's preferred LUN format (i.e. an a

[PATCH 19/19] sg: table of error numbers with meanings

2019-05-24 Thread Douglas Gilbert
Rather than having a piece of paper recording which errno values have been used for what, the author thought why not place then in one table in the driver code. As a guesstimate, over half the code in this driver is dedicated to sanity checking and reporting errors. Those errors may come from the

[PATCH 12/19] sg: add sg_set_get_extended ioctl

2019-05-24 Thread Douglas Gilbert
Add ioctl(SG_SET_GET_EXTENDED) together with its interface: struct sg_extended_info which is 96 bytes long, only half of which is currently used. The "SET_GET" component of the name is to stress data flows towards and back from the ioctl. That ioctl has three sections: one for getting and setting

[PATCH 04/19] sg: move header to uapi section

2019-05-24 Thread Douglas Gilbert
Move user interface part of scsi/sg.h into the new header file: include/uapi/scsi/sg.h . Since scsi/sg.h includes the new header, other code including scsi/sg.h should not be impacted. Signed-off-by: Douglas Gilbert --- include/scsi/sg.h | 268 ++--- include/uapi

[PATCH 13/19] sg: sgat_elem_sz and sum_fd_dlens

2019-05-24 Thread Douglas Gilbert
Wire up some more capabilities of ioctl(SG_SET_GET_EXTENDED). One is the size of each internal scatter gather list element. This defaults to 2^15 and was fixed in previous versions of this driver. If the user provides a value, it must be a power of 2 (bytes) and no less than PAGE_SIZE. sum_fd_dlen

[PATCH 00/19] sg: v4 interface, rq sharing + multiple rqs

2019-05-24 Thread Douglas Gilbert
This patchset extends the SCSI generic (sg) driver found in lk 5.2 . The sg driver has a version number which is visible via an ioctl() and is bumped from 3.5.36 to 4.0.12 by this patchset. The additions and changes are described in some detail on this long webpage: http://sg.danny.cz/sg/sg_v40

[PATCH 15/19] sg: add fd sharing , change, unshare

2019-05-24 Thread Douglas Gilbert
Add the ability establish a share between any two open file descriptors in the sg driver. Neither file descriptor can already be part of a share. This fd share is used for two features added and described in later patches: request sharing and the "do_on_other" flag used when multiple requests are i

[PATCH 14/19] sg: tag and more_async

2019-05-24 Thread Douglas Gilbert
Wire up some more capabilities of ioctl(SG_SET_GET_EXTENDED). One is to use a LLD or block layer generated tag rather than the user provided pack_id to track requests. Tags to the user space for an async interface may be considered as work in progress as there doesn't seem to be a safe mechanism to

[PATCH 09/19] sg: expand sg_comm_wr_t

2019-05-24 Thread Douglas Gilbert
The internal struct sg_comm_wr_t was added when the number of arguments to sg_common_write() became excessive. Expand this idea so multiple calls to sg_fetch_cmnd() can be deferred until a scsi_request object is ready to receive the command. This saves a 252 byte stack allocation on every submit pa

[PATCH 03/19] sg: sg_log and is_enabled

2019-05-24 Thread Douglas Gilbert
Replace SCSI_LOG_TIMEOUT macros with SG_LOG macros across the driver. The definition of SG_LOG calls SCSI_LOG_TIMEOUT if scsi_device pointer is non-zero, calls pr_info otherwise. Prints the thread id if current is non-zero, -1 otherwise. Also replace #if and #ifdef conditional compilations with th

[PATCH 11/19] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls

2019-05-24 Thread Douglas Gilbert
Add ioctl(SG_IOSUBMIT_V3) and ioctl(SG_IORECEIVE_V3). These ioctls are meant to be (almost) drop-in replacements for the write()/read() async version 3 interface. They only accept the version 3 interface. See the webpage at: http://sg.danny.cz/sg/sg_v40.html specifically the table in the section t

[PATCH 10/19] sg: add sg_ioabort ioctl

2019-05-24 Thread Douglas Gilbert
Add ioctl(SG_IOABORT) that acts as a front-end to blk_abort_request() which is only called if the request is "inflight". The request to abort is matched via its pack_id and the scope of the search is the current device. That scope will be fine tuned in a later patch to being either all file descri

[PATCH 05/19] sg: replace rq array with lists

2019-05-24 Thread Douglas Gilbert
Remove the fixed size array of 16 request elements per file descriptor and replace with two linked lists (per fd). One list is for active commands, the other list is a free list. sg_request objects are now kept, available for re-use, until their owning file descriptor is closed. The associated bloc

Re: [PATCH 19/21] lpfc: Fix BFS crash with t10-dif enabled.

2019-05-24 Thread Ewan D. Milne
On Tue, 2019-05-21 at 17:49 -0700, James Smart wrote: > Crashes in scsi_queue_rq or in dma_unmap_direct_sg during BFS when > lpfc has lpfc_enable_bg=1. > > lpfc is setting the t10-dif and prot sg after scsi_add_host_with_dma() > has been called. The scsi_host_set_prot() and scsi_host_set_guard() >