drbd: bm_page_async_io: fix spurious bitmap "IO error" on large volumes
authorLars Ellenberg <lars.ellenberg@linbit.com>
Wed, 22 Jun 2022 20:49:32 +0000 (22:49 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 27 Jun 2022 12:29:22 +0000 (06:29 -0600)
commit197f80d97e9ccc8a496f4935ba939f3ed7432d53
tree55cb79442ec6340b2ccab8188feeee6e6f87d450
parentee78ec1077d37d1a4a0860589a65df8ae6d2255c
drbd: bm_page_async_io: fix spurious bitmap "IO error" on large volumes

We usually do all our bitmap IO in units of PAGE_SIZE.

With very small or oddly sized external meta data, or with
PAGE_SIZE != 4k, it can happen that our last on-disk bitmap page
is not fully PAGE_SIZE aligned, so we may need to adjust the size
of the IO.

We used to do that with
  min_t(unsigned int, PAGE_SIZE,
last_allowed_sector - current_offset);
And for just the right diff, (unsigned int)(diff) will result in 0.

A bio of length 0 will correctly be rejected with an IO error
(and some scary WARN_ON_ONCE()) by the scsi layer.

Do the calculation properly.

Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20220622204932.196830-1-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_bitmap.c