53
unsigned int in_flight; /* atomic */
54
bool mounted, fd_handler_set_up;
55
56
+ /*
57
+ * Set when there was an unrecoverable error and no requests should be read
58
+ * from the device anymore (basically only in case of something we would
59
+ * consider a kernel bug). Access atomically.
60
+ */
61
+ bool halted;
62
+
63
char *mountpoint;
64
bool writable;
65
bool growable;
76
77
static void fuse_export_shutdown(BlockExport *exp);
78
static void fuse_export_delete(BlockExport *exp);
79
+static void fuse_export_halt(FuseExport *exp) G_GNUC_UNUSED;
80
81
static void init_exports_table(void);
82
107
108
static void fuse_attach_handlers(FuseExport *exp)
109
{
110
+ if (qatomic_read(&exp->halted)) {
111
+ return;
112
+ }
113
+
114
aio_set_fd_handler(exp->common.ctx,
115
fuse_session_fd(exp->fuse_session),
116
read_from_fuse_export, NULL, NULL, NULL, exp);
334
FuseExport *exp = opaque;
335
int ret;
336
337
+ if (unlikely(qatomic_read(&exp->halted))) {
338
+ return;
339
+ }
340
+
341
fuse_inc_in_flight(exp);
342
343
do {
396
g_free(exp->mountpoint);
397
}
398
399
+/**
400
+ * Halt the export: Detach FD handlers, and set exp->halted to true, preventing
401
+ * fuse_attach_handlers() from re-attaching them, therefore stopping all further
402
+ * request processing.
403
+ *
404
+ * Call this function when an unrecoverable error happens that makes processing
405
+ * all future requests unreliable.
406
+ */
407
+static void fuse_export_halt(FuseExport *exp)
408
+{
409
+ qatomic_set(&exp->halted, true);
410
+ fuse_detach_handlers(exp);
411
+}
412
+
413
/**
414
* Check whether @path points to a regular file. If not, put an
415
* appropriate message into *errp.