file-posix: try BLKSECTGET on block devices too, do not round to power of 2
commit18473467d55a20d643b6c9b3a52de42f705b4d35
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 14 Apr 2021 17:52:26 +0000 (14 19:52 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Jun 2021 08:54:13 +0000 (25 10:54 +0200)
treec24a98cb7bafaacc30695d5d274df0de24433547
parent24b36e9813ec15da7db62e3b3621730710c5f020
file-posix: try BLKSECTGET on block devices too, do not round to power of 2

bs->sg is only true for character devices, but block devices can also
be used with scsi-block and scsi-generic.  Unfortunately BLKSECTGET
returns bytes in an int for /dev/sgN devices, and sectors in a short
for block devices, so account for that in the code.

The maximum transfer also need not be a power of 2 (for example I have
seen disks with 1280 KiB maximum transfer) so there's no need to pass
the result through pow2floor.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block/file-posix.c