Patchwork [v2] block: fix physical_block_size calculation

login
register
mail settings
Submitter Christoph Hellwig
Date June 15, 2010, 3:52 p.m.
Message ID <20100615155252.GB2364@lst.de>
Download mbox | patch
Permalink /patch/55733/
State New
Headers show

Comments

Christoph Hellwig - June 15, 2010, 3:52 p.m.
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 <bcao@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Kevin Wolf - June 16, 2010, 2:57 p.m.
Am 15.06.2010 17:52, schrieb Christoph Hellwig:
> 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 <bcao@redhat.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

This one looks better. Fixed whitespace errors and applied to the block
branch.

Kevin

Patch

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++;
     }