Patchwork [03/14] block: fix physical_block_size calculation

login
register
mail settings
Submitter Kevin Wolf
Date June 22, 2010, 2:09 p.m.
Message ID <1277215773-27357-4-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/56508/
State New
Headers show

Comments

Kevin Wolf - June 22, 2010, 2:09 p.m.
From: Christoph Hellwig <hch@lst.de>

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>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block_int.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Patch

diff --git a/block_int.h b/block_int.h
index e3bfd19..b64a009 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++;
     }