diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-02 00:49:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-02 00:49:30 -0300 |
| commit | fe9772b178575fcab93de09fc61c2f13db7db1a8 (patch) | |
| tree | 0e00f63e85f0803e328bc8696a03389e1369000e /9ns/src | |
| parent | e66b2cfcf4e196ec04c73a33364cb567dbcc5d18 (diff) | |
| download | cloud9-fe9772b178575fcab93de09fc61c2f13db7db1a8.tar.gz cloud9-fe9772b178575fcab93de09fc61c2f13db7db1a8.zip | |
9ns: a dead mount's entry is invalidated from a thread of its own, never from the thread serving the mount, which a LOOKUP holding the parent directory's lock may be waiting on (a cat of a dead session's index hung for good)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to '9ns/src')
| -rw-r--r-- | 9ns/src/bridge.zig | 25 |
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) ------------------------------------------------------------ |
