summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--9ns/src/bridge.zig25
1 files changed, 20 insertions, 5 deletions
diff --git a/9ns/src/bridge.zig b/9ns/src/bridge.zig
index 97e0882..b94ef78 100644
--- a/9ns/src/bridge.zig
+++ b/9ns/src/bridge.zig
@@ -2406,13 +2406,28 @@ fn dialErrno(e: DialError) linux.E {
///
/// Best effort, and deliberately not fatal: a notification the kernel
/// rejects leaves exactly the old behaviour (ESTALE until the cache
-/// expires), which is degraded, not broken. Writing to /dev/fuse from this
-/// thread is safe — a notification carries `unique = 0`, and the workers
-/// already write their own replies to the same fd.
+/// expires), which is degraded, not broken.
+///
+/// Never sent from this thread, the one serving the mount: the kernel
+/// takes the parent directory's lock to invalidate the entry, and a LOOKUP
+/// holding that lock may be waiting on a reply only this thread would send
+/// (a `cat` of the dead session's index, seen to hang for good). A thread
+/// of its own sends it while this one goes on answering ESTALE; one that
+/// cannot be made skips it.
fn retireEntry(m: *Mount) void {
- fuse.notifyInvalEntry(m.b.fuse_fd, m.parent_node, m.entry_name) catch |e| {
- if (m.debug) std.debug.print("9ns: [{s}] could not invalidate its entry: {t}\n", .{ m.name, e });
+ const Notify = struct {
+ fn send(fd: i32, parent: u64, name: []u8) void {
+ defer std.heap.page_allocator.free(name);
+ fuse.notifyInvalEntry(fd, parent, name) catch {};
+ }
+ };
+ const name = std.heap.page_allocator.dupe(u8, m.entry_name) catch return;
+ const thread = std.Thread.spawn(.{}, Notify.send, .{ m.b.fuse_fd, m.parent_node, name }) catch {
+ std.heap.page_allocator.free(name);
+ if (m.debug) std.debug.print("9ns: [{s}] could not invalidate its entry\n", .{m.name});
+ return;
};
+ thread.detach();
}
// -- pure helpers (unit-tested) ------------------------------------------------------------