From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=36069 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOVQk-0001U9-7O for qemu-devel@nongnu.org; Tue, 15 Jun 2010 08:39:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOVQg-00069b-Dt for qemu-devel@nongnu.org; Tue, 15 Jun 2010 08:39:49 -0400 Received: from verein.lst.de ([213.95.11.210]:53230) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOVQf-00067Y-V8 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 08:39:46 -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 o5FCdaXt025434 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Tue, 15 Jun 2010 14:39:36 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id o5FCdaZC025433 for qemu-devel@nongnu.org; Tue, 15 Jun 2010 14:39:36 +0200 Date: Tue, 15 Jun 2010 14:39:36 +0200 From: Christoph Hellwig Message-ID: <20100615123936.GA25281@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] 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 14:30:00.164034570 +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 / conf->logical_block_size; + size > 512; + size >>= 1) { exp++; }