mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:10 +00:00
fuse: Introduce fuse_{inc,dec}_in_flight()
This is how vduse-blk.c does it, and it does seem better to have dedicated functions for it. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Hanna Czenczek <hreitz@redhat.com> Message-ID: <20260309150856.26800-11-hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
committed by
Kevin Wolf
parent
4a8527e836
commit
7e38c36558
@@ -78,6 +78,25 @@ static void read_from_fuse_export(void *opaque);
|
||||
static bool is_regular_file(const char *path, Error **errp);
|
||||
|
||||
|
||||
static void fuse_inc_in_flight(FuseExport *exp)
|
||||
{
|
||||
if (qatomic_fetch_inc(&exp->in_flight) == 0) {
|
||||
/* Prevent export from being deleted */
|
||||
blk_exp_ref(&exp->common);
|
||||
}
|
||||
}
|
||||
|
||||
static void fuse_dec_in_flight(FuseExport *exp)
|
||||
{
|
||||
if (qatomic_fetch_dec(&exp->in_flight) == 1) {
|
||||
/* Wake AIO_WAIT_WHILE() */
|
||||
aio_wait_kick();
|
||||
|
||||
/* Now the export can be deleted */
|
||||
blk_exp_unref(&exp->common);
|
||||
}
|
||||
}
|
||||
|
||||
static void fuse_attach_handlers(FuseExport *exp)
|
||||
{
|
||||
aio_set_fd_handler(exp->common.ctx,
|
||||
@@ -303,9 +322,7 @@ static void read_from_fuse_export(void *opaque)
|
||||
FuseExport *exp = opaque;
|
||||
int ret;
|
||||
|
||||
blk_exp_ref(&exp->common);
|
||||
|
||||
qatomic_inc(&exp->in_flight);
|
||||
fuse_inc_in_flight(exp);
|
||||
|
||||
do {
|
||||
ret = fuse_session_receive_buf(exp->fuse_session, &exp->fuse_buf);
|
||||
@@ -323,11 +340,7 @@ static void read_from_fuse_export(void *opaque)
|
||||
fuse_session_process_buf(exp->fuse_session, &exp->fuse_buf);
|
||||
|
||||
out:
|
||||
if (qatomic_fetch_dec(&exp->in_flight) == 1) {
|
||||
aio_wait_kick(); /* wake AIO_WAIT_WHILE() */
|
||||
}
|
||||
|
||||
blk_exp_unref(&exp->common);
|
||||
fuse_dec_in_flight(exp);
|
||||
}
|
||||
|
||||
static void fuse_export_shutdown(BlockExport *blk_exp)
|
||||
|
||||
Reference in New Issue
Block a user