Commit Graph

1248778 Commits

Author SHA1 Message Date
Ricardo B. Marliere
4ad9465365 scsi: target: tcm_loop: Make tcm_loop_lld_bus const
Now that the driver core can properly handle constant struct bus_type, move
the tcm_loop_lld_bus variable to be a constant structure as well, placing
it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240204-bus_cleanup-target-v1-1-96106936c4ab@marliere.net
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:58:55 -05:00
Ricardo B. Marliere
ac0dd0f33a scsi: scsi_debug: Make pseudo_lld_bus const
Now that the driver core can properly handle constant struct bus_type, move
the pseudo_lld_bus variable to be a constant structure as well, placing it
into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240203-bus_cleanup-scsi-v1-3-6f552fb24f71@marliere.net
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:57:18 -05:00
Ricardo B. Marliere
824ec98b1b scsi: iscsi: Make iscsi_flashnode_bus const
Now that the driver core can properly handle constant struct bus_type, move
the iscsi_flashnode_bus variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240203-bus_cleanup-scsi-v1-2-6f552fb24f71@marliere.net
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:57:18 -05:00
Ricardo B. Marliere
4dbde797b9 scsi: fcoe: Make fcoe_bus_type const
Now that the driver core can properly handle constant struct bus_type, move
the fcoe_bus_type variable to be a constant structure as well, placing it
into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://lore.kernel.org/r/20240203-bus_cleanup-scsi-v1-1-6f552fb24f71@marliere.net
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:57:18 -05:00
Martin K. Petersen
3d6776a371 Merge patch series "Update lpfc to revision 14.4.0.0"
Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.4.0.0

This patch set contains fixes identified by static code analyzers,
updates to log messaging, bug fixes related to discovery and
congestion management, and clean up patches regarding the abuse of
shost lock in the driver.

The patches were cut against Martin's 6.9/scsi-queue tree.

Link: https://lore.kernel.org/r/20240131185112.149731-1-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:52:37 -05:00
Justin Tee
ea4044e4dd scsi: lpfc: Copyright updates for 14.4.0.0 patches
Update copyrights to 2024 for files modified in the 14.4.0.0 patch set.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-18-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:36 -05:00
Justin Tee
5b22878daf scsi: lpfc: Update lpfc version to 14.4.0.0
Update lpfc version to 14.4.0.0.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-17-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:36 -05:00
Justin Tee
e39811bec6 scsi: lpfc: Change lpfc_vport load_flag member into a bitmask
In attempt to reduce the amount of unnecessary shost_lock acquisitions in
the lpfc driver, change load_flag into an unsigned long bitmask and use
clear_bit/test_bit bitwise atomic APIs instead of reliance on shost_lock
for synchronization.

Also, correct the test for FC_UNLOADING in lpfc_ct_handle_mibreq, which
incorrectly tests vport->fc_flag rather than vport->load_flag.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-16-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:36 -05:00
Justin Tee
a645b8c1f5 scsi: lpfc: Change lpfc_vport fc_flag member into a bitmask
In attempt to reduce the amount of unnecessary shost_lock acquisitions in
the lpfc driver, change fc_flag into an unsigned long bitmask and use
clear_bit/test_bit bitwise atomic APIs instead of reliance on shost_lock
for synchronization.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-15-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:36 -05:00
Justin Tee
9bb36777d0 scsi: lpfc: Protect vport fc_nodes list with an explicit spin lock
In attempt to reduce the amount of unnecessary shost_lock acquisitions in
the lpfc driver, replace shost_lock with an explicit fc_nodes_list_lock
spinlock when accessing vport->fc_nodes lists.  Although vport memory
region is owned by shost->hostdata, it is driver private memory and an
explicit fc_nodes list lock for fc_nodes list mutations is more appropriate
than locking the entire shost.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-14-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:36 -05:00
Justin Tee
0dfd9cbc18 scsi: lpfc: Change nlp state statistic counters into atomic_t
There is no reason to use the shost_lock to synchronize an LLDD statistics
counter.  Convert all the nlp state statistic counters into atomic_t.
Corresponding zeroing, increments, and reads are converted to atomic
versions.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-13-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
4be4ad6cd2 scsi: lpfc: Remove shost_lock protection for fc_host_port shost APIs
Desiring to reduce the amount of unnecessary shost_lock acquisitions in the
lpfc driver, it has been determined that there is no need for shost_lock
protection when retrieving fc_host port information because it is only for
display to user via sysfs.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-12-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
140bd888ed scsi: lpfc: Move handling of reset congestion statistics events
The ACQE notification event to reset congestion statistics should be moved
into the specific lpfc_sli4_async_sli_evt() routine instead of being
processed from the generic lpfc_sli4_async_event_proc() routine.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-11-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
6ca396c5e3 scsi: lpfc: Save FPIN frequency statistics upon receipt of peer cgn notifications
FPIN frequency is provided by the fabric in peer congestion notifications.

Currently, the frequency is only logged in a message, but it should also be
saved into the phba's cgn_fpin statistics member for proper application
functionality.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-10-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
900db34ad2 scsi: lpfc: Add condition to delete ndlp object after sending BLS_RJT to an ABTS
The "Nodelist not empty" log message and an accompanying delay may be
observed when deleting an NPIV port or unloading the lpfc driver.  This can
occur due to receipt of an ABTS for which there is no corresponding login
context or ndlp allocated.  In such cases, the driver allocates a new ndlp
object to send a BLS_RJT after which the ndlp object unintentionally
remains in the NLP_STE_UNUSED_NODE state forever.

Add a check to conditionally remove ndlp's initial reference count when
queuing a BLS response.  If the initial reference is removed, then set
the NLP_DROPPED flag to notify other code paths.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-9-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
7bb6cb7bb2 scsi: lpfc: Fix failure to delete vports when discovery is in progress
Requests to delete an NPIV port may fail repeatedly if the initial request
is received during discovery.

If the FC_UNLOADING load_flag is set, then skip CT response processing for
the physical port.  This allows discovery processing for other lpfc_vport
objects to reach their cmpl routines before deleting the vport.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-8-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
a801d57a11 scsi: lpfc: Remove NLP_RCV_PLOGI early return during RSCN processing for ndlps
Upon first RSCN receipt of a target server's remote port that is initially
acting as an initiator function, the driver marks the ndlp->nlp_type as an
initiator role.  Then later, when processing an RSCN for a target function
role switch, that ndlp remote port is permanently stuck as an initiator
role and can never transition to be discovered as an updated target role
function.

Remove the NLP_RCV_PLOGI early return if statement clause so that the
NLP_NPR_2B_DISC flag gets set.  This allows for role change detections.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-7-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
e1b3acad0d scsi: lpfc: Allow lpfc_plogi_confirm_nport() logic to execute for Fabric nodes
Remove the early return NLP_FABRIC check in lpfc_plogi_confirm_nport()
because it is possible for switch domain controllers to change WWPN.

As a result, allow lpfc_plogi_confirm_nport() to detect that a new ndlp
should be initialized in such cases.  The old ndlp object will be cleaned
up when dev_loss_tmo callbk executes.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-6-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:35 -05:00
Justin Tee
b76beac1a4 scsi: lpfc: Remove D_ID swap log message from trace event logger
D_ID swaps are common during cable swaps in a SAN.  Thus, there's no reason
to log the event at a KERN_ERR level with the trace event logger.

Change the log level to KERN_INFO and the normal LOG_ELS flag.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-5-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:34 -05:00
Justin Tee
aa7674bd8d scsi: lpfc: Use sg_dma_len() API to get struct scatterlist's length
The sg_dma_len() API should be used to retrieve a scatterlist's length
instead of directly accessing scatterlist->length.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-4-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:34 -05:00
Justin Tee
2ae917d4bc scsi: lpfc: Fix possible memory leak in lpfc_rcv_padisc()
The call to lpfc_sli4_resume_rpi() in lpfc_rcv_padisc() may return an
unsuccessful status.  In such cases, the elsiocb is not issued, the
completion is not called, and thus the elsiocb resource is leaked.

Check return value after calling lpfc_sli4_resume_rpi() and conditionally
release the elsiocb resource.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-3-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:34 -05:00
Justin Tee
3d0f9342ae scsi: lpfc: Initialize status local variable in lpfc_sli4_repost_sgl_list()
A static code analyzer tool indicates that the local variable called status
in the lpfc_sli4_repost_sgl_list() routine could be used to print garbage
uninitialized values in the routine's log message.

Fix by initializing to zero.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20240131185112.149731-2-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-02-05 20:51:34 -05:00
Martin K. Petersen
3f90ac7138 Merge patch series "scsi: Allow scsi_execute users to request retries"
Mike Christie <michael.christie@oracle.com> says:

The following patches were made over Linus's tree which contains a fix
for sd which was not in Martin's branches.

The patches allow scsi_execute_cmd users to have scsi-ml retry the cmd
for it instead of the caller having to parse the error and loop
itself.

Link: https://lore.kernel.org/r/20240123002220.129141-1-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:21:10 -05:00
Mike Christie
25a1f7a0a1 scsi: core: Add kunit tests for scsi_check_passthrough()
Add some kunit tests for scsi_check_passthrough() so we can easily make
sure we are hitting the cases for which it's difficult to replicate in
hardware or even scsi_debug.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-20-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:55 -05:00
Mike Christie
b8c3a7bac9 scsi: ufs: Have midlayer retry start stop errors
This has the SCSI midlayer retry errors instead of driving them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-19-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
b72f2d149e scsi: sr: Have midlayer retry get_sectorsize() errors
This has get_sectorsize() have the SCSI midlayer retry errors instead of
driving them itself.

There is one behavior change where we no longer retry when
scsi_execute_cmd() returns < 0, but we should be ok. We don't need to retry
for failures like the queue being removed, and for the case where there are
no tags/reqs the block layer waits/retries for us. For possible memory
allocation failures from blk_rq_map_kern() we use GFP_NOIO, so retrying
will probably not help.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-18-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
3a7b457932 scsi: ses: Have midlayer retry scsi_execute_cmd() errors
This has ses have the SCSI midlayer retry scsi_execute_cmd() errors instead
of driving them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-17-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
0f11328f2f scsi: sd: Have midlayer retry read_capacity_10() errors
This has read_capacity_10() have the SCSI midlayer retry errors instead of
driving them itself.

There are 2 behavior changes with this patch:

 1. There is one behavior change where we no longer retry when
    scsi_execute_cmd() returns < 0, but we should be ok. We don't need to
    retry for failures like the queue being removed, and for the case where
    there are no tags/reqs since the block layer waits/retries for us. For
    possible memory allocation failures from blk_rq_map_kern() we use
    GFP_NOIO, so retrying will probably not help.

 2. For the specific UAs we checked for and retried, we would get
    READ_CAPACITY_RETRIES_ON_RESET retries plus whatever retries were left
    from the main loop's retries. Each UA now gets
    READ_CAPACITY_RETRIES_ON_RESET retries, and the other errors get up to
    3 retries. This is most likely ok, because
    READ_CAPACITY_RETRIES_ON_RESET is already 10 and is not based on
    anything specific like a spec or device, so the extra 3 we got from the
    main loop was probably just an accident and is not going to help.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-16-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
eea6ef3792 scsi: sd: Have pr commands retry UAs
It's common to get a UA when doing PR commands. It could be due to a target
restarting, transport level relogin or other PR commands like a release
causing it. The upper layers don't get the sense and in some cases have no
idea if it's a SCSI device, so this has the sd layer retry.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-15-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
8d24677ebb scsi: core: Have SCSI midlayer retry scsi_report_lun_scan() errors
This has scsi_report_lun_scan() have the SCSI midlayer retry errors instead
of driving them itself.

There is one behavior change where we no longer retry when
scsi_execute_cmd() returns < 0, but we should be ok. We don't need to retry
for failures like the queue being removed, and for the case where there are
no tags/reqs the block layer waits/retries for us. For possible memory
allocation failures from blk_rq_map_kern() we use GFP_NOIO, so retrying
will probably not help.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-14-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
21bdff48e1 scsi: core: Have midlayer retry scsi_mode_sense() UAs
This has scsi_mode_sense() have the SCSI midlayer retry UAs instead of
driving them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-13-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
e11f35c46e scsi: ch: Have midlayer retry ch_do_scsi() UAs
This has ch_do_scsi() have the SCSI midlayer retry UAs instead of driving
them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-12-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
11a2672321 scsi: ch: Remove unit_attention
unit_attention is not used so remove it.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-11-michael.christie@oracle.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:54 -05:00
Mike Christie
183053203d scsi: sd: Have midlayer retry sd_sync_cache() errors
This has sd_sync_cache() have the SCSI midlayer retry errors instead of
driving them itself.

There is one behavior change where we no longer retry when
scsi_execute_cmd() returns < 0, but we should be ok. We don't need to retry
for failures like the queue being removed, and for the case where there are
no tags/reqs the block layer waits/retries for us. For possible memory
allocation failures from blk_rq_map_kern() we use GFP_NOIO, so retrying
will probably not help.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-10-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
5dbf104736 scsi: spi: Have midlayer retry spi_execute() UAs
This has spi_execute() have the SCSI midlayer retry UAs instead of driving
them.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-9-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
f316ff46a0 scsi: device_handler: rdac: Have midlayer retry send_mode_select() errors
This has rdac have the SCSI midlayer retry errors instead of driving them
itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-8-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
fabe3ee92e scsi: device_handler: hp_sw: Have midlayer retry scsi_execute_cmd() errors
This has hp_sw have the SCSI midlayer retry scsi_execute_cmd() errors
instead of driving them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-7-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
c1acf38cd1 scsi: sd: Have midlayer retry sd_spinup_disk() errors
This simplifies sd_spinup_disk() so the SCSI midlayer retries errors for
it. Note that we retried every UA except Medium Not Present and also if
scsi_status_is_good() returned failed which would happen for all check
conditions. In this patch we use SCMD_FAILURE_STAT_ANY which will trigger
for the same conditions as when scsi_status_is_good() returns false and
there is status. This will cover all CCs including UAs so there is no
explicit failures array entry for UAs except for Medium Not Present which
we don't want to retry.

There is one behavior change where we no longer retry when
scsi_execute_cmd() returns < 0, but we should be ok. We don't need to retry
for failures like the queue being removed, and for the case where there are
no tags/reqs the block layer waits/retries for us. For possible memory
allocation failures from blk_rq_map_kern() we use GFP_NOIO, so retrying
will probably not help.

We do not handle the outside loop's retries because we want to sleep
between tries and we don't support that yet.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-6-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
1008f5776f scsi: sd: Use separate buf for START_STOP in sd_spinup_disk()
We currently reuse the cmd buffer for the TUR and START_STOP commands
which requires us to reset the buffer when retrying. This has us use
separate buffers for the 2 commands so we can make them const and I think
it makes it easier to handle for retries but does not add too much extra to
the stack use.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-5-michael.christie@oracle.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
987d7d3db0 scsi: core: Retry INQUIRY after timeout
Description from: Martin Wilck <mwilck@suse.com>:

The SCSI mid layer doesn't retry commands after DID_TIME_OUT (see
scsi_noretry_cmd()). Packet loss in the fabric can cause spurious timeouts
during SCSI device probing, causing device probing to fail. This has been
observed in FCoE uplink failover tests, for example.

This patch fixes the issue by retrying the INQUIRY.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-4-michael.christie@oracle.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
2a1f96f60a scsi: core: Have midlayer retry scsi_probe_lun() errors
This has scsi_probe_lun() ask the SCSI midlayer to retry UAs instead of
driving them itself.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-3-michael.christie@oracle.com
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Mike Christie
994724e6b3 scsi: core: Allow passthrough to request midlayer retries
For passthrough we don't retry any error which we get a check condition
for. This results in a lot of callers driving their own retries for all
UAs, specific UAs, NOT_READY, specific sense values or any type of failure.

This adds the core code to allow passthrough users to specify what errors
they want the SCSI midlayer to retry for them. We can then convert users to
drop a lot of their sense parsing and retry handling.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20240123002220.129141-2-michael.christie@oracle.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 21:20:53 -05:00
Li Zhijian
8179041f80 scsi: pm8001: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/pm8001/pm8001_ctl.c:883:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Jack Wang <jinpu.wang@cloud.ionos.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-32-lizhijian@fujitsu.com
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:40:49 -05:00
Li Zhijian
5fbf37e530 scsi: isci: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/isci/init.c:140:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-25-lizhijian@fujitsu.com
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:40:49 -05:00
Li Zhijian
01105c23de scsi: ibmvscsi_tgt: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3619:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3625:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c:3633:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Michael Cyr <mikecyr@linux.ibm.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
CC: target-devel@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-24-lizhijian@fujitsu.com
Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:40:49 -05:00
Li Zhijian
29ff822f46 scsi: ibmvscsi: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/ibmvscsi/ibmvfc.c:3483:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3493:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3503:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3513:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3522:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/ibmvscsi/ibmvfc.c:3530:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Tyrel Datwyler <tyreld@linux.ibm.com>
CC: Michael Ellerman <mpe@ellerman.id.au>
CC: Nicholas Piggin <npiggin@gmail.com>
CC: Christophe Leroy <christophe.leroy@csgroup.eu>
CC: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
CC: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
CC: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-23-lizhijian@fujitsu.com
Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:40:49 -05:00
Li Zhijian
1ad717c929 scsi: fnic: Convert snprintf() to sysfs_emit()
Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

> ./drivers/scsi/fnic/fnic_attrs.c:17:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:23:8-16: WARNING: please use sysfs_emit
> ./drivers/scsi/fnic/fnic_attrs.c:31:8-16: WARNING: please use sysfs_emit

No functional change intended

CC: Satish Kharat <satishkh@cisco.com>
CC: Sesidhar Baddela <sebaddel@cisco.com>
CC: Karan Tilak Kumar <kartilak@cisco.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240116045151.3940401-20-lizhijian@fujitsu.com
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:40:48 -05:00
Lee Jones
bc978cc18d scsi: aacraid: aachba: Replace snprintf() with the safer scnprintf() variant
There is a general misunderstanding amongst engineers that {v}snprintf()
returns the length of the data *actually* encoded into the destination
array.  However, as per the C99 standard {v}snprintf() really returns
the length of the data that *would have been* written if there were
enough space for it.  This misunderstanding has led to buffer-overruns
in the past.  It's generally considered safer to use the {v}scnprintf()
variants in their place (or even sprintf() in simple cases).  So let's
do that.

Link: https://lwn.net/Articles/69419/
Link: https://github.com/KSPP/linux/issues/105
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: PMC-Sierra, Inc <aacraid@pmc-sierra.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20240111131732.1815560-6-lee@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:34:52 -05:00
Lee Jones
f615c74de3 scsi: 53c700: Remove snprintf() from sysfs call-backs and replace with sysfs_emit()
Since snprintf() has the documented, but still rather strange trait of
returning the length of the data that *would have been* written to the
array if space were available, rather than the arguably more useful
length of data *actually* written, it is usually considered wise to use
something else instead in order to avoid confusion.

In the case of sysfs call-backs, new wrappers exist that do just that.

[mkp: removed unrelated whitespace cleanups]

Link: https://lwn.net/Articles/69419/
Link: https://github.com/KSPP/linux/issues/105
Cc: Richard Hirst <rhirst@linuxcare.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20240111131732.1815560-5-lee@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:34:52 -05:00
Lee Jones
30cc6aa09e scsi: 3w-xxxx: Remove snprintf() from sysfs call-backs and replace with sysfs_emit()
Since snprintf() has the documented, but still rather strange trait of
returning the length of the data that *would have been* written to the
array if space were available, rather than the arguably more useful
length of data *actually* written, it is usually considered wise to use
something else instead in order to avoid confusion.

In the case of sysfs call-backs, new wrappers exist that do just that.

Link: https://lwn.net/Articles/69419/
Link: https://github.com/KSPP/linux/issues/105
Cc: Adam Radford <aradford@gmail.com>
Cc: Joel Jacobson <linux@3ware.com>
Cc: de Melo <acme@conectiva.com.br>
Cc: Andre Hedrick <andre@suse.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20240111131732.1815560-4-lee@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2024-01-29 20:34:52 -05:00