On Tue, Mar 23, 2021 at 05:22:03PM +0100, mwilck@xxxxxxxx wrote: > Avoid this by simply not resetting nr_pages to 0 after allocating the > bio. This way, the client receives an IO error when it tries to send > requests exceeding the devices max_sectors_kb, and eventually gets > it right. The client must still limit max_sectors_kb e.g. by an udev > rule if (like in my case) the driver doesn't report valid block > limits, otherwise it encounters I/O errors. FYI, I think the what you did here is correct, but not enough. When pscsi_get_bio (that is bio_kmalloc) fails, this function needs to unwind and return an error insted of blindly retrying the allocation, else we can't recover from a memory shortage.