Message ID | 1432896805-23867-4-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
On 29/05/2015 12:53, Fam Zheng wrote: > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > 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); > } >
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; } 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); + } if (state->aio_context) { aio_context_release(state->aio_context); }
Signed-off-by: Fam Zheng <famz@redhat.com> --- blockdev.c | 6 ++++++ 1 file changed, 6 insertions(+)