block/export: don't require AioContext lock around blk_exp_ref/unref()

The FUSE export calls blk_exp_ref/unref() without the AioContext lock.
Instead of fixing the FUSE export, adjust blk_exp_ref/unref() so they
work without the AioContext lock. This way it's less error-prone.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230516190238.8401-15-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2023-05-16 15:02:32 -04:00 committed by Kevin Wolf
parent 195332c1d9
commit 3d499a43a2
3 changed files with 8 additions and 11 deletions

View file

@ -44,9 +44,7 @@ static void vduse_blk_inflight_inc(VduseBlkExport *vblk_exp)
{
if (qatomic_fetch_inc(&vblk_exp->inflight) == 0) {
/* Prevent export from being deleted */
aio_context_acquire(vblk_exp->export.ctx);
blk_exp_ref(&vblk_exp->export);
aio_context_release(vblk_exp->export.ctx);
}
}
@ -57,9 +55,7 @@ static void vduse_blk_inflight_dec(VduseBlkExport *vblk_exp)
aio_wait_kick();
/* Now the export can be deleted */
aio_context_acquire(vblk_exp->export.ctx);
blk_exp_unref(&vblk_exp->export);
aio_context_release(vblk_exp->export.ctx);
}
}