Re: [PATCH v2 3/4] block: remember the writability a reopen starts from

Andrey Drobyshev <[email protected]>
Newsgroups org.nongnu.qemu-devel
Message-ID <[email protected]>
On 8/11/26 6:42 PM, Denis V. Lunev wrote:
> bdrv_reopen_commit() updates bs->open_flags, so by the time
> .bdrv_reopen_commit_post() runs a driver can no longer tell whether
> the node has just become writable or was writable all along. Only the
> transition is worth reacting to.
> 
> Record the value while the queue is built, next to the other
> pre-reopen state BDRVReopenState already keeps.
> 
> Signed-off-by: Denis V. Lunev <[email protected]>
> CC: Kevin Wolf <[email protected]>
> CC: Hanna Reitz <[email protected]>
> CC: Andrey Drobyshev <[email protected]>
> Cc: [email protected]
> ---
>  block.c                      | 1 +
>  include/block/block-common.h | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 99ed06f8ca..c50d9474fc 100644
> --- a/block.c
> +++ b/block.c
> @@ -4473,6 +4473,7 @@ bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, BlockDriverState *bs,
>      bs_entry->state.options = options;
>      bs_entry->state.explicit_options = explicit_options;
>      bs_entry->state.flags = flags;
> +    bs_entry->state.was_writable = bdrv_is_writable(bs);
>  
>      /*
>       * If keep_old_opts is false then it means that unspecified
> diff --git a/include/block/block-common.h b/include/block/block-common.h
> index 895ea17541..f64b2d6f35 100644
> --- a/include/block/block-common.h
> +++ b/include/block/block-common.h
> @@ -360,6 +360,7 @@ typedef struct BDRVReopenState {
>      int flags;
>      BlockdevDetectZeroesOptions detect_zeroes;
>      bool backing_missing;
> +    bool was_writable; /* bs->open_flags is updated on commit */
>      BlockDriverState *old_backing_bs; /* keep pointer for permissions update */
>      BlockDriverState *old_file_bs; /* keep pointer for permissions update */
>      QDict *options;

If we start tracking pre-reopen flags state, wouldn't it be better to
just save 'int old_flags'?  Otherwise, once we have an urge to track
smth else besides writeability - we'll need to waste another struct field.

Andrey
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.