[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] qcow2: Do not reopen data_file in invalidate_cache
From: |
Eric Blake |
Subject: |
Re: [PATCH 2/4] qcow2: Do not reopen data_file in invalidate_cache |
Date: |
Wed, 27 Apr 2022 08:20:35 -0500 |
User-agent: |
NeoMutt/20220415-26-c08bba |
On Wed, Apr 27, 2022 at 01:40:55PM +0200, Hanna Reitz wrote:
> qcow2_co_invalidate_cache() closes and opens the qcow2 file, by calling
> qcow2_close() and qcow2_do_open(). These two functions must thus be
> usable from both a global-state and an I/O context.
>
> As they are, they are not safe to call in an I/O context, because they
> use bdrv_unref_child() and bdrv_open_child() to close/open the data_file
> child, respectively, both of which are global-state functions. When
> used from qcow2_co_invalidate_cache(), we do not need to close/open the
> data_file child, though (we do not do this for bs->file or bs->backing
> either), and so we should skip it in the qcow2_co_invalidate_cache()
> path.
>
> To do so, add a parameter to qcow2_do_open() and qcow2_close() to make
> them skip handling s->data_file, and have qcow2_co_invalidate_cache()
> exempt it from the memset() on the BDRVQcow2State.
>
> (Note that the QED driver similarly closes/opens the QED image by
> invoking bdrv_qed_close()+bdrv_qed_do_open(), but both functions seem
> safe to use in an I/O context.)
>
> Fixes: https://gitlab.com/qemu-project/qemu/-/issues/945
> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
> ---
> block/qcow2.c | 104 ++++++++++++++++++++++++++++++--------------------
> 1 file changed, 62 insertions(+), 42 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- [PATCH 0/4] Revert "main-loop: Disable GLOBAL_STATE_CODE() assertions", Hanna Reitz, 2022/04/27
- [PATCH 1/4] block: Classify bdrv_get_flags() as I/O function, Hanna Reitz, 2022/04/27
- [PATCH 2/4] qcow2: Do not reopen data_file in invalidate_cache, Hanna Reitz, 2022/04/27
- [PATCH 4/4] iotests: Add regression test for issue 945, Hanna Reitz, 2022/04/27
- [PATCH 3/4] Revert "main-loop: Disable GLOBAL_STATE_CODE() assertions", Hanna Reitz, 2022/04/27
- Re: [PATCH 0/4] Revert "main-loop: Disable GLOBAL_STATE_CODE() assertions", Kevin Wolf, 2022/04/27