qemu-patch-raspberry4/include
Kevin Wolf b94a261057 block: Avoid unecessary drv->bdrv_getlength() calls
The block layer generally keeps the size of an image cached in
bs->total_sectors so that it doesn't have to perform expensive
operations to get the size whenever it needs it.

This doesn't work however when using a backend that can change its size
without qemu being aware of it, i.e. passthrough of removable media like
CD-ROMs or floppy disks. For this reason, the caching is disabled when a
removable device is used.

It is obvious that checking whether the _guest_ device has removable
media isn't the right thing to do when we want to know whether the size
of the host backend can change. To make things worse, non-top-level
BlockDriverStates never have any device attached, which makes qemu
assume they are removable, so drv->bdrv_getlength() is always called on
the protocol layer. In the case of raw-posix, this causes unnecessary
lseek() system calls, which turned out to be rather expensive.

This patch completely changes the logic and disables bs->total_sectors
caching only for certain block driver types, for which a size change is
expected: host_cdrom and host_floppy on POSIX, host_device on win32; also
the raw format in case it sits on top of one of these protocols, but in
the common case the nested bdrv_getlength() call on the protocol driver
will use the cache again and avoid an expensive drv->bdrv_getlength()
call.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2013-10-29 13:10:26 +01:00
..
block block: Avoid unecessary drv->bdrv_getlength() calls 2013-10-29 13:10:26 +01:00
disas Add moxie disassembler 2013-03-23 14:25:41 +00:00
exec portio: Allow to mark portio lists as coalesced MMIO flushing 2013-10-17 17:24:15 +02:00
fpu softfloat: Implement uint64_to_float128 2013-01-05 10:12:50 +00:00
hw Mostly revert "qemu-help: Sort devices by logical functionality" 2013-10-11 09:36:29 -07:00
migration migration: add version supporting macros for struct pointer 2013-09-24 13:22:50 +02:00
monitor Merge remote-tracking branch 'kwolf/for-anthony' into staging 2013-09-03 12:32:46 -05:00
net net: Rename send_queue to incoming_queue 2013-09-06 17:01:26 +02:00
qapi qemu-ga: Extend 'guest-info' command to expose flag 'success-response' 2013-10-10 14:52:37 -05:00
qemu timer: add timer_mod_anticipate and timer_mod_anticipate_ns 2013-10-17 17:31:00 +02:00
qom QOM CPUState refactorings / X86CPU 2013-09-03 12:33:32 -05:00
sysemu blockdev: Introduce DriveInfo.enable_auto_del 2013-10-11 16:50:01 +02:00
ui spice: fix multihead support 2013-10-17 12:42:54 +02:00
config.h janitor: move remaining public headers to include/ 2012-12-19 08:32:46 +01:00
elf.h s390: Implement dump-guest-memory support for target s390x 2013-07-30 16:12:25 +02:00
glib-compat.h glib: add a compatibility interface for g_timeout_add_seconds 2013-03-25 13:10:40 -05:00
qemu-common.h qmp: add interface blockdev-snapshot-delete-internal-sync 2013-09-12 10:12:47 +02:00
qemu-io.h qemu-io: Interface cleanup 2013-06-06 11:27:05 +02:00
trace.h build: some simplifications for "trace/Makefile.objs" 2013-01-12 18:42:51 +01:00