fuse: Introduce fuse_{at,de}tach_handlers()
Pull setting up and tearing down the AIO context handlers into two dedicated functions. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Hanna Czenczek <hreitz@redhat.com> Message-ID: <20260309150856.26800-10-hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Hanna Czenczek committed
Mar 9, 2026 at 16:08 UTC
4a8527e83699733a588f2f64ab26408edbfe0d89
1 file changed
+16
-16
block/export/fuse.c
+16
-16
@@ -78,27 +78,34 @@ static void read_from_fuse_export(void *opaque);
78
static bool is_regular_file(const char *path, Error **errp);
79
80
81
-static void fuse_export_drained_begin(void *opaque)
81
+static void fuse_attach_handlers(FuseExport *exp)
82
{
83
- FuseExport *exp = opaque;
83
+ aio_set_fd_handler(exp->common.ctx,
84
+ fuse_session_fd(exp->fuse_session),
85
+ read_from_fuse_export, NULL, NULL, NULL, exp);
86
+ exp->fd_handler_set_up = true;
87
+}
88
89
+static void fuse_detach_handlers(FuseExport *exp)
90
+{
91
aio_set_fd_handler(exp->common.ctx,
92
fuse_session_fd(exp->fuse_session),
93
NULL, NULL, NULL, NULL, NULL);
94
exp->fd_handler_set_up = false;
95
}
96
97
+static void fuse_export_drained_begin(void *opaque)
98
+{
99
+ fuse_detach_handlers(opaque);
100
+}
101
+
102
static void fuse_export_drained_end(void *opaque)
103
{
104
FuseExport *exp = opaque;
105
106
/* Refresh AioContext in case it changed */
107
exp->common.ctx = blk_get_aio_context(exp->common.blk);
97
-
98
- aio_set_fd_handler(exp->common.ctx,
99
- fuse_session_fd(exp->fuse_session),
100
- read_from_fuse_export, NULL, NULL, NULL, exp);
101
- exp->fd_handler_set_up = true;
108
+ fuse_attach_handlers(exp);
109
}
110
111
static bool fuse_export_drained_poll(void *opaque)
@@ -209,11 +216,7 @@ static int fuse_export_create(BlockExport *blk_exp,
216
217
g_hash_table_insert(exports, g_strdup(exp->mountpoint), NULL);
218
212
- aio_set_fd_handler(exp->common.ctx,
213
- fuse_session_fd(exp->fuse_session),
214
- read_from_fuse_export, NULL, NULL, NULL, exp);
215
- exp->fd_handler_set_up = true;
216
-
219
+ fuse_attach_handlers(exp);
220
return 0;
221
222
fail:
@@ -335,10 +338,7 @@ static void fuse_export_shutdown(BlockExport *blk_exp)
338
fuse_session_exit(exp->fuse_session);
339
340
if (exp->fd_handler_set_up) {
338
- aio_set_fd_handler(exp->common.ctx,
339
- fuse_session_fd(exp->fuse_session),
340
- NULL, NULL, NULL, NULL, NULL);
341
- exp->fd_handler_set_up = false;
341
+ fuse_detach_handlers(exp);
342
}
343
}
344