aboutsummaryrefslogtreecommitdiff
path: root/include/scsi
AgeCommit message (Collapse)AuthorFilesLines
2021-03-29scsi: core: scsi_host_cmd_pool is declared twiceWan Jiabing1-1/+0
struct scsi_host_cmd_pool has already been declared. Remove the duplicate. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wan Jiabing <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-03-29scsi: iscsi: Fix race condition between login and sync threadGulam Mohamed1-0/+1
A kernel panic was observed due to a timing issue between the sync thread and the initiator processing a login response from the target. The session reopen can be invoked both from the session sync thread when iscsid restarts and from iscsid through the error handler. Before the initiator receives the response to a login, another reopen request can be sent from the error handler/sync session. When the initial login response is subsequently processed, the connection has been closed and the socket has been released. To fix this a new connection state, ISCSI_CONN_BOUND, is added: - Set the connection state value to ISCSI_CONN_DOWN upon iscsi_if_ep_disconnect() and iscsi_if_stop_conn() - Set the connection state to the newly created value ISCSI_CONN_BOUND after bind connection (transport->bind_conn()) - In iscsi_set_param(), return -ENOTCONN if the connection state is not either ISCSI_CONN_BOUND or ISCSI_CONN_UP Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Gulam Mohamed <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> index 91074fd97f64..f4bf62b007a0 100644
2021-03-24scsi: scsi_dh: Fix a typoBhaskar Chowdhury1-1/+1
s/infrastruture/infrastructure/ [mkp: combined .c and .h patches] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bhaskar Chowdhury <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> frog
2021-03-04scsi: core: Add mq_poll support to SCSI layerKashyap Desai2-0/+12
Currently IOPOLL support is only available in block layer. This patch adds mq_poll support to the SCSI layer. Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Kashyap Desai <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-03-04scsi: core: Replace sdev->device_busy with sbitmapMing Lei1-2/+3
SCSI currently uses an atomic variable to track queue depth for each attached device. The queue depth depends on many factors such as transport type and device implementation. In addition, the SCSI device queue depth is not a static entity but changes over time as a result of congestion management. While blk-mq currently tracks queue depth for each hctx, it can't easily be changed to accommodate the SCSI per-device requirement. The current approach of using an atomic variable doesn't scale well when there are lots of CPU cores and the disk is very fast. IOPS can be substantially impacted by the atomic in the hot path. Replace the atomic variable sdev->device_busy with an sbitmap for tracking the SCSI device queue depth. It has been observed that IOPS is improved ~30% by this patchset in the following test: 1) test machine(32 logical CPU cores) Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 2 NUMA node(s): 2 Model name: Intel(R) Xeon(R) Silver 4110 CPU @ 2.10GHz 2) setup scsi_debug: modprobe scsi_debug virtual_gb=128 max_luns=1 submit_queues=32 delay=0 max_queue=256 3) fio script: fio --rw=randread --size=128G --direct=1 --ioengine=libaio --iodepth=2048 \ --numjobs=32 --bs=4k --group_reporting=1 --group_reporting=1 --runtime=60 \ --loops=10000 --name=job1 --filename=/dev/sdN [mkp: fix device_busy reference in mpt3sas] Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/linux-block/[email protected]/ Cc: Omar Sandoval <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Sumanesh Samanta <[email protected]> Cc: Ewan D. Milne <[email protected]> Cc: Hannes Reinecke <[email protected]> Tested-by: Sumanesh Samanta <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-03-04scsi: core: Add scsi_device_busy() wrapperMing Lei1-0/+5
Add scsi_device_busy() helper to prepare drivers for tracking device queue depth via sbitmap_queue. Link: https://lore.kernel.org/r/[email protected] Cc: Omar Sandoval <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Sumanesh Samanta <[email protected]> Cc: Ewan D. Milne <[email protected]> Tested-by: Sumanesh Samanta <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-03-04scsi: core: Put hot fields of scsi_host_template in one cachelineMing Lei1-33/+39
The following three fields of scsi_host_template are referenced in the SCSI I/O submission hot path. Put them together in one cacheline: - cmd_size - queuecommand - commit_rqs Link: https://lore.kernel.org/r/[email protected] Cc: Omar Sandoval <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Sumanesh Samanta <[email protected]> Cc: Ewan D. Milne <[email protected]> Cc: Hannes Reinecke <[email protected]> Tested-by: Sumanesh Samanta <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-03-04scsi: blk-mq: Add callbacks for storing & retrieving budget tokenMing Lei1-0/+2
Since SCSI is the only driver which requires dispatch budget move the token from struct request to struct scsi_cmnd. Link: https://lore.kernel.org/r/[email protected] Cc: Omar Sandoval <[email protected]> Cc: Kashyap Desai <[email protected]> Cc: Sumanesh Samanta <[email protected]> Cc: Ewan D. Milne <[email protected]> Cc: Hannes Reinecke <[email protected]> Tested-by: Sumanesh Samanta <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-02-08scsi: libiscsi: Add helper to calculate max SCSI cmds per sessionMike Christie1-0/+2
This patch just breaks out the code that calculates the number of SCSI cmds that will be used for a SCSI session. It also adds a check that we don't go over the host's can_queue value. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-02-08scsi: libiscsi: Drop taskqueuelockMike Christie1-2/+2
The purpose of the taskqueuelock was to handle the issue where a bad target decides to send a R2T and before its data has been sent decides to send a cmd response to complete the cmd. The following patches fix up the frwd/back locks so they are taken from the queue/xmit (frwd) and completion (back) paths again. To get there this patch removes the taskqueuelock which for iSCSI xmit wq based drivers was taken in the queue, xmit and completion paths. Instead of the lock, we just make sure we have a ref to the task when we queue a R2T, and then we always remove the task from the requeue list in the xmit path or the forced cleanup paths. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: libsas: Remove temporarily-added _gfp() API variantsAhmed S. Darwish1-4/+0
These variants were added for bisectability. Remove them, as all call sites have now been convertd to use the original API. Link: https://lore.kernel.org/r/[email protected] Cc: Jason Yan <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: libsas: Add gfp_t flags parameter to event notificationsAhmed S. Darwish1-2/+4
All call-sites of below libsas APIs: - sas_alloc_event() - sas_notify_port_event() - sas_notify_phy_event() have been converted to use the _gfp()-suffixed version. Modify the original APIs above to take a gfp_t flags parameter by default. For bisectability, call-sites will be modified again to use the original libsas APIs (while passing gfp_t). The temporary _gfp()-suffixed versions can then be removed. Link: https://lore.kernel.org/r/[email protected] Cc: Jason Yan <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: libsas: Introduce a _gfp() variant of event notifiersAhmed S. Darwish1-0/+4
sas_alloc_event() uses in_interrupt() to decide which allocation should be used. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. The in_interrupt() check is also only partially correct, because it fails to choose the correct code path when just preemption or interrupts are disabled. For example, as in the following call chain: mvsas/mv_sas.c: mvs_work_queue() [process context] spin_lock_irqsave(mvs_info::lock, ) -> libsas/sas_event.c: sas_notify_phy_event() -> sas_alloc_event() -> in_interrupt() = false -> invalid GFP_KERNEL allocation -> libsas/sas_event.c: sas_notify_port_event() -> sas_alloc_event() -> in_interrupt() = false -> invalid GFP_KERNEL allocation Introduce sas_alloc_event_gfp(), sas_notify_port_event_gfp(), and sas_notify_phy_event_gfp(), which all behave like the non _gfp() variants but use a caller-passed GFP mask for allocations. For bisectability, all callers will be modified first to pass GFP context, then the non _gfp() libsas API variants will be modified to take a gfp_t by default. Link: https://lore.kernel.org/r/[email protected] Fixes: 1c393b970e0f ("scsi: libsas: Use dynamic alloced work to avoid sas event lost") Cc: Jason Yan <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: libsas: Remove notifier indirectionJohn Garry1-4/+3
LLDDs report events to libsas with .notify_port_event and .notify_phy_event callbacks. These callbacks are fixed and so there is no reason why the functions cannot be called directly, so do that. This neatens the code slightly, makes it more obvious, and reduces function pointer usage, which is generally a good thing. Downside is that there are 2x more symbol exports. [[email protected]: Remove the now unused "sas_ha" local variables] Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Jack Wang <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: core: Add 'set_status_byte()' accessorHannes Reinecke1-0/+5
Add the missing 'set_status_byte()' accessor function. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Benjamin Block <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-22scsi: aic7xxx: aic79xx: Drop internal SCSI message definitionHannes Reinecke1-0/+1
Use the standard SCSI message definitions instead of the driver-internal ones. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-14scsi: scsi_transport_fc: Add a new rport state FC_PORTSTATE_MARGINALMuneendra Kumar1-1/+3
Add a new interface, fc_eh_should_retry_cmd(), which checks if the cmd should be retried or not by checking the rport state. If the rport state is marginal it returns false to make sure there won't be any retries on the cmd. Make the fc_remote_port_delete(), fc_user_scan_tgt(), and fc_timeout_deleted_rport() functions handle the new rport state. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Reviewed-by: Ewan D. Milne <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Muneendra Kumar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-14scsi: core: No retries on abort successMuneendra Kumar1-0/+6
Add a new optional routine, eh_should_retry_cmd(), in scsi_host_template that allows the transport to decide if a cmd is retryable. Return true if the transport is in a state the cmd should be retried on. Update scmd_eh_abort_handler() and scsi_eh_flush_done_q() to both call scsi_eh_should_retry_cmd() to check whether the command needs to be retried. The above changes were based on a patch by Mike Christie. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Reviewed-by: Ewan D. Milne <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Muneendra Kumar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-01-14scsi: core: Add a new error code DID_TRANSPORT_MARGINAL in scsi.hMuneendra Kumar1-0/+1
Add code in scsi_result_to_blk_status to translate a new error DID_TRANSPORT_MARGINAL to the corresponding blk_status_t i.e BLK_STS_TRANSPORT. Add DID_TRANSPORT_MARGINAL case to scsi_decide_disposition(). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Reviewed-by: Ewan D. Milne <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Muneendra Kumar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-12-16Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds3-727/+66
Pull SCSI updates from James Bottomley: "This consists of the usual driver updates (ufs, qla2xxx, smartpqi, target, zfcp, fnic, mpt3sas, ibmvfc) plus a load of cleanups, a major power management rework and a load of assorted minor updates. There are a few core updates (formatting fixes being the big one) but nothing major this cycle" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (279 commits) scsi: mpt3sas: Update driver version to 36.100.00.00 scsi: mpt3sas: Handle trigger page after firmware update scsi: mpt3sas: Add persistent MPI trigger page scsi: mpt3sas: Add persistent SCSI sense trigger page scsi: mpt3sas: Add persistent Event trigger page scsi: mpt3sas: Add persistent Master trigger page scsi: mpt3sas: Add persistent trigger pages support scsi: mpt3sas: Sync time periodically between driver and firmware scsi: qla2xxx: Update version to 10.02.00.104-k scsi: qla2xxx: Fix device loss on 4G and older HBAs scsi: qla2xxx: If fcport is undergoing deletion complete I/O with retry scsi: qla2xxx: Fix the call trace for flush workqueue scsi: qla2xxx: Fix flash update in 28XX adapters on big endian machines scsi: qla2xxx: Handle aborts correctly for port undergoing deletion scsi: qla2xxx: Fix N2N and NVMe connect retry failure scsi: qla2xxx: Fix FW initialization error on big endian machines scsi: qla2xxx: Fix crash during driver load on big endian machines scsi: qla2xxx: Fix compilation issue in PPC systems scsi: qla2xxx: Don't check for fw_started while posting NVMe command scsi: qla2xxx: Tear down session if FW say it is down ...
2020-11-16scsi: libiscsi: Fix NOP race conditionLee Duncan1-0/+3
iSCSI NOPs are sometimes "lost", mistakenly sent to the user-land iscsid daemon instead of handled in the kernel, as they should be, resulting in a message from the daemon like: iscsid: Got nop in, but kernel supports nop handling. This can occur because of the new forward- and back-locks, and the fact that an iSCSI NOP response can occur before processing of the NOP send is complete. This can result in "conn->ping_task" being NULL in iscsi_nop_out_rsp(), when the pointer is actually in the process of being set. To work around this, we add a new state to the "ping_task" pointer. In addition to NULL (not assigned) and a pointer (assigned), we add the state "being set", which is signaled with an INVALID pointer (using "-1"). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Lee Duncan <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-29scsi: libfc: Move scsi/fc_encode.h to libfcArnd Bergmann2-727/+30
Most of this file is only used inside of libfc, so move it to where it is actually used, with only fc_fill_fc_hdr() left inside of the header. Link: https://lore.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-26scsi: fc: Add mechanism to update FPIN signal statisticsShyam Sundar1-0/+3
Under fc_host_statistics add statistics for Congestion Signals that are delivered to the host as interrupt signals. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: James Smart <[email protected]> Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Shyam Sundar <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-26scsi: fc: Parse FPIN packets and update statisticsShyam Sundar1-0/+1
Parse the incoming FPIN packets and update the host and rport FPIN statistics based on the FPINs. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Shyam Sundar <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-26scsi: fc: Add FPIN statistics to fc_host and fc_rport objectsShyam Sundar1-0/+32
Add a structure for holding FPIN statistics, for host & rport respectively, and add associated sysfs nodes: /sys/class/fc_host/hostXX/statistics/ /sys/class/fc_remote_ports/rport-XX\:Y-Z/statistics/ Link: https://lore.kernel.org/r/[email protected] Reviewed-by: James Smart <[email protected]> Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Shyam Sundar <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-23Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds1-1/+2
Pull more SCSI updates from James Bottomley: "The set of core changes here is Christoph's submission path cleanups. These introduced a couple of regressions when first proposed so they got held over from the initial merge window pull request to give more testing time, which they've now had and Syzbot has confirmed the regression it detected is fixed. The other main changes are two driver updates (arcmsr, pm80xx) and assorted minor clean ups" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (38 commits) scsi: qla2xxx: Fix return of uninitialized value in rval scsi: core: Set sc_data_direction to DMA_NONE for no-transfer commands scsi: sr: Initialize ->cmd_len scsi: arcmsr: Update driver version to v1.50.00.02-20200819 scsi: arcmsr: Add support for ARC-1886 series RAID controllers scsi: arcmsr: Fix device hot-plug monitoring timer stop scsi: arcmsr: Remove unnecessary syntax scsi: pm80xx: Driver version update scsi: pm80xx: Increase the number of outstanding I/O supported to 1024 scsi: pm80xx: Remove DMA memory allocation for ccb and device structures scsi: pm80xx: Increase number of supported queues scsi: sym53c8xx_2: Fix sizeof() mismatch scsi: isci: Fix a typo in a comment scsi: qla4xxx: Fix inconsistent format argument type scsi: myrb: Fix inconsistent format argument types scsi: myrb: Remove redundant assignment to variable timeout scsi: bfa: Fix error return in bfad_pci_init() scsi: fcoe: Simplify the return expression of fcoe_sysfs_setup() scsi: snic: Simplify the return expression of svnic_cq_alloc() scsi: fnic: Simplify the return expression of vnic_wq_copy_alloc() ...
2020-10-14Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds3-0/+9
Pull SCSI updates from James Bottomley: "The usual driver updates (ufs, qla2xxx, tcmu, ibmvfc, lpfc, smartpqi, hisi_sas, qedi, qedf, mpt3sas) and minor bug fixes. There are only three core changes: adding sense codes, cleaning up noretry and adding an option for limitless retries" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (226 commits) scsi: hisi_sas: Recover PHY state according to the status before reset scsi: hisi_sas: Filter out new PHY up events during suspend scsi: hisi_sas: Add device link between SCSI devices and hisi_hba scsi: hisi_sas: Add check for methods _PS0 and _PR0 scsi: hisi_sas: Add controller runtime PM support for v3 hw scsi: hisi_sas: Switch to new framework to support suspend and resume scsi: hisi_sas: Use hisi_hba->cq_nvecs for calling calling synchronize_irq() scsi: qedf: Remove redundant assignment to variable 'rc' scsi: lpfc: Remove unneeded variable 'status' in lpfc_fcp_cpu_map_store() scsi: snic: Convert to use DEFINE_SEQ_ATTRIBUTE macro scsi: qla4xxx: Delete unneeded variable 'status' in qla4xxx_process_ddb_changed scsi: sun_esp: Use module_platform_driver to simplify the code scsi: sun3x_esp: Use module_platform_driver to simplify the code scsi: sni_53c710: Use module_platform_driver to simplify the code scsi: qlogicpti: Use module_platform_driver to simplify the code scsi: mac_esp: Use module_platform_driver to simplify the code scsi: jazz_esp: Use module_platform_driver to simplify the code scsi: mvumi: Fix error return in mvumi_io_attach() scsi: lpfc: Drop nodelist reference on error in lpfc_gen_req() scsi: be2iscsi: Fix a theoretical leak in beiscsi_create_eqs() ...
2020-10-07scsi: core: Clean up allocation and freeing of sgtablesChristoph Hellwig1-1/+2
Rename scsi_init_io() to scsi_alloc_sgtables(), and ensure callers call scsi_free_sgtables() to cleanup failures close to scsi_init_io() instead of leaking it down the generic I/O submission path. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-10-06scsi: Add host and host template flag 'host_tagset'Hannes Reinecke1-1/+8
Add Host and host template flag 'host_tagset' so hostwide tagset can be shared on multiple reply queues after the SCSI device's reply queue is converted to blk-mq hw queue. [jpg: Update comment on .can_queue and add Scsi_Host.host_tagset] Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: John Garry <[email protected]> Tested-by: Don Brace<[email protected]> #SCSI resv cmds patches used Tested-by: Douglas Gilbert <[email protected]> Acked-by: Martin K. Petersen <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
2020-10-02scsi: target: core: Add CONTROL field for trace eventsRoman Bolshakov1-0/+7
trace-cmd report doesn't show events from target subsystem because scsi_command_size() leaks through event format string: [target:target_sequencer_start] function scsi_command_size not defined [target:target_cmd_complete] function scsi_command_size not defined Addition of scsi_command_size() to plugin_scsi.c in trace-cmd doesn't help because an expression is used inside TP_printk(). trace-cmd event parser doesn't understand minus sign inside [ ]: Error: expected ']' but read '-' Rather than duplicating kernel code in plugin_scsi.c, provide a dedicated field for CONTROL byte. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Roman Bolshakov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-09-15scsi: core: Only re-run queue in scsi_end_request() if device queue is busyMing Lei1-0/+1
The request queue is currently run unconditionally in scsi_end_request() if both target queue and host queue are ready. Recently Long Li reported that cost of a queue run can be very heavy in case of high queue depth. Improve this situation by only running the request queue when this LUN is busy. Link: https://lore.kernel.org/r/[email protected] Reported-by: Long Li <[email protected]> Tested-by: Long Li <[email protected]> Tested-by: Kashyap Desai <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Ewan D. Milne <[email protected]> Reviewed-by: John Garry <[email protected]> Signed-off-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-09-02scsi: fc: Add 256GBit speed setting to SCSI FC transportJames Smart1-0/+1
Add 256GBit speed setting to the SCSI FC transport. This speed can be reached via FC trunking techniques. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-07-24scsi: core: Only return started requests from scsi_host_find_tag()Hannes Reinecke1-1/+1
scsi_host_find_tag() is used by the drivers to return a scsi command based on the command tag. Typically it's used from the interrupt handler to fetch the command associated with a value returned from hardware. Some drivers like fnic or qla4xxx, however, also use it also to traverse outstanding commands. With the current implementation scsi_host_find_tag() will return commands even if they are not started (i.e. passed to the driver). This will result in random errors with those drivers. With this patch scsi_host_find_tag() will only return 'started' commands (i.e. commands which have been passed to the drivers) thus avoiding the above issue. The other use cases will be unaffected as the interrupt handler naturally will only ever return 'started' requests. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-07-24scsi: scsi_transport_iscsi: Drop a duplicated wordRandy Dunlap1-1/+1
Drop the repeated word "the" in a comment. Link: https://lore.kernel.org/r/[email protected] Cc: "James E.J. Bottomley" <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Cc: [email protected] Signed-off-by: Randy Dunlap <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-07-15scsi: scsi_transport_fc: Match HBA Attribute Length with HBAAPI V2.0 definitionsLee Jones1-2/+2
According to 'include/scsi/scsi_transport_fc.h': "Attributes are based on HBAAPI V2.0 definitions" ... so it seems sane to match the 'HBA Attribute Length' to them. If we don't, the compiler complains that the copied data will be truncated. Fixes the following W=1 kernel build warning(s): In file included from include/linux/bitmap.h:9, from include/linux/cpumask.h:12, from include/linux/smp.h:13, from include/linux/percpu.h:7, from include/scsi/libfc.h:13, from drivers/scsi/libfc/fc_elsct.c:17: In function ‘strncpy’, inlined from ‘fc_ct_ms_fill.constprop’ at include/scsi/fc_encode.h:263:3: include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ output may be truncated copying 64 bytes from a string of length 79 [-Wstringop-truncation] 297 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/string.h:307:9: note: in expansion of macro ‘__underlying_strncpy’ 307 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ In function ‘strncpy’, inlined from ‘fc_ct_ms_fill.constprop’ at include/scsi/fc_encode.h:275:3: include/linux/string.h:297:30: warning: ‘__builtin_strncpy’ output may be truncated copying 64 bytes from a string of length 79 [-Wstringop-truncation] 297 | #define __underlying_strncpy __builtin_strncpy | ^ include/linux/string.h:307:9: note: in expansion of macro ‘__underlying_strncpy’ 307 | return __underlying_strncpy(p, q, size); | ^~~~~~~~~~~~~~~~~~~~ Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-06-05Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds2-5/+4
Pull SCSI updates from James Bottomley: :This series consists of the usual driver updates (qla2xxx, ufs, zfcp, target, scsi_debug, lpfc, qedi, qedf, hisi_sas, mpt3sas) plus a host of other minor updates. There are no major core changes in this series apart from a refactoring in scsi_lib.c" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (207 commits) scsi: ufs: ti-j721e-ufs: Fix unwinding of pm_runtime changes scsi: cxgb3i: Fix some leaks in init_act_open() scsi: ibmvscsi: Make some functions static scsi: iscsi: Fix deadlock on recovery path during GFP_IO reclaim scsi: ufs: Fix WriteBooster flush during runtime suspend scsi: ufs: Fix index of attributes query for WriteBooster feature scsi: ufs: Allow WriteBooster on UFS 2.2 devices scsi: ufs: Remove unnecessary memset for dev_info scsi: ufs-qcom: Fix scheduling while atomic issue scsi: mpt3sas: Fix reply queue count in non RDPQ mode scsi: lpfc: Fix lpfc_nodelist leak when processing unsolicited event scsi: target: tcmu: Fix a use after free in tcmu_check_expired_queue_cmd() scsi: vhost: Notify TCM about the maximum sg entries supported per command scsi: qla2xxx: Remove return value from qla_nvme_ls() scsi: qla2xxx: Remove an unused function scsi: iscsi: Register sysfs for iscsi workqueue scsi: scsi_debug: Parser tables and code interaction scsi: core: Refactor scsi_mq_setup_tags function scsi: core: Fix incorrect usage of shost_for_each_device scsi: qla2xxx: Fix endianness annotations in source files ...
2020-05-11scsi: libsas: Replace zero-length array with flexible-arrayGustavo A. R. Silva1-4/+4
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] sizeof(flexible-array-member) triggers a warning because flexible array members have incomplete type[1]. There are some instances of code in which the sizeof operator is being incorrectly/erroneously applied to zero-length arrays and the result is zero. Such instances may be hiding some bugs. So, this work (flexible-array member conversions) will also help to get completely rid of those sorts of issues. This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Link: https://lore.kernel.org/r/20200507192147.GA16206@embeddedor Reviewed-by: John Garry <[email protected]> Reviewed-by: Jason Yan <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-05-07scsi: core: Remove 'list' entry from struct scsi_cmndHannes Reinecke1-1/+0
Leftover from cmd_list removal. Link: https://lore.kernel.org/r/[email protected] Fixes: c5a9707672fe ("scsi: core: Remove cmd_list functionality") Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-04-22block: move dma_pad handling from blk_rq_map_sg into the callersChristoph Hellwig1-0/+1
There are only two callers of blk_rq_map_sg/__blk_rq_map_sg that set the dma_pad value in the queue. Move the handling into those callers instead of burdening the common code, and move the ->extra_len field from struct request to struct scsi_cmnd. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
2020-04-22block: move dma drain handling to scsiChristoph Hellwig2-0/+10
Don't burden the common block code with with specifics of the libata DMA draining mechanism. Instead move most of the code to the scsi midlayer. That also means the nr_phys_segments adjustments in the blk-mq fast path can go away entirely, given that SCSI never looks at nr_phys_segments after mapping the request to a scatterlist. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
2020-04-02Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsiLinus Torvalds9-22/+39
Pull SCSI updates from James Bottomley: "This series has a huge amount of churn because it pulls in Mauro's doc update changing all our txt files to rst ones. Excluding that, we have the usual driver updates (qla2xxx, ufs, lpfc, zfcp, ibmvfc, pm80xx, aacraid), a treewide update for scnprintf and some other minor updates. The major core change is Hannes moving functions out of the aacraid driver and into the core" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (223 commits) scsi: aic7xxx: aic97xx: Remove FreeBSD-specific code scsi: ufs: Do not rely on prefetched data scsi: dc395x: remove dc395x_bios_param scsi: libiscsi: Fix error count for active session scsi: hpsa: correct race condition in offload enabled scsi: message: fusion: Replace zero-length array with flexible-array member scsi: qedi: Add PCI shutdown handler support scsi: qedi: Add MFW error recovery process scsi: ufs: Enable block layer runtime PM for well-known logical units scsi: ufs-qcom: Override devfreq parameters scsi: ufshcd: Let vendor override devfreq parameters scsi: ufshcd: Update the set frequency to devfreq scsi: ufs: Resume ufs host before accessing ufs device scsi: ufs-mediatek: customize the delay for enabling host scsi: ufs: make HCE polling more compact to improve initialization latency scsi: ufs: allow custom delay prior to host enabling scsi: ufs-mediatek: use common delay function scsi: ufs: introduce common and flexible delay function scsi: ufs: use an enum for host capabilities scsi: ufs: fix uninitialized tx_lanes in ufshcd_disable_tx_lcc() ...
2020-03-26scsi: iscsi: Report connection state in sysfsGabriel Krisman Bertazi1-0/+8
If an iSCSI connection happens to fail while the daemon isn't running (due to a crash or for another reason), the kernel failure report is not received. When the daemon restarts, there is insufficient kernel state in sysfs for it to know that this happened. open-iscsi tries to reopen every connection, but on different initiators, we'd like to know which connections have failed. There is session->state, but that has a different lifetime than an iSCSI connection, so it doesn't directly reflect the connection state. [mkp: typos] Link: https://lore.kernel.org/r/[email protected] Cc: Khazhismel Kumykov <[email protected]> Suggested-by: Junho Ryu <[email protected]> Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-03-24scsi: simplify scsi_partsizeChristoph Hellwig1-4/+3
Call scsi_bios_ptable from scsi_partsize instead of requiring boilerplate code in the callers. Also switch the calling convention to match that of the ->bios_param instances calling this function, and use true/false for the return value instead of the weird -1 convention. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
2020-03-11scsi: core: avoid repetitive logging of device offline messagesEwan D. Milne1-0/+3
Large queues of I/O to offline devices that are eventually submitted when devices are unblocked result in a many repeated "rejecting I/O to offline device" messages. These messages can fill up the dmesg buffer in crash dumps so no useful prior messages remain. In addition, if a serial console is used, the flood of messages can cause a hard lockup in the console code. Introduce a flag indicating the message has already been logged for the device, and reset the flag when scsi_device_set_state() changes the device state. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart van Assche <[email protected]> Signed-off-by: Ewan D. Milne <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-03-11scsi: docs: convert scsi-generic.txt to ReSTMauro Carvalho Chehab1-1/+1
Link: https://lore.kernel.org/r/f57b8ddf30397c2c7213e49634e5e9cbd4246368.1583136624.git.mchehab+huawei@kernel.org Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-03-11scsi: iscsi: Add support for asynchronous iSCSI session destructionFrank Mayhar2-0/+2
iSCSI session destruction can be arbitrarily slow, since it might require network operations and serialization inside the SCSI layer. This patch adds a new user event to trigger the destruction work asynchronously, releasing the rx_queue_mutex as soon as the operation is queued and before it is performed. This change allows other operations to run in other sessions in the meantime, removing one of the major iSCSI bottlenecks for us. To prevent the session from being used after the destruction request, we remove it immediately from the sesslist. This simplifies the locking required during the asynchronous removal. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Gabriel Krisman Bertazi <[email protected]> Co-developed-by: Khazhismel Kumykov <[email protected]> Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Signed-off-by: Frank Mayhar <[email protected]> Signed-off-by: Khazhismel Kumykov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-03-11scsi: Replace zero-length array with flexible-array memberGustavo A. R. Silva6-14/+14
The current codebase makes use of the zero-length array language extension to the C90 standard, but the preferred mechanism to declare variable-length types such as these ones is a flexible array member[1][2], introduced in C99: struct foo { int stuff; struct boo array[]; }; By making use of the mechanism above, we will get a compiler warning in case the flexible array does not occur last in the structure, which will help us prevent some kind of undefined behavior bugs from being inadvertently introduced[3] to the codebase from now on. Also, notice that, dynamic memory allocations won't be affected by this change: "Flexible array members have incomplete type, and so the sizeof operator may not be applied. As a quirk of the original implementation of zero-length arrays, sizeof evaluates to zero."[1] This issue was found with the help of Coccinelle. [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html [2] https://github.com/KSPP/linux/issues/21 [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") Link: https://lore.kernel.org/r/20200224161406.GA21454@embeddedor Reviewed-by: Lee Duncan <[email protected]> Reviewed-by: Satish Kharat <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-02-28scsi: core: Introduce {init,exit}_cmd_priv()Bart Van Assche1-0/+3
The current behavior of the SCSI core is to clear driver-private data before preparing a request for submission to the SCSI LLD. Make it possible for SCSI LLDs to disable clearing of driver-private data. These hooks will be used by a later patch, namely "scsi: ufs: Let the SCSI core allocate per-command UFS data". Link: https://lore.kernel.org/r/[email protected] Cc: Tomas Winkler <[email protected]> Cc: Stanley Chu <[email protected]> Cc: Bean Huo <[email protected]> Cc: Avri Altman <[email protected]> Cc: Can Guo <[email protected]> Cc: Ming Lei <[email protected]> Cc: Johannes Thumshirn <[email protected]> Cc: Hannes Reinecke <[email protected]> Cc: Christoph Hellwig <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-02-28scsi: core: Remove cmd_list functionalityHannes Reinecke3-4/+0
Remove cmd_list functionality; no users left. With that the scsi_put_command() becomes empty, so remove that one, too. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Bart van Assche <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2020-02-28scsi: core: add scsi_host_busy_iter()Hannes Reinecke1-0/+3
Add an iterator scsi_host_busy_iter() to traverse all busy commands. If locking against concurrent command completions is required, it has to be provided by the caller. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>