Files
seaweedfs/weed/mount
Chris LuandClaude Opus 5.5 bb697650b4 mount: flush open files before shutdown (#13373)
* mount: flush open files before shutdown

On SIGTERM the mount unmounted and exited without uploading the buffered
writes of files still open, so a pod deletion dropped data the kernel had
already acknowledged. The interrupt hook now flushes every dirty open handle
like fsync, inside the existing 30s shutdown bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: refuse writes once the shutdown flush starts

A write admitted after its handle was flushed was acknowledged and then
lost when the process exited. The shutdown flush now sets a flag that Write
checks under the handle lock, takes every handle lock once to wait out the
writes already admitted, and reports whether every flush succeeded. The test
now buffers real bytes and checks they are uploaded and committed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: wait for each handle inside the shutdown flush workers

Waiting for every handle lock before flushing any file let one slow handle
use up the shutdown bound for all the others. Each worker now waits for its
own handle and flushes it if dirty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: refuse copy, fallocate and handle attribute changes during the shutdown flush

copy_file_range, fallocate, and setattr/xattr on an open handle also
leave their result only in the handle. One that lands after the shutdown
flush has passed its handle was acknowledged and then lost at exit, as
writes were before. Like Write, they now return EIO once the flush starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: leave the meta cache open when the shutdown flush times out

A flush still running after the 30s bound holds its handle's lock.
Closing the meta cache drains queued invalidations, and one for that
handle waits on the same lock, so the hook blocked past its bound
until the flush gave up. Skip the close in that case, as the write
cache removal already is; the process exits right after the hooks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: keep the read cache dir when the shutdown flush times out

By default the write cache lives inside the read cache dir, so removing
the read cache on the timeout path deleted the swap files that the still
running flushes read, along with the meta store left open for them. Remove
both dirs only after the flushes drain. The meta store is recreated on
the next start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: keep a close's writeback deferral through the shutdown flush

A writeback close marks the handle for the background drain. If the
shutdown flush started on that handle between the close's flush and its
release, it cleared the mark, so the release took the immediate path:
it fenced the handle's publication and destroyed its pages while the
shutdown flush still uploaded them. Once shutdown starts, a synchronous
flush leaves the mark, and the release drains as usual.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 10:24:02 -08:00
..
2026-02-20 18:42:00 -08:00

Concurrent writers to one file from different mounts require -dlm; without it, a conflicting write fails with EIO and the file may refuse further appends until reopened after the cache drops.