linux/drivers/block
Lars Ellenberg cf01aa6288 drbd: fix "LOGIC BUG" in drbd_al_begin_io_nonblock()
commit ab140365fb upstream.

Even though we check that we "should" be able to do lc_get_cumulative()
while holding the device->al_lock spinlock, it may still fail,
if some other code path decided to do lc_try_lock() with bad timing.

If that happened, we logged "LOGIC BUG for enr=...",
but still did not return an error.

The rest of the code now assumed that this request has references
for the relevant activity log extents.

The implcations are that during an active resync, mutual exclusivity of
resync versus application IO is not guaranteed. And a potential crash
at this point may not realizs that these extents could have been target
of in-flight IO and would need to be resynced just in case.

Also, once the request completes, it will give up activity log references it
does not even hold, which will trigger a BUG_ON(refcnt == 0) in lc_put().

Fix:

Do not crash the kernel for a condition that is harmless during normal
operation: also catch "e->refcnt == 0", not only "e == NULL"
when being noisy about "al_complete_io() called on inactive extent %u\n".

And do not try to be smart and "guess" whether something will work, then
be surprised when it does not.
Deal with the fact that it may or may not work.  If it does not, remember a
possible "partially in activity log" state (only possible for requests that
cross extent boundaries), and return an error code from
drbd_al_begin_io_nonblock().

A latter call for the same request will then resume from where we left off.

Cc: stable@vger.kernel.org
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:09 +02:00
..
aoe aoe: avoid potential deadlock at set_capacity 2025-07-17 18:30:48 +02:00
drbd drbd: fix "LOGIC BUG" in drbd_al_begin_io_nonblock() 2026-04-18 10:33:09 +02:00
mtip32xx block: fix surprise removal for drivers calling blk_set_queue_dying 2022-02-23 12:03:15 +01:00
null_blk null_blk: fix validation of block size 2024-07-27 10:46:09 +02:00
paride pcd: fix error codes in pcd_init_unit() 2023-09-19 12:23:04 +02:00
rnbd rnbd-srv: Zero the rsp buffer before using it 2026-03-04 07:19:58 -05:00
rsxx block: handle bio_split_to_limits() NULL return 2023-01-18 11:48:58 +01:00
xen-blkback xen-blkback: Advertise feature-persistent as user requested 2022-09-08 12:28:05 +02:00
zram zram: refuse to use zero sized block device as backing device 2025-01-09 13:28:34 +01:00
amiflop.c block: drop unused includes in <linux/genhd.h> 2022-03-16 14:23:46 +01:00
ataflop.c block: drop unused includes in <linux/genhd.h> 2022-03-16 14:23:46 +01:00
brd.c brd: defer automatic disk creation until module initialization succeeds 2024-12-14 19:50:42 +01:00
cryptoloop.c cryptoloop: add a deprecation warning 2021-08-27 10:44:54 -06:00
floppy.c floppy: fix for PAGE_SIZE != 4KB 2026-01-19 13:09:49 +01:00
Kconfig remove the sx8 block driver 2023-06-14 11:12:59 +02:00
loop.c loop: aio inherit the ioprio of original request 2025-05-02 07:44:38 +02:00
loop.h loop: reduce the loop_ctl_mutex scope 2021-09-03 22:14:40 -06:00
Makefile remove the sx8 block driver 2023-06-14 11:12:59 +02:00
n64cart.c block: rename GENHD_FL_NO_PART_SCAN to GENHD_FL_NO_PART 2023-09-19 12:23:02 +02:00
nbd.c nbd: defer config unlock in nbd_genl_connect 2026-01-19 13:09:28 +01:00
pktcdvd.c block: handle bio_split_to_limits() NULL return 2023-01-18 11:48:58 +01:00
ps3disk.c ps3disk: use memcpy_{from,to}_bvec index 2026-01-19 13:09:29 +01:00
ps3vram.c block: handle bio_split_to_limits() NULL return 2023-01-18 11:48:58 +01:00
rbd.c rbd: check for EOD after exclusive lock is ensured to be held 2026-02-11 13:35:26 +01:00
rbd_types.h libceph, rbd: replace zero-length array with flexible-array 2020-06-01 13:22:53 +02:00
sunvdc.c sunvdc: Balance device refcount in vdc_port_mpgroup_check 2025-08-28 16:24:15 +02:00
swim.c block: drop unused includes in <linux/genhd.h> 2022-03-16 14:23:46 +01:00
swim3.c swim3: use blk_mq_alloc_disk 2021-06-11 11:53:02 -06:00
swim_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
virtio_blk.c virtio-blk: don't keep queue frozen during system suspend 2025-01-09 13:28:40 +01:00
xen-blkfront.c xen/blkfront: Only check REQ_FUA for writes 2023-06-21 15:59:13 +02:00
z2ram.c for-5.14/drivers-2021-06-29 2021-06-30 12:21:16 -07:00