From 8cfacf079047c50d272ce64e45a78d816db8b36e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 4 Mar 2010 14:20:17 +0100 Subject: block: add logical_block_size property Add a logical block size attribute as various guest side tools only increase the filesystem sector size based on it, not the advisory physical block size. For scsi we already have support for a different logical block size in place for CDROMs that we can built upon. Only my recent block device characteristics VPD page needs some fixups. Note that we leave the logial block size for CDROMs hardcoded as the 2k value is expected for it in general. For virtio-blk we already have a feature flag claiming to support a variable logical block size that was added for the s390 kuli hypervisor. Interestingly it does not actually change the units in which the protocol works, which is still fixed at 512 bytes, but only communicates a different minimum I/O granularity. So all we need to do in virtio is to add a trap for unaligned I/O and round down the device size to the next multiple of the logical block size. IDE does not support any other logical block size than 512 bytes. Signed-off-by: Christoph Hellwig Signed-off-by: Anthony Liguori --- block_int.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'block_int.h') diff --git a/block_int.h b/block_int.h index 50e1a0b770..71b633b788 100644 --- a/block_int.h +++ b/block_int.h @@ -209,6 +209,7 @@ struct DriveInfo; typedef struct BlockConf { struct DriveInfo *dinfo; uint16_t physical_block_size; + uint16_t logical_block_size; uint16_t min_io_size; uint32_t opt_io_size; } BlockConf; @@ -226,6 +227,8 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) #define DEFINE_BLOCK_PROPERTIES(_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.dinfo), \ + DEFINE_PROP_UINT16("logical_block_size", _state, \ + _conf.logical_block_size, 512), \ DEFINE_PROP_UINT16("physical_block_size", _state, \ _conf.physical_block_size, 512), \ DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 512), \ -- cgit v1.2.3