From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=37496 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOYZB-0005qL-5p for qemu-devel@nongnu.org; Tue, 15 Jun 2010 12:00:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOYRZ-0000Qr-F9 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 11:52:54 -0400 Received: from verein.lst.de ([213.95.11.210]:60556) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOYRZ-0000Qf-3d for qemu-devel@nongnu.org; Tue, 15 Jun 2010 11:52:53 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id o5FFqqXt002469 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 15 Jun 2010 17:52:52 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o5FFqqUn002468 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 17:52:52 +0200 Date: Tue, 15 Jun 2010 17:52:52 +0200 From: Christoph Hellwig Message-ID: <20100615155252.GB2364@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH v2] block: fix physical_block_size calculation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 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++; }