* [Qemu-devel] [PATCH] block: fix physical_block_size calculation
@ 2010-06-15 12:39 Christoph Hellwig
2010-06-15 13:48 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2010-06-15 12:39 UTC (permalink / raw)
To: qemu-devel
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>
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++;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: fix physical_block_size calculation
2010-06-15 12:39 [Qemu-devel] [PATCH] block: fix physical_block_size calculation Christoph Hellwig
@ 2010-06-15 13:48 ` Kevin Wolf
2010-06-15 15:52 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2010-06-15 13:48 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: qemu-devel
Am 15.06.2010 14:39, schrieb 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 <bcao@redhat.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> 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;
512 looks wrong now that size is the number of logical blocks.
Kevin
> + size >>= 1) {
> exp++;
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: fix physical_block_size calculation
2010-06-15 13:48 ` Kevin Wolf
@ 2010-06-15 15:52 ` Christoph Hellwig
0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2010-06-15 15:52 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Christoph Hellwig, qemu-devel
> 512 looks wrong now that size is the number of logical blocks.
The patch is entirely wrong, and only happen to work for the case
I was testing by accident. I'll resend a fixed version after I
created a little userspace test harness for all useful values.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-15 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-15 12:39 [Qemu-devel] [PATCH] block: fix physical_block_size calculation Christoph Hellwig
2010-06-15 13:48 ` Kevin Wolf
2010-06-15 15:52 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).