qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC PATCH 03/12] blockdev: Lock BDS during internal sn


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [RFC PATCH 03/12] blockdev: Lock BDS during internal snapshot transaction
Date: Fri, 29 May 2015 13:39:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0


On 29/05/2015 12:53, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  blockdev.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 5eaf77e..46f8d60 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1262,6 +1262,7 @@ typedef struct InternalSnapshotState {
>      BlockDriverState *bs;
>      AioContext *aio_context;
>      QEMUSnapshotInfo sn;
> +    bool needs_unlock;

No need for needs_unlock...

>  } InternalSnapshotState;
>  
>  static void internal_snapshot_prepare(BlkTransactionState *common,
> @@ -1356,6 +1357,8 @@ static void 
> internal_snapshot_prepare(BlkTransactionState *common,
>      }
>  
>      /* 4. succeed, mark a snapshot is created */
> +    bdrv_lock(bs);
> +    state->needs_unlock = true;
>      state->bs = bs;
>  }
>  
> @@ -1387,6 +1390,9 @@ static void internal_snapshot_clean(BlkTransactionState 
> *common)
>      InternalSnapshotState *state = DO_UPCAST(InternalSnapshotState,
>                                               common, common);
>  
> +    if (state->needs_unlock) {
> +        bdrv_unlock(state->bs);
> +    }

... you can use state->bs != NULL here.

Paolo

>      if (state->aio_context) {
>          aio_context_release(state->aio_context);
>      }
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]