mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-01-06 14:37:42 -07:00
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> |
||
|---|---|---|
| .. | ||
| backup.c | ||
| blkdebug.c | ||
| blkverify.c | ||
| bochs.c | ||
| cloop.c | ||
| commit.c | ||
| cow.c | ||
| curl.c | ||
| dmg.c | ||
| gluster.c | ||
| iscsi.c | ||
| linux-aio.c | ||
| Makefile.objs | ||
| mirror.c | ||
| nbd.c | ||
| parallels.c | ||
| qapi.c | ||
| qcow.c | ||
| qcow2-cache.c | ||
| qcow2-cluster.c | ||
| qcow2-refcount.c | ||
| qcow2-snapshot.c | ||
| qcow2.c | ||
| qcow2.h | ||
| qed-check.c | ||
| qed-cluster.c | ||
| qed-gencb.c | ||
| qed-l2-cache.c | ||
| qed-table.c | ||
| qed.c | ||
| qed.h | ||
| raw-aio.h | ||
| raw-posix.c | ||
| raw-win32.c | ||
| raw_bsd.c | ||
| rbd.c | ||
| sheepdog.c | ||
| snapshot.c | ||
| ssh.c | ||
| stream.c | ||
| vdi.c | ||
| vhdx.c | ||
| vhdx.h | ||
| vmdk.c | ||
| vpc.c | ||
| vvfat.c | ||
| win32-aio.c | ||