[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 22/42] block: keep bs->total_sectors up to date even
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 22/42] block: keep bs->total_sectors up to date even for growable block devices |
Date: |
Fri, 6 Sep 2013 17:38:53 +0200 |
From: Paolo Bonzini <address@hidden>
If a BlockDriverState is growable, after every write we need to
check if bs->total_sectors might have changed. With this change,
bdrv_getlength does not need anymore a system call.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 905bf34..d9a3a7f 100644
--- a/block.c
+++ b/block.c
@@ -2739,6 +2739,9 @@ static int coroutine_fn
bdrv_co_do_writev(BlockDriverState *bs,
if (bs->wr_highest_sector < sector_num + nb_sectors - 1) {
bs->wr_highest_sector = sector_num + nb_sectors - 1;
}
+ if (bs->growable && ret >= 0) {
+ bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
+ }
tracked_request_end(&req);
@@ -2813,7 +2816,7 @@ int64_t bdrv_getlength(BlockDriverState *bs)
if (!drv)
return -ENOMEDIUM;
- if (bs->growable || bdrv_dev_has_removable_media(bs)) {
+ if (bdrv_dev_has_removable_media(bs)) {
if (drv->bdrv_getlength) {
return drv->bdrv_getlength(bs);
}
--
1.8.3.1
- [Qemu-devel] [PULL 38/42] block: add default get_block_status implementation for protocols, (continued)
- [Qemu-devel] [PULL 38/42] block: add default get_block_status implementation for protocols, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 39/42] block: look for zero blocks in bs->file, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 40/42] dataplane: Fix startup race., Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 41/42] qemu-iotests: Whitespace cleanup, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 42/42] qemu-iotests: Fixed test case 026, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 18/42] qmp: Documentation for BLOCK_IMAGE_CORRUPTED, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 20/42] cow: make writes go at a less indecent speed, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 16/42] nbd: use BlockDriverState refcnt, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 25/42] block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 26/42] block: expect errors from bdrv_co_is_allocated, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 22/42] block: keep bs->total_sectors up to date even for growable block devices,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 23/42] block: make bdrv_co_is_allocated static, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 21/42] cow: do not call bdrv_co_is_allocated, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 24/42] block: do not use ->total_sectors in bdrv_co_is_allocated, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 19/42] cow: make reads go at a decent speed, Stefan Hajnoczi, 2013/09/06
- [Qemu-devel] [PULL 17/42] block: use BDS ref for block jobs, Stefan Hajnoczi, 2013/09/06