Skip to content
  • Bart Van Assche's avatar
    scsi: klist: Make it safe to use klists in atomic context · 624fa779
    Bart Van Assche authored
    In the scsi_transport_srp implementation it cannot be avoided to
    iterate over a klist from atomic context when using the legacy block
    layer instead of blk-mq. Hence this patch that makes it safe to use
    klists in atomic context. This patch avoids that lockdep reports the
    following:
    
    WARNING: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected
     Possible interrupt unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock(&(&k->k_lock)->rlock);
                                   local_irq_disable();
                                   lock(&(&q->__queue_lock)->rlock);
                                   lock(&(&k->k_lock)->rlock);
      <Interrupt>
        lock(&(&q->__queue_lock)->rlock);
    
    stack backtrace:
    Workqueue: kblockd blk_timeout_work
    Call Trace:
     dump_stack+0xa4/0xf5
     check_usage+0x6e6/0x700
     __lock_acquire+0x185d/0x1b50
     lock_acquire+0xd2/0x260
     _raw_spin_lock+0x32/0x50
     klist_next+0x47/0x190
     device_for_each_child+0x8...
    624fa779