Skip to contentSkip to conversation

commit: Fix commit_top_bs problems

PATCH In review Kevin Wolf 3 participants 6 messages Apr 6, 2017 – Apr 7, 2017 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover commit: Fix commit_top_bs problems

The same problem that Fam's patch "mirror: Fix aio context of mirror_top_bs" fixes for the mirror block job also exists for the commit block job and the 'commit' HMP command. While comparing the respective places in mirror.c and commit.c, I also noticed that commit neglects to set an image size.

This series fixes both problems.

Kevin Wolf (2):
commit: Set commit_top_bs->aio_context
commit: Set commit_top_bs->total_sectors

 block/commit.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 commit: Set commit_top_bs->aio_context

The filter driver that is inserted by the commit job needs to use the same AioContext as its parent and child nodes.

---
 block/commit.c | 2 ++
 1 file changed, 2 insertions(+)
block/commit.c +2 -0
index 2832482..4c38220 100644
@@ -335,6 +335,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
     if (commit_top_bs == NULL) {
         goto fail;
     }
+    bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top));
 
     bdrv_set_backing_hd(commit_top_bs, top, &local_err);
     if (local_err) {
@@ -482,6 +483,7 @@ int bdrv_commit(BlockDriverState *bs)
         error_report_err(local_err);
         goto ro_cleanup;
     }
+    bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(backing_file_bs));
 
     bdrv_set_backing_hd(commit_top_bs, backing_file_bs, &error_abort);
     bdrv_set_backing_hd(bs, commit_top_bs, &error_abort);
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 2/2 commit: Set commit_top_bs->total_sectors

In reply to Kevin Wolf

Like in the mirror filter driver, we also need to set the image size for the commit filter driver. This is less likely to be a problem in practice than for the mirror because we're not at the active layer here, but attaching new parents to a node in the middle of the chain is possible, so the size needs to be correct anyway.

---
 block/commit.c | 1 +
 1 file changed, 1 insertion(+)
block/commit.c +1 -0
index 4c38220..91d2c34 100644
@@ -335,6 +335,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
     if (commit_top_bs == NULL) {
         goto fail;
     }
+    commit_top_bs->total_sectors = top->total_sectors;
     bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top));
 
     bdrv_set_backing_hd(commit_top_bs, top, &local_err);
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.9 1/2] commit: Set commit_top_bs->aio_context

In reply to Kevin Wolf
Quoted 8 lines · Kevin Wolf

The filter driver that is inserted by the commit job needs to use the same AioContext as its parent and child nodes.

---
 block/commit.c | 2 ++
 1 file changed, 2 insertions(+)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH for-2.9 2/2] commit: Set commit_top_bs->total_sectors

In reply to Kevin Wolf
Quoted 10 lines · Kevin Wolf

Like in the mirror filter driver, we also need to set the image size for the commit filter driver. This is less likely to be a problem in practice than for the mirror because we're not at the active layer here, but attaching new parents to a node in the middle of the chain is possible, so the size needs to be correct anyway.

---
 block/commit.c | 1 +
 1 file changed, 1 insertion(+)

block/commit.c void commit_start(const char *job_id, BlockDriverState *bs, · line 338

Quoted 10 lines
block/commit.c +1 -0
index 4c38220..91d2c34 100644
@@ -335,6 +335,7 @@ void commit_start(const char *job_id, BlockDriverState *bs,
     if (commit_top_bs == NULL) {
         goto fail;
     }
+    commit_top_bs->total_sectors = top->total_sectors;

[I'd really like to change total_sectors to bytes in 2.10 or later, but that's a much hairier mess to untangle. I've got some patches that I hope to post soon that at least start the process with regards to bdrv_is_allocated...]

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on the v1 series
#5 lore raw
In reply to Kevin Wolf
Quoted 6 lines · Kevin Wolf

The same problem that Fam's patch "mirror: Fix aio context of mirror_top_bs" fixes for the mirror block job also exists for the commit block job and the 'commit' HMP command. While comparing the respective places in mirror.c and commit.c, I also noticed that commit neglects to set an image size.

Quoted 12 lines

This series fixes both problems.

Kevin Wolf (2):
commit: Set commit_top_bs->aio_context
commit: Set commit_top_bs->total_sectors

 block/commit.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
1.8.3.1