Re: [PATCH for-next v2 2/4] null_blk: do partial IO for bad blocks
From: Shinichiro Kawasaki <hidden>
Date: 2025-01-15 01:16:37
On Jan 06, 2025 / 14:47, Damien Le Moal wrote:
On 12/25/24 7:09 PM, Shin'ichiro Kawasaki wrote:quoted
The current null_blk implementation checks if any bad blocks exist in the target blocks of each IO. If so, the IO fails and data is not transferred for all of the IO target blocks. However, when real storage devices have bad blocks, the devices may transfer data partially up to the first bad blocks. Especially, when the IO is a write operation, such partial IO leaves partially written data on the device. To simulate such partial IO using null_blk, perform the data transfer from the IO start block to the block just before the first bad block. Introduce __null_handle_rq() to support partial data transfer. Modify null_handle_badblocks() to calculate the size of the partial data transfer and call __null_handle_rq().We should have an option to control this behavior to be able to mimic actual devices. E.g. SAS devices may do partial data transfers before hitting a bad block, but ATA devices will not (it is always all or nothing with ATA). The current default corresponds to an ATA drive behavior and this change allows emulating a SAS drive behavior. So let's control this with an option.
Thanks. Will do so in v3.