From: Christoph Hellwig Date: Tue, 15 Jun 2010 15:52:52 +0000 (+0200) Subject: block: fix physical_block_size calculation X-Git-Tag: origin_master~180 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1e297c323590d3deae46e566956cc4351e2aa5da;p=qemu-xen-unstable.git block: fix physical_block_size calculation Both SCSI and virtio expect the physical block size relative to the logical block size. So get the factor first before calculating the log2. Reported-by: Mike Cao Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- diff --git a/block_int.h b/block_int.h index e3bfd192a2..b64a0095f5 100644 --- a/block_int.h +++ b/block_int.h @@ -224,7 +224,9 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) { unsigned int exp = 0, size; - for (size = conf->physical_block_size; size > 512; size >>= 1) { + for (size = conf->physical_block_size; + size > conf->logical_block_size; + size >>= 1) { exp++; }