diff options
author | Ahmed S. Darwish <a.darwish@linutronix.de> | 2020-12-20 23:36:38 +0300 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-01-23 04:25:25 +0300 |
commit | bbb087679d5f4e104306c2664c22ed8f6356e820 (patch) | |
tree | e62678b4b0166116c3e5a09a71da1c8bfbcd0a71 /drivers/target/target_core_transport.c | |
parent | 513e29946ab22f66cd14670024f6c98b5b913462 (diff) | |
download | linux-bbb087679d5f4e104306c2664c22ed8f6356e820.tar.xz |
scsi: target: core: Remove in_interrupt() check in transport_handle_cdb_direct()
transport_handle_cdb_direct() uses in_interrupt() to detect if it is safe
to sleep. It produces a stack trace and returns with an error which is
clearly for debugging.
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.
transport_handle_cdb_direct() has a comment saying that it may only be
invoked from process context. It invokes transport_generic_new_cmd() which
performs GFP_KERNEL memory allocations. in_interrupt() does not detect all
the contexts where it is invalid to sleep (for the blocking GFP_KERNEL
allocation) as it fails to detect sections with disabled preemption.
Replace the in_interrupt() based check with a might_sleep() annotation.
Link: https://lore.kernel.org/r/20201220203638.43615-7-bigeasy@linutronix.de
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/target/target_core_transport.c')
-rw-r--r-- | drivers/target/target_core_transport.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index b4fdc3f41e90..d47bfd8b0f87 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1512,17 +1512,14 @@ int transport_handle_cdb_direct( { sense_reason_t ret; + might_sleep(); + if (!cmd->se_lun) { dump_stack(); pr_err("cmd->se_lun is NULL\n"); return -EINVAL; } - if (in_interrupt()) { - dump_stack(); - pr_err("transport_generic_handle_cdb cannot be called" - " from interrupt context\n"); - return -EINVAL; - } + /* * Set TRANSPORT_NEW_CMD state and CMD_T_ACTIVE to ensure that * outstanding descriptors are handled correctly during shutdown via |