[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 18/22] vmdk: implement .bdrv_detach/attach_aio_c
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH 18/22] vmdk: implement .bdrv_detach/attach_aio_context() |
Date: |
Mon, 5 May 2014 14:03:09 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Sun, May 04, 2014 at 06:17:45PM +0800, Fam Zheng wrote:
> On Thu, 05/01 16:54, Stefan Hajnoczi wrote:
> > @@ -2118,6 +2139,8 @@ static BlockDriver bdrv_vmdk = {
> > .bdrv_has_zero_init = vmdk_has_zero_init,
> > .bdrv_get_specific_info = vmdk_get_specific_info,
> > .bdrv_refresh_limits = vmdk_refresh_limits,
> > + .bdrv_detach_aio_context = vmdk_detach_aio_context,
> > + .bdrv_attach_aio_context = vmdk_attach_aio_context,
> >
> > .create_options = vmdk_create_options,
> > };
> > --
>
> I'm wondering why we need to separate detach and attach as two functions, and
> also add bdrv_set_aio_context in block.c, instead of a single
> .bdrv_set_aio_context member which is called in bdrv_set_aio_context()? The
> latter seems less code.
I can see it working either way, but here is why I chose to keep them
separate:
The detach/attach happens in two phases:
1. Parents are detached before child nodes - just in case the parent
still needs the child in order to detach.
2. The new AioContext is acquired and then children are attached before
their parent nodes - that way the parent knows it can already use its
children during attach.
Acquiring the new AioContext for the minimum amount of time (attach
only) seems like a good idea. Remember the AioContext may be
responsible for other I/O devices too so we should minimize the scope of
acquire/release.
Doing it all in a single .bdrv_set_aio_context() forces detach to happen
while the new AioContext is held.
Another reason why separate detach/attach is nice is that it allows
block drivers to avoid code duplication. .bdrv_open() calls attach()
and .bdrv_close() calls detach(). A single .bdrv_set_aio_context()
function would need extra code to deal with the open (currently not
attached) and close (don't attach to a new context) scenarios.
Stefan
- Re: [Qemu-devel] [PATCH 13/22] block/raw-posix: implement .bdrv_detach/attach_aio_context(), (continued)
- [Qemu-devel] [PATCH 17/22] ssh: use BlockDriverState's AioContext, Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 19/22] dataplane: use the QEMU block layer for I/O, Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 18/22] vmdk: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 21/22] dataplane: implement async flush, Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 16/22] sheepdog: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 20/22] dataplane: delete IOQueue since it is no longer used, Stefan Hajnoczi, 2014/05/01
- [Qemu-devel] [PATCH 22/22] raw-posix: drop raw_get_aio_fd() since it is no longer used, Stefan Hajnoczi, 2014/05/01
- Re: [Qemu-devel] [PATCH 00/22] dataplane: use QEMU block layer, Paolo Bonzini, 2014/05/02
- Re: [Qemu-devel] [PATCH 00/22] dataplane: use QEMU block layer, Christian Borntraeger, 2014/05/05