From patchwork Tue Jun 15 15:52:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2] block: fix physical_block_size calculation X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 55733 Message-Id: <20100615155252.GB2364@lst.de> To: qemu-devel@nongnu.org Date: Tue, 15 Jun 2010 17:52:52 +0200 From: Christoph Hellwig List-Id: qemu-devel.nongnu.org 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 Index: qemu/block_int.h =================================================================== --- qemu.orig/block_int.h 2010-06-15 14:29:42.593012221 +0200 +++ qemu/block_int.h 2010-06-15 17:48:55.428255620 +0200 @@ -223,7 +223,9 @@ static inline unsigned int get_physical_ { 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++; }