• Mike Snitzer's avatar
    dm bufio: simplify DM_BUFIO_CLIENT_NO_SLEEP locking · b33b6fdc
    Mike Snitzer authored
    Historically none of the bufio code runs in interrupt context but with
    the use of DM_BUFIO_CLIENT_NO_SLEEP a bufio client can, see: commit
    5721d4e5 ("dm verity: Add optional "try_verify_in_tasklet" feature")
    That said, the new tasklet usecase still doesn't require interrupts be
    disabled by bufio (let alone conditionally restore them).
    
    Yet with PREEMPT_RT, and falling back from tasklet to workqueue, care
    must be taken to properly synchronize between softirq and process
    context, otherwise ABBA deadlock may occur. While it is unnecessary to
    disable bottom-half preemption within a tasklet, we must consistently do
    so in process context to ensure locking is in the proper order.
    
    Fix these issues by switching from spin_lock_irq{save,restore} to using
    spin_{lock,unlock}_bh instead. Also remove the 'spinlock_flags' member
    in dm_bufio_client struct (that can be used unsafely if bufio must
    recurse on behalf of some caller, e.g. block layer's submit_bio).
    
    Fixes: 5721d4e5 ("dm verity: Add optional "try_verify_in_tasklet" feature")
    Reported-by: default avatarJens Axboe <axboe@kernel.dk>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    b33b6fdc
dm-bufio.c 51.5 KB