From 1e297c323590d3deae46e566956cc4351e2aa5da Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 15 Jun 2010 17:52:52 +0200 Subject: [PATCH] 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 --- block_int.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block_int.h b/block_int.h index e3bfd192a..b64a0095f 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++; } -- 2.39.2