On 11/14/22 4:24 AM, Anastasia Kovaleva wrote: > Currently iblock always reports MAXIMUM TRANSFER LENGTH in 512b units > regardless of the LU block size. > > Target block size: > target:~ # fdisk -l /dev/nullb0 > Disk /dev/nullb0: 250 GiB, 268435456000 bytes, 65536000 sectors > Units: sectors of 1 * 4096 = 4096 bytes > Sector size (logical/physical): 4096 bytes / 4096 bytes > I/O size (minimum/optimal): 4096 bytes / 4096 bytes > > Initiator block size: > initiator:~ # fdisk -l /dev/sdc > Disk /dev/sdc: 250 GiB, 268435456000 bytes, 65536000 sectors > Disk model: nullb0 > Units: sectors of 1 * 4096 = 4096 bytes > Sector size (logical/physical): 4096 bytes / 4096 bytes > I/O size (minimum/optimal): 4096 bytes / 131072 bytes > > target max transfer length limit: > target:~ # cat /sys/block/nullb0/queue/max_hw_sectors_kb > 128 > > So the maximum transfer length should be 128 * 1024 / 4096 = 32 blocks > But the target sends MTL in 512b units, so the initiators see 256 blocks > instead. > > initiator:~ # sg_inq -p 0xb0 /dev/sdc > VPD INQUIRY: Block limits page (SBC) > Maximum compare and write length: 1 blocks > Optimal transfer length granularity: 1 blocks > Maximum transfer length: 256 blocks > Optimal transfer length: 32 blocks > Maximum prefetch transfer length: 0 blocks [ignored] > > This happens because MAXIMUM TRANSFER LENGTH field in VPD Block Limits > page is derived from dev->dev_attrib.hw_max_sectors which happens to be > in 512b units for iblock. This patch series fixes this issue and removes > some special-casing for other backstores. > > Changes since v1: > Sinse the v1 patch series, some variables was renamed, the checkpatch > script was run and issues with debug logs was fixed, some refactoring > was done. > You forgot the tabbing/spacing issue I mentioned (checkpatch --strict reports them for example). It's probably not a big enough deal to hold this up though. Reviewed-by: Mike Christie <michael.christie@xxxxxxxxxx>