[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] block: clear dirty bitmap when discarding
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 7/7] block: clear dirty bitmap when discarding |
Date: |
Mon, 14 Jan 2013 16:26:58 +0100 |
Note that resetting bits in the dirty bitmap is done _before_ actually
processing the request. Writes, instead, set bits after the request
is completed.
This way, when there are concurrent write and discard requests, the
outcome will always be that the blocks are marked dirty. This scenario
should never happen, but it is safer to do it this way.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index b5e64ec..ffcc9e6 100644
--- a/block.c
+++ b/block.c
@@ -4174,7 +4174,13 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs,
int64_t sector_num,
return -EIO;
} else if (bs->read_only) {
return -EROFS;
- } else if (bs->drv->bdrv_co_discard) {
+ }
+
+ if (bs->dirty_bitmap) {
+ set_dirty_bitmap(bs, sector_num, nb_sectors, 0);
+ }
+
+ if (bs->drv->bdrv_co_discard) {
return bs->drv->bdrv_co_discard(bs, sector_num, nb_sectors);
} else if (bs->drv->bdrv_aio_discard) {
BlockDriverAIOCB *acb;
--
1.8.1
- [Qemu-devel] [PATCH resend 0/7] Discard improvements, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 1/7] raw-posix: support discard on more filesystems, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 2/7] raw-posix: remember whether discard failed, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 3/7] raw: support discard on block devices, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 4/7] block: make discard asynchronous, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 5/7] ide: fix TRIM with empty range entry, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 6/7] ide: issue discard asynchronously but serialize the pieces, Paolo Bonzini, 2013/01/14
- [Qemu-devel] [PATCH 7/7] block: clear dirty bitmap when discarding,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH resend 0/7] Discard improvements, Stefan Hajnoczi, 2013/01/15