Lines Matching +full:pre +full:- +full:charge +full:- +full:time
1 .. SPDX-License-Identifier: GPL-2.0
14 [1-1] struct scsi_cmnd
15 [1-2] How do scmd's get completed?
16 [1-2-1] Completing a scmd w/ scsi_done
17 [1-2-2] Completing a scmd w/ timeout
18 [1-3] How EH takes over
20 [2-1] EH through fine-grained callbacks
21 [2-1-1] Overview
22 [2-1-2] Flow of scmds through EH
23 [2-1-3] Flow of control
24 [2-2] EH through transportt->eh_strategy_handler()
25 [2-2-1] Pre transportt->eh_strategy_handler() SCSI midlayer conditions
26 [2-2-2] Post transportt->eh_strategy_handler() SCSI midlayer conditions
27 [2-2-3] Things to consider
34 --------------------
38 scmd->list and scmd->eh_entry. The former is used for free list or
39 per-device allocated scmd list and not of much interest to this EH
41 otherwise stated scmds are always linked using scmd->eh_entry in this
46 --------------------------------
50 invoking hostt->queuecommand() or the block layer will time it out.
56 For all non-EH commands, scsi_done() is the completion callback. It
62 scsi_decide_disposition() looks at the scmd->result value and sense
65 - SUCCESS
75 - NEEDS_RETRY
77 - ADD_TO_MLQUEUE
81 - otherwise
84 [1-3] for details of this function.
92 1. invokes optional hostt->eh_timed_out() callback. Return value can
95 - SCSI_EH_RESET_TIMER
96 This indicates that more time is required to finish the
99 - SCSI_EH_NOT_HANDLED
103 - SCSI_EH_DONE
107 issue a retry scmd->allowed + 1 times. Asynchronous aborts are not invoked
114 command. See [1-4] for more information.
117 -------------------------------
125 See [1-4] for more information.
128 ---------------------
132 1. Links scmd->eh_entry to shost->eh_cmd_q
134 2. Sets SHOST_RECOVERY bit in shost->shost_state
136 3. Increments shost->host_failed
138 4. Wakes up SCSI EH thread if shost->host_busy == shost->host_failed
140 As can be seen above, once any scmd is added to shost->eh_cmd_q,
144 time out and get added to shost->eh_cmd_q.
146 If all scmds either complete or fail, the number of in-flight scmds
147 becomes equal to the number of failed scmds - i.e. shost->host_busy ==
148 shost->host_failed. This wakes up SCSI EH thread. So, once woken up,
149 SCSI EH thread can expect that all in-flight commands have failed and
150 are linked on shost->eh_cmd_q.
155 has timed out, unless hostt->eh_timed_out() made lower layers forget
158 occur at any time. Of course, all such completions are ignored as the
161 We'll talk about how SCSI EH takes actions to abort - make LLDD
162 forget about - timed out scmds later.
171 - Fine-grained EH callbacks
172 LLDD can implement fine-grained EH callbacks and let SCSI
174 This will be discussed further in [2-1].
176 - eh_strategy_handler() callback
179 performs during recovery. This will be discussed in [2-2].
188 3. Wakes up waiters on shost->host_wait. This occurs if someone
196 2.1 EH through fine-grained callbacks
197 -------------------------------------
202 If eh_strategy_handler() is not present, SCSI midlayer takes charge
203 of driving error handling. EH's goals are two - make LLDD, host and
211 others are performed by invoking one of the following fine-grained
222 Higher-severity actions are taken only when lower-severity actions
224 highest-severity action means EH failure and results in offlining of
229 - Recovery actions are performed on failed scmds on the to do list,
237 - Higher severity actions are taken iff eh_work_q is not empty after
240 - EH reuses failed scmds to issue commands for recovery. For
241 timed-out scmds, SCSI EH ensures that LLDD forgets about a scmd
247 either retry or error-finish (notify upper layer of failure) recovered
251 EH), REQ_FAILFAST is not set and ++scmd->retries is less than
252 scmd->allowed.
258 1. Error completion / time out
262 - add scmd to shost->eh_cmd_q
263 - set SHOST_RECOVERY
264 - shost->host_failed++
266 :LOCKING: shost->host_lock
270 :ACTION: move all scmds to EH's local eh_work_q. shost->eh_cmd_q
273 :LOCKING: shost->host_lock (not strictly necessary, just for
278 :ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd
280 - move from local eh_work_q to local eh_done_q
294 - scmd is removed from eh_done_q and scmd->eh_entry is cleared
295 - if retry is necessary, scmd is requeued using
297 - otherwise, scsi_finish_command() is invoked for scmd
298 - zero shost->host_failed
306 EH through fine-grained callbacks start from scsi_unjam_host().
310 1. Lock shost->host_lock, splice_init shost->eh_cmd_q into local
311 eh_work_q and unlock host_lock. Note that shost->eh_cmd_q is
318 This action is taken for each error-completed
325 Note that if autosense is not supported, scmd->sense_buffer
326 contains invalid sense data when error-completing the scmd
334 causes higher-severity recovery to be taken for the scmd.
338 - SUCCESS
339 scmd->retries is set to scmd->allowed preventing
343 - NEEDS_RETRY
346 - otherwise
363 as we explicitly choose error-completed scmds, it is known
368 all failed scmds on the sdev are EH-finished with
371 *NOTE* If hostt->eh_abort_handler() isn't implemented or
374 scmds. Yet, this function EH-finish all scmds on the sdev
384 instead of issuing STU, hostt->eh_device_reset_handler()
387 to choose error-completed scmds.
393 hostt->eh_bus_reset_handler() is invoked for each channel
396 EH-finished.
402 This is the last resort. hostt->eh_host_reset_handler()
404 all ready or offline sdevs on the host are EH-finished.
411 and EH-finish the scmds.
423 2.2 EH through transportt->eh_strategy_handler()
424 ------------------------------------------------
426 transportt->eh_strategy_handler() is invoked in the place of
431 SCSI midlayer. IOW, of the steps described in [2-1-2], all steps
435 2.2.1 Pre transportt->eh_strategy_handler() SCSI midlayer conditions
440 - Each failed scmd's eh_flags field is set appropriately.
442 - Each failed scmd is linked on scmd->eh_cmd_q by scmd->eh_entry.
444 - SHOST_RECOVERY is set.
446 - shost->host_failed == shost->host_busy
449 2.2.2 Post transportt->eh_strategy_handler() SCSI midlayer conditions
454 - shost->host_failed is zero.
456 - shost->eh_cmd_q is cleared.
458 - Each scmd->eh_entry is cleared.
460 - Either scsi_queue_insert() or scsi_finish_command() is called on
461 each scmd. Note that the handler is free to use scmd->retries and
462 ->allowed to limit the number of retries.
468 - Know that timed out scmds are still active on lower layers. Make
472 - For consistency, when accessing/modifying shost data structure,
473 grab shost->host_lock.
475 - On completion, each failed sdev must have forgotten about all
478 - On completion, each failed sdev must be ready for new commands or