From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43246 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OR4Ag-0005dz-TU for qemu-devel@nongnu.org; Tue, 22 Jun 2010 10:09:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OR4Af-0007aI-0t for qemu-devel@nongnu.org; Tue, 22 Jun 2010 10:09:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12588) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OR4Ae-0007a5-QR for qemu-devel@nongnu.org; Tue, 22 Jun 2010 10:09:48 -0400 From: Kevin Wolf Date: Tue, 22 Jun 2010 16:09:22 +0200 Message-Id: <1277215773-27357-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1277215773-27357-1-git-send-email-kwolf@redhat.com> References: <1277215773-27357-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 03/14] block: fix physical_block_size calculation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- block_int.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) 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++; } -- 1.6.6.1