[PATCH v2 05/18] sg: bitops in sg_device

2019-07-26 Thread Douglas Gilbert
Introduce bitops in sg_device to replace an atomic, a bool and a char. That char (sgdebug) had been reduced to only two states. Add some associated macros to make the code a little clearer. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 104 +++---

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

2019-07-26 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 | 394

[PATCH v2 04/18] sg: rework sg_poll(), minor changes

2019-07-26 Thread Douglas Gilbert
Re-arrange code in sg_poll(). Rename sg_read_oxfer() to sg_rd_append(). In sg_start_req() rename rw to r0w. Plus associated changes demanded by checkpatch.pl Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 65 ++- 1 file changed, 30 insertions(+

[PATCH v2 12/18] sg: sense buffer rework

2019-07-26 Thread Douglas Gilbert
The biggest single item in the sg_request object is the sense buffer array which is SCSI_SENSE_BUFFERSIZE bytes long. That constant started out at 18 bytes 20 years ago and is 96 bytes now and might grow in the future. On the other hand the sense buffer is only used by a small number of SCSI comman

[PATCH v2 14/18] sg: rework debug info

2019-07-26 Thread Douglas Gilbert
Since the version 2 driver, the state of the driver can be found with 'cat /proc/scsi/sg/debug'. As the driver becomes more threaded and IO faster (e.g. scsi_debug with a command timer of 5 microseconds), the existing state dump can become misleading as the state can change during the "snapshot". T

[PATCH v2 17/18] sg: add sg_iosubmit_v3 and sg_ioreceive_v3 ioctls

2019-07-26 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 v2 18/18] sg: bump version to 4.0.03

2019-07-26 Thread Douglas Gilbert
Now that the sg version 4 interface is supported: - with ioctl(SG_IO) for synchronous/blocking use - with ioctl(SG_IOSUBMIT) and ioctl(SG_IORECEIVE) for async/non-blocking use Plus new ioctl(SG_IOSUBMIT_V3) and ioctl(SG_IORECEIVE_V3) potentially replace write() and read() for the sg version

[PATCH v2 06/18] sg: make open count an atomic

2019-07-26 Thread Douglas Gilbert
Convert sg_device::open_cnt into an atomic. Also rename sg_tablesize into the more descriptive max_sgat_elems. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 39 --- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/sg.c b/dr

[PATCH v2 13/18] sg: add sg v4 interface support

2019-07-26 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 v2 15/18] sg: add 8 byte SCSI LUN to sg_scsi_id

2019-07-26 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 v2 10/18] sg: remove most access_ok functions

2019-07-26 Thread Douglas Gilbert
Since access_ok() has lost it direction (3rd) parameter there seems to be no benefit in calling access_ok() before __copy_{to|from}_user(). Simplify code by using the variant of these functions that do not start with "__". Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 50 +++

[PATCH v2 08/18] sg: speed sg_poll and sg_get_num_waiting

2019-07-26 Thread Douglas Gilbert
Track the number of submitted and waiting (for read/receive) requests on each file descriptor with two atomic integers. This speeds sg_poll() and ioctl(SG_GET_NUM_WAITING) which are oft used with the asynchronous (non-blocking) interfaces. Signed-off-by: Douglas Gilbert --- drivers/scsi/sg.c | 5

[PATCH v2 09/18] sg: sg_allow_if_err_recovery and renames

2019-07-26 Thread Douglas Gilbert
Add sg_allow_if_err_recover() to do checks common to several entry points. Replace retval with either res or ret. Rename sg_finish_rem_req() to sg_finish_scsi_blk_rq(). Rename sg_new_write() to sg_submit(). Other cleanups triggered by checkpatch.pl . Signed-off-by: Douglas Gilbert --- drivers/sc

[PATCH v2 00/18] sg: add v4 interface

2019-07-26 Thread Douglas Gilbert
This patchset extends the SCSI generic (sg) driver found in lk 5.3 . The sg driver has a version number which is visible via ioctl(SG_GET_VERSION_NUM) and is bumped from 3.5.36 to 4.0.03 by this patchset. The additions and changes are described in some detail in this long webpage: http://sg.dan

[PATCH v2 01/18] sg: move functions around

2019-07-26 Thread Douglas Gilbert
Move main entry point functions around so submission code comes before completion code. Prior to this, the driver used the traditional open(), close(), read(), write(), ioctl() ordering however in this case that places completion code (i.e. sg_read()) before submission code (i.e. sg_write()). The m

[PATCH v2 07/18] sg: move header to uapi section

2019-07-26 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 v2 03/18] sg: sg_log and is_enabled

2019-07-26 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 given and derived pointers are non-zero, calls pr_info otherwise. SG_LOGS additionally prints the sg device name and the thread id. The thread id is very useful, even in single t

[PATCH v2 11/18] sg: replace rq array with lists

2019-07-26 Thread Douglas Gilbert
Remove the fixed size array of 16 request elements per file descriptor and replace with two linked lists per file descriptor. 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 sg_r

[PATCH v2 16/18] sg: expand sg_comm_wr_t

2019-07-26 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

Re: [scsi] ae86a1c553: BUG:kernel_NULL_pointer_dereference,address

2019-07-26 Thread Ming Lei
Hi, Thanks for your report! On Thu, Jul 25, 2019 at 06:46:29PM +0800, kernel test robot wrote: > FYI, we noticed the following commit (built with gcc-7): > > commit: ae86a1c5530b52dc44a280e78feb0c4eb2dd8595 ("[PATCH V2 2/2] scsi: > implement .cleanup_rq callback") > url: > https://github.com/0

Re: [PATCH V2 0/2] block/scsi/dm-rq: fix leak of request private data in dm-mpath

2019-07-26 Thread Ming Lei
On Fri, Jul 26, 2019 at 06:20:46PM +0200, Benjamin Block wrote: > Hey Ming Lei, > > On Sat, Jul 20, 2019 at 11:06:35AM +0800, Ming Lei wrote: > > Hi, > > > > When one request is dispatched to LLD via dm-rq, if the result is > > BLK_STS_*RESOURCE, dm-rq will free the request. However, LLD may allo

Zdravstvujte! Vas interesuyut klientskie bazy dannyh?

2019-07-26 Thread linux-scsi
Zdravstvujte! Vas interesuyut klientskie bazy dannyh?

Re: [PATCH 03/15] qla2xxx: Fix abort timeout race condition.

2019-07-26 Thread Bart Van Assche
On 7/26/19 9:07 AM, Himanshu Madhani wrote: static void qla24xx_abort_sp_done(void *ptr, int res) @@ -109,7 +122,8 @@ static void qla24xx_abort_sp_done(void *ptr, int res) srb_t *sp = ptr; struct srb_iocb *abt = &sp->u.iocb_cmd; - if (del_timer(&sp->u.iocb_cmd.timer)) { +

Re: [PATCH 3/4] Complain if scsi_target_block() fails

2019-07-26 Thread Bart Van Assche
On 7/26/19 11:03 AM, James Bottomley wrote: I don't disagree, but nothing in this patch set actually uses it ... is there a plan for something to use the scsi_target_block return value to perform some action other than issue a warning? If not, it likely makes better sense simply to add the warn

Re: [PATCH 3/4] Complain if scsi_target_block() fails

2019-07-26 Thread James Bottomley
On Fri, 2019-07-26 at 11:00 -0700, Bart Van Assche wrote: > On 7/26/19 10:00 AM, James Bottomley wrote: > > On Fri, 2019-07-26 at 09:48 -0700, Bart Van Assche wrote: > > > If scsi_target_block() fails that can break the code that calls > > > this > > > function. Hence complain loudly if scsi_target

Re: [PATCH 3/4] Complain if scsi_target_block() fails

2019-07-26 Thread Bart Van Assche
On 7/26/19 10:00 AM, James Bottomley wrote: On Fri, 2019-07-26 at 09:48 -0700, Bart Van Assche wrote: If scsi_target_block() fails that can break the code that calls this function. Hence complain loudly if scsi_target_block() fails. Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thums

Re: [PATCH 3/4] Complain if scsi_target_block() fails

2019-07-26 Thread James Bottomley
On Fri, 2019-07-26 at 09:48 -0700, Bart Van Assche wrote: > If scsi_target_block() fails that can break the code that calls this > function. Hence complain loudly if scsi_target_block() fails. > > Cc: Christoph Hellwig > Cc: Hannes Reinecke > Cc: Johannes Thumshirn > Cc: Ming Lei > Signed-off-

[PATCH 0/4] SCSI core patches for kernel v5.4

2019-07-26 Thread Bart Van Assche
Hi Martin, The patches in this series improve the robustness of SCSI device blocking and unblocking and fix a boot failure. Please consider these patches for kernel version v5.4. Thanks, Bart. Bart Van Assche (4): Make scsi_internal_device_unblock_nowait() reject invalid new_state values

[PATCH 2/4] Change the return type of scsi_target_block() from 'void' into 'int'

2019-07-26 Thread Bart Van Assche
Since scsi_target_block() can fail, return a value that indicates whether or not this function succeeded. Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Ming Lei Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_lib.c| 24 +--- include/scsi/sc

[PATCH 1/4] Make scsi_internal_device_unblock_nowait() reject invalid new_state values

2019-07-26 Thread Bart Van Assche
The only 'new_state' values passed by upstream kernel code to scsi_internal_device_unblock_nowait() are SDEV_RUNNING and SDEV_TRANSPORT_OFFLINE. These are the only values that should be passed to this function. Hence Check the value of the 'new_state' argument to avoid that scsi_internal_device_unb

[PATCH 4/4] Reduce memory required for SCSI logging

2019-07-26 Thread Bart Van Assche
The data structure used for log messages is so large that it can cause a boot failure. Since allocations from that data structure can fail anyway, use kmalloc() / kfree() instead of that data structure. See also https://bugzilla.kernel.org/show_bug.cgi?id=204119. See also commit ded85c193a39 ("scs

[PATCH 3/4] Complain if scsi_target_block() fails

2019-07-26 Thread Bart Van Assche
If scsi_target_block() fails that can break the code that calls this function. Hence complain loudly if scsi_target_block() fails. Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Ming Lei Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_lib.c | 2 ++ 1 file changed,

Attn Dear Atm Card beneficiary. GOOD NEWS,Shipment number: 4Z69536197319960 Content Packages: ATM Visa Card, amount of $18.5Million

2019-07-26 Thread DR, MOHAMMED BUHARI, PRESIDENT OF NIGERIA
Attn Dear Atm Card beneficiary. GOOD NEWS, This is to inform you that i have paid the delivery fees for your ATM Master Card I paid it because our bank director stated that before, they So contact Dr. William Roberts, Director DHL Courier Company Benin to receive your delivery ATM Visa Card amount

Re: [PATCH V2 0/2] block/scsi/dm-rq: fix leak of request private data in dm-mpath

2019-07-26 Thread Benjamin Block
Hey Ming Lei, On Sat, Jul 20, 2019 at 11:06:35AM +0800, Ming Lei wrote: > Hi, > > When one request is dispatched to LLD via dm-rq, if the result is > BLK_STS_*RESOURCE, dm-rq will free the request. However, LLD may allocate > private data for this request, so this way will cause memory leak. I a

[PATCH 15/15] qla2xxx: Update driver version to 10.01.00.18-k

2019-07-26 Thread Himanshu Madhani
Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h index cd6bdf71e533..0833546a1b43 100644 --- a/drivers/scsi/qla2xxx/qla_version.h +++

[PATCH 13/15] qla2xxx: Fix hang in fcport delete path

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran A hange was observed in the fcport delete path when the device was responding slow and a issue-lip path (results in session termination) was taken. Fix this by issuing logo requests unconditionally. PID: 19491 TASK: 8e23e67bb150 CPU: 0 COMMAND: "kworker/0:0" #0 [8e

[PATCH 14/15] qla2xxx: Allow NVME IO to resume with short cable pull

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran Current driver report dev_loss_tmo to 0 for NVME devices with short cable pull. This causes NVME controller to be freed along with NVME namespace. The side affect is IO would stop. By not setting dev_loss_tmo to 0, NVME namespace would stay until cable is plug back in. This al

[PATCH 12/15] qla2xxx: Use common update-firmware-options routine for ISP27xx+

2019-07-26 Thread Himanshu Madhani
From: Andrew Vasquez Leverage the generic routine, qla24xx_update_fw_options(), for the configuration of firmware options for ISP27xx/ISP28xx. Signed-off-by: Andrew Vasquez Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

[PATCH 04/15] qla2xxx: Use Correct index for Q-Pair array

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran For target mode, the default number of Q-Pairs allowed to use is 2. If the number of Q-Pair allocated is lower than the default Q-Pairs, then lower value should be the set as default. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_targe

[PATCH 05/15] qla2xxx: Skip FW dump on LOOP initialization error

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran Firmware dump captured during LOOP Init error does not yield any significant information. This patch removes call to trigger firmware dump collection during Loop Initialization. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_isr.c | 1

[PATCH 06/15] qla2xxx: Reject EH_{abort|device_reset|target_request}

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran Reject eh_{abort|device_reset|target_reset}, when rport is being torn down or chip is down. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_os.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_os.c b

[PATCH 11/15] qla2xxx: Fix failed NVME port discovery after a short device port loss

2019-07-26 Thread Himanshu Madhani
From: Arun Easi The following sequence of event leads to NVME port disappearing: - device port shut - nvme_fc_unregister_remoteport - device port online - remote port delete completes - relogin is scheduled - "post gidpn" message appears due to rscn generation # mismatch

[PATCH 09/15] qla2xxx: Retry fabric Scan on IOCB queue full

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran when fabric scan thread encounters IOCB Q Full, schedule a delayed work to retry fabric scan. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gs.c | 28 ++-- 1 file changed, 22 insertions(+), 6 deletions(-) diff

[PATCH 08/15] qla2xxx: Fix premature timer expiration

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran For any qla2xxx async command, the SRB buffer is used to send it. In setting up the SRB buffer, the timer for this command is started before all memory allocation has finished. Under low memory pressure, memory alloc can go to sleep and not wake up before the timer expires. Once

[PATCH 10/15] qla2xxx: Correct error handling during initialization failures

2019-07-26 Thread Himanshu Madhani
From: Andrew Vasquez Current code misses or fails to account for proper recovery during early initialization failures: - Properly unwind allocations during probe() failures. - Protect against non-initialization memory allocations during unwinding. - Propagate error status during HW initializat

[PATCH 07/15] qla2xxx: Fix Relogin to prevent modifying scan_state flag

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran Relogin fail to move forward due scan_state flag indicate device is not there. Before relogin process, Session delete process accidently modified the scan_state flag. Fixes: 79140e2f4fa7 ("scsi: qla2xxx: Fix login state machine freeze") Cc: sta...@vger.kernel.org Signed-off-by:

[PATCH 03/15] qla2xxx: Fix abort timeout race condition.

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran If an abort times out, the Abort IOCB completion and Abort timer can race against each other. This patch provides unique error code for timer path to allow proper cleanup Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 1 + dri

[PATCH 02/15] qla2xxx: Fix different size DMA Alloc/Unmap

2019-07-26 Thread Himanshu Madhani
From: Quinn Tran [ 17.177276] qla2xxx :05:00.0: DMA-API: device driver frees DMA memory with different size [device address=0x0006198b] [map size=32784 bytes] [unmap size=8208 bytes] [ 17.177390] RIP: 0010:check_unmap+0x7a2/0x1750 [ 17.177425] Call Trace: [ 17.177438]

[PATCH 01/15] qla2xxx: Fix DMA unmap leak

2019-07-26 Thread Himanshu Madhani
With debug kernel we see following wanings indicating memory leak. [28809.523959] WARNING: CPU: 3 PID: 6790 at lib/dma-debug.c:978 dma_debug_device_change+0x166/0x1d0 [28809.523964] pci :0c:00.6: DMA-API: device driver has pending DMA allocations while released from device [count=5] [28809.523

[PATCH 00/15] qla2xxx: Bug fixes for the driver

2019-07-26 Thread Himanshu Madhani
Hi Martin, This series contains bug fixes for the driver. Most of the fixes are obvious memory leak and/or error handling fixes. Please apply this series to 5.4/scsi-queue at your earliest convenience. Thanks, Himanshu Andrew Vasquez (2): qla2xxx: Correct error handling during initializati

Re: [PATCH] mpt3sas: Use 63-bit DMA addressing on SAS35 HBA

2019-07-26 Thread Christoph Hellwig
On Fri, Jul 26, 2019 at 06:00:57AM -0400, Suganath Prabu wrote: > Although SAS3 & SAS3.5 IT HBA controllers support > 64-bit DMA addressing, as per hardware design, > DMA address with all 64-bits set (0x-) > results in a firmware fault. Linux will never send a dma address with all

[V1] mpt3sas: Use 63-bit DMA addressing on SAS35 HBA

2019-07-26 Thread Suganath Prabu
Although SAS3 & SAS3.5 IT HBA controllers support 64-bit DMA addressing, as per hardware design, DMA address with all 64-bits set (0x-) results in a firmware fault. Fix: Driver will set 63-bit DMA mask to ensure the above address will not be used. Cc: Signed-off-by: Suganath Prab

Re: [PATCH] mpt3sas: Use 63-bit DMA addressing on SAS35 HBA

2019-07-26 Thread Greg KH
On Fri, Jul 26, 2019 at 06:00:57AM -0400, Suganath Prabu wrote: > Although SAS3 & SAS3.5 IT HBA controllers support > 64-bit DMA addressing, as per hardware design, > DMA address with all 64-bits set (0x-) > results in a firmware fault. > > Fix: > Driver will set 63-bit DMA mask to

[PATCH] mpt3sas: Use 63-bit DMA addressing on SAS35 HBA

2019-07-26 Thread Suganath Prabu
Although SAS3 & SAS3.5 IT HBA controllers support 64-bit DMA addressing, as per hardware design, DMA address with all 64-bits set (0x-) results in a firmware fault. Fix: Driver will set 63-bit DMA mask to ensure the above address will not be used. Signed-off-by: Suganath Prabu --

Re: [PATCH v2] scsi: mpt3sas: clean up a couple sizeof() uses

2019-07-26 Thread Sreekanth Reddy
On Fri, Jul 26, 2019 at 12:22 PM Dan Carpenter wrote: > > There is a copy and paste bug here. It uses EVENT_TRIGGERS size instead > of SCSI_TRIGGERS size but fortunately both size are 84 bytes so it > doesn't affect runtime. > > These days the prefered style is to just say sizeof(object) instead

[PATCH] megaraid_sas: change sdev queue depth max vs optimal

2019-07-26 Thread Chandrakanth Patil
This patch provides the module parameter and sysfs interface to switch between the firmware provided (optimal) queue depth and controller queue depth (can_queue). Although We have sysfs interface per sdev to change the queue depth of individual scsi devices this implementation provides the single