| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Every program that serves a cloud9 tree should be drivable through it from
its own binary and from agents, and pardes, 9ns and pardes's Python tests
each carried a blocking client of their own. Fsys is the one the library
lacked, plan9port's lib9pclient over `Client`: dial a name posted in the
registry (a subdirectory entry such as pardes/main included), unix!PATH or
tcp!HOST!PORT; open, create, remove, stat, read, write and clunk by path and
fid; readFile, writeFile and ask (write, then read the answer on the same
open from the start, as Plan 9 reads /net/cs) streaming into a
std.Io.Writer, flushed per answer, so an event file whose reads park streams as it comes. A refusal is
error.Refused and said() holds the server's words, which a mount would have
turned into an errno.
Taken from pardes's Client (src/9p_io.zig): the walk sent ahead of the
request that uses its fid, the clunk not waited for, and the answers of
both checked or dropped on the way to the request's, so an open, a stat or
a remove is one round trip; error words kept as the server said them. Not
taken: its kept-connection table, flights of read-ahead, the stat-length
end of file and its pardes-only dials. From 9ns: the chunked read/write
loops and the iounit. Buffers inline (2 x 64 KiB), no allocator, std.Io
streams only, so it builds without libc.
TestTree.zig is a small tree on serve.Runner for these tests and the next
change's. Tests over a Unix socket and TCP against cloud9's own engine:
whole files longer than a message, stats, walks longer than 16 names, a
missing first name and a walk short of its names refused in the server's
words, a refused write whose words reach the caller, a short read that is
not the end, ask, a held read streaming three chunks flushed one at a time,
a server that hangs up mid-read, create and remove, a directory decoded as
entries, dial by posted name and a name that climbs out of the registry.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
mount
9ns served one FUSE request at a time per 9P server, so a read the server
parks (pardes's log, a pane's event) held up every other operation on the
mount: with 'cat log' parked, 'cat status' took 3.5-4.5 s instead of ~1 ms.
nine.zig: the session is shared by threads and multiplexes by tag the way
Plan 9's mount driver does (devmnt.c mountio/mountmux/mntgate/
mntflushalloc). Each thread calls through its own nine.Caller (reply buffer,
wake-up eventfd, interrupt source, ename). A call writes its T-message under
wlock; the first waiter with nobody reading takes the reading baton, reads
for everyone and hands each R-message to the caller its tag names, then
passes the baton on. Tflush is per tag: a reply that beats the Rflush is
honoured, the flushed tag is not reused before the Rflush, the baton is let
go before the flush is written. With every tag taken a call waits for one
(starved list) instead of failing.
bridge.zig: one thread (the loop) still owns the inode/handle/qid tables and
serves everything that touches them. READ and WRITE are resolved to their
fid on the loop and handed to transfer workers (up to 31 per bridge,
started on demand), which make the 9P calls on their own Caller and reply
themselves. FUSE_INTERRUPT for a worker's request: still queued -> EINTR on
the spot; in flight -> its unique down the worker's pipe -> Tflush of exactly
that tag. Fids are clunked only on RELEASE. mntgen mounts get the same pool
(their dispatcher routes interrupts to it); the mount interrupt pipe moved
into Bridge. main.zig attaches through a Caller.
Tests: two multiplexing tests in nine.zig (a parked read holds up only its
caller and its interrupt flushes exactly its tag; with every tag parked a
call waits for a tag), and a serve()-level test driving a fake /dev/fuse (a
parked READ holds up neither READs nor GETATTR; INTERRUPT -> one Tflush for
the parked tag -> EINTR; RELEASE). Also de-flaked the pre-existing
'short read' test (it raced its own server reply under load).
Measured (own 9ns mount on the live pardes socket, read-only): with log
parked, cat status 4498 ms before, 7 ms after.
Tag window: client.zig gains ClientWith(n) (Client = ClientWith(16) as
before; request/result types hoisted so all instantiations share them).
9ns uses ClientWith(32): 32 is fs.zig's default slot_capacity, so one 9ns
mount can never have more parked on a cloud9 fs server than it parks, and
never meets its "Resource temporarily unavailable" refusal. fs.zig is
unchanged (its default is also the ESP32 board's, held to 24 KiB by its
budget tests). Full window: the loop keeps its tag (metadata unaffected);
the 32nd READ/WRITE waits in the pool queue (blocks, interruptible, never
EAGAIN/EIO).
More tests (bridge.zig, serve() over a fake /dev/fuse): one open is one fid
(two opens of an inode read through distinct fids, concurrently, one of
them parked); FLUSH on a handle with a parked read clunks nothing and the
read later completes on that fid; only RELEASE clunks; a flushed READ whose
reply beats the Rflush returns the data, not EINTR.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
cloud9.post: servers post their socket under a name in
$XDG_RUNTIME_DIR/9p (post/unpost, posted, dial, Watch) and
serve.Runner.listenPosted posts a server by name, unposting on stop.
Names are budget-checked against the 108-byte socket path; a claim
binds+listens at a private temp path and takes the name with atomic
renames under flock (RENAME_NOREPLACE for free names, RENAME_EXCHANGE
grab-verify-commit for stale ones): the registry path is never unlinked
by a claim, live names refuse with AlreadyPosted, foreign files with
NotSocket, and unpost removes only the caller's inode-matched entry.
Watch surfaces inotify overflow and a replaced registry dir.
9ns --mntgen [--mount DIR] -- PROGRAM: one FUSE mount at /mnt/9p whose
synthetic root lists the posted registry (no connection made); a walk
into an unmounted name dials it and runs the existing bridge dispatch
in a per-server worker thread, routed by mount index in the node id's
top bits (ordinals never reused, cap 4096); a dead server answers EIO
on its subtree and is re-dialed on the next walk. The dial watches
stop_fd through Tversion (connectWatched). All existing 9ns forms are
unchanged.
9proc's unix listener no longer blind-unlinks its path: a foreign
non-socket is refused (Occupied), a live server is refused
(AlreadyListening), only a refused socket is cleared, and stop()
unlinks only the listener's own inode-matched socket.
Hardened by adversarial review (GLM 5.3 x2 + DeepSeek V4.1 Flash, all
high-thinking): double-bind races on one name (0 in 180k rounds),
foreign-file TOCTOU deletions (0 in 4M flips), a 255-byte-name listing
panic, inotify queue overflow silently dropped, listenPosted silently
overwriting, dial-time Tversion hangs wedging the dispatcher, --debug
silently ignored in mntgen, and xattr/statx probes answering EPERM on
the synthetic root (broke `ls -l /mnt/9p`).
Tests: root 80/80, 9ns 47/47, 9proc 60/60, integration 88/88 +
mntgen 37/37, adversarial 213/0, freestanding riscv32 gate green.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Runner(Backend, Options, Limits) listens on Unix or TCP, runs a reader and a
serve task per connection in one Io.Group, pushes frames into an fs.Server,
and lets the backend answer now or later from any task or thread (reply,
flush, wake); Tflush, greet timeout, connection limit, close and stop with
cancellation are covered by tests over real sockets. The engine and the
backend contract stay Io-free, so the push/step mode for freestanding
targets is unchanged. Documented as the two ways to drive the engine.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The asynchronous 9P file-server engine from the Pardes editor moves into the
library: fid table, walks, directory cursors, a job/slot model where backend
replies arrive later by tag (status again = parked), Tflush cancellation and
orphaned fids on hangup. Allocation-free, no OS calls, no std.Io; comptime
Options (fid, slot, park data, name and user capacities) replace the
editor's constants. Backend contract types (Req, Reply/ReplyWith, Op,
Status, Attr, E, error strings) live here. 29 engine tests plus the client
tests that sat beside it in Pardes.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
| | |
|
| |
|