]> git.baikalelectronics.ru Git - kernel.git/commit
dm bufio: simplify DM_BUFIO_CLIENT_NO_SLEEP locking
authorMike Snitzer <snitzer@kernel.org>
Sat, 6 Aug 2022 02:58:33 +0000 (22:58 -0400)
committerMike Snitzer <snitzer@kernel.org>
Tue, 9 Aug 2022 23:12:14 +0000 (19:12 -0400)
commit5505cb9e1d286fb4bd20f549f070daf70edf23cc
tree66de843e37d7ba139884dbd35b0fec9fa3f56b83
parent3fb1136f6d25ba8338178ac271eef09f2e783fd7
dm bufio: simplify DM_BUFIO_CLIENT_NO_SLEEP locking

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
172f4a827694 ("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: 172f4a827694 ("dm verity: Add optional "try_verify_in_tasklet" feature")
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-bufio.c