From c9f6856ded10602147ca1d1806e7afb545430fd9 Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Tue, 17 Nov 2015 20:02:58 +0300 Subject: [PATCH 1/2] parallels: dirty BAT properly for continuous allocations This patch marks part of the BAT dirty properly. There is a possibility that multy-block allocation could have one block allocated on one BAT page and next block on the next page. The code without the patch could not save updated position to the file. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Denis V. Lunev Message-id: 1447779778-26062-1-git-send-email-den@openvz.org CC: Stefan Hajnoczi Signed-off-by: Stefan Hajnoczi --- block/parallels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 4f79293826..f689fdeaff 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -220,7 +220,7 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, s->bat_bitmap[idx + i] = cpu_to_le32(s->data_end / s->off_multiplier); s->data_end += s->tracks; bitmap_set(s->bat_dirty_bmap, - bat_entry_off(idx) / s->bat_dirty_block, 1); + bat_entry_off(idx + i) / s->bat_dirty_block, 1); } return bat2sect(s, idx) + sector_num % s->tracks; From 466138dc689b6b14f31d5d20316affb4b4efd177 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Mon, 23 Nov 2015 08:41:20 +0800 Subject: [PATCH 2/2] virtio-blk: Move resetting of req->mr_next to virtio_blk_handle_rw_error "werror=report" would free the req in virtio_blk_handle_rw_error, we mustn't write to it in that case. Reported-by: Paolo Bonzini Signed-off-by: Fam Zheng Message-id: 1448239280-15025-1-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 848f3fe3e1..756ae5ce63 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -72,6 +72,9 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, VirtIOBlock *s = req->dev; if (action == BLOCK_ERROR_ACTION_STOP) { + /* Break the link as the next request is going to be parsed from the + * ring again. Otherwise we may end up doing a double completion! */ + req->mr_next = NULL; req->next = s->rq; s->rq = req; } else if (action == BLOCK_ERROR_ACTION_REPORT) { @@ -112,10 +115,6 @@ static void virtio_blk_rw_complete(void *opaque, int ret) * happen on the other side of the migration). */ if (virtio_blk_handle_rw_error(req, -ret, is_read)) { - /* Break the link in case the next request is added to the - * restart queue and is going to be parsed from the ring again. - */ - req->mr_next = NULL; continue; } }