[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/21] preallocate: Don't poll during permission updates
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH 03/21] preallocate: Don't poll during permission updates |
Date: |
Tue, 22 Aug 2023 14:41:34 -0400 |
On Thu, Aug 17, 2023 at 02:50:02PM +0200, Kevin Wolf wrote:
> When the permission related BlockDriver callbacks are called, we are in
> the middle of an operation traversing the block graph. Polling in such a
> place is a very bad idea because the graph could change in unexpected
> ways. In the future, callers will also hold the graph lock, which is
> likely to turn polling into a deadlock.
>
> So we need to get rid of calls to functions like bdrv_getlength() or
> bdrv_truncate() there as these functions poll internally. They are
> currently used so that when no parent has write/resize permissions on
> the image any more, the preallocate filter drops the extra preallocated
> area in the image file and gives up write/resize permissions itself.
>
> In order to achieve this without polling in .bdrv_check_perm, don't
> immediately truncate the image, but only schedule a BH to do so. The
> filter keeps the write/resize permissions a bit longer now until the BH
> has executed.
>
> There is one case in which delaying doesn't work: Reopening the image
> read-only. In this case, bs->file will likely be reopened read-only,
> too, so keeping write permissions a bit longer on it doesn't work. But
> we can already cover this case in preallocate_reopen_prepare() and not
> rely on the permission updates for it.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/preallocate.c | 89 +++++++++++++++++++++++++++++++++++----------
> 1 file changed, 69 insertions(+), 20 deletions(-)
I don't know the permissions code well enough, but the patch matches the
commit description:
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
signature.asc
Description: PGP signature
- [PATCH 06/21] block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions, (continued)
- [PATCH 06/21] block-coroutine-wrapper: Add no_co_wrapper_bdrv_wrlock functions, Kevin Wolf, 2023/08/17
- [PATCH 09/21] block: Mark bdrv_replace_child_tran() GRAPH_WRLOCK, Kevin Wolf, 2023/08/17
- [PATCH 11/21] block: Call transaction callbacks with lock held, Kevin Wolf, 2023/08/17
- [PATCH 03/21] preallocate: Don't poll during permission updates, Kevin Wolf, 2023/08/17
- [PATCH 02/21] preallocate: Factor out preallocate_truncate_to_real_size(), Kevin Wolf, 2023/08/17
- [PATCH 07/21] block-coroutine-wrapper: Allow arbitrary parameter names, Kevin Wolf, 2023/08/17
- [PATCH 15/21] block: Mark bdrv_child_perm() GRAPH_RDLOCK, Kevin Wolf, 2023/08/17