Ekaterina Tumanova <tuman...@linux.vnet.ibm.com> writes: > On 12/15/2014 04:50 PM, Markus Armbruster wrote: >> Ekaterina Tumanova <tuman...@linux.vnet.ibm.com> writes: >> >>> geometry: hd_geometry_guess function autodetects the drive geometry. >>> This patch adds a block backend call, that probes the backing device >>> geometry. If the inner driver method is implemented and succeeds >>> (currently only for DASDs), the blkconf_geometry will pass-through >>> the backing device geometry. Otherwise will fallback to old logic. >>> >>> blocksize: This patch initializes blocksize properties to 0. >>> In order to set the properly a blkconf_blocksizes was introduced. >>> If user didn't set physical or logical blocksize, it will >>> retrieve it's value from a driver (which will return a default 512 for >>> any backend but DASD). >>> >>> The blkconf_blocksizes call was added to all users of BlkConf. >>> >>> Signed-off-by: Ekaterina Tumanova <tuman...@linux.vnet.ibm.com> >>> --- >>> hw/block/block.c | 18 ++++++++++++++++++ >>> hw/block/hd-geometry.c | 12 ++++++++++++ >>> hw/block/nvme.c | 1 + >>> hw/block/virtio-blk.c | 1 + >>> hw/core/qdev-properties.c | 3 ++- >>> hw/ide/qdev.c | 1 + >>> hw/scsi/scsi-disk.c | 1 + >>> hw/usb/dev-storage.c | 1 + >>> include/hw/block/block.h | 5 +++-- >>> 9 files changed, 40 insertions(+), 3 deletions(-) >>> >>> diff --git a/hw/block/block.c b/hw/block/block.c >>> index a625773..9c07516 100644 >>> --- a/hw/block/block.c >>> +++ b/hw/block/block.c >>> @@ -25,6 +25,24 @@ void blkconf_serial(BlockConf *conf, char **serial) >>> } >>> } >>> >>> +void blkconf_blocksizes(BlockConf *conf) >>> +{ >>> + BlockBackend *blk = conf->blk; >>> + BlockSizes blocksizes; >>> + >>> + if (conf->physical_block_size && conf->logical_block_size) { >>> + return; >>> + } >> >> This conditional isn't necessary for correctness. Feel free to drop it. >> > > But this allows to avoid the ioctl call when user has specified both > values. Remove anyway?
It's device model setup, i.e. not a fast path. I'd favor simplicity and compactness over speed there. >>> + blk_probe_blocksizes(blk, &blocksizes); >>> + >>> + if (!conf->physical_block_size) { >>> + conf->physical_block_size = blocksizes.phys; >>> + } >>> + if (!conf->logical_block_size) { >>> + conf->logical_block_size = blocksizes.log; >>> + } >> > > I'll add a comment to make it apparent. > >> This works because you change the default block size to 0 (second to >> last hunk). >> >>> +} >>> + >>> void blkconf_geometry(BlockConf *conf, int *ptrans, >>> unsigned cyls_max, unsigned heads_max, unsigned >>> secs_max, >>> Error **errp) [...]