mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-19 02:15:02 +01:00
* mount: ask the filer again when a deferred create is published mid-lookup A program that writes a file under a temporary name and renames it while the file is still open (safetensors save_file does, through Rust tempfile's persist) looks the temporary name up before the rename. When the parent directory's listing is not cached, that lookup goes to the filer. If a FLUSH publishes the deferred create while the lookup is in flight (a forked child closing its inherited descriptor sends one), the filer can answer not-found from a read taken before the create committed. By the time the answer arrives the flush has cleared the handle's dirty flag, so lookupEntry finds nothing local to explain the answer, logs "possible coherence bug" and returns ENOENT, and the rename fails although the file exists. Note before sending the request whether the inode had unpublished metadata (a dirty handle or an async flush in flight). On not-found, if it had and has since been published, ask the filer once more: the filer acknowledged the publish before the second request is sent. A second not-found stands, so a file another mount removed is not brought back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: judge a placeholder's not-found by one look at its base Review of the previous commit found two problems. The retry check and the not-found fallback read the handle separately, so a flush that finished between the two reads still turned the answer into ENOENT. And the pre-request read of dirtyMetadata, a plain bool that Write and the flush set under the handle lock, raced with them on every lookup that reached the filer. Note instead whether the handle is a local placeholder: a deferred create has no filer base (baseEntry) until a flush publishes it. A not-found for a placeholder is judged by one atomic look at that base. With none, the filer cannot have the file yet and the handle answers. With a base, the filer acknowledged the publish, so ask once more. dirtyMetadata is not read for this, and the not-found fallback keeps the existing check, with the placeholder decision added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: answer a placeholder from its own handle; a second miss is final Follow-ups from review of the previous commit: - Pick the placeholder after the async-flush wait, from the path's current mapping. - A placeholder that still has no base answers from the observed handle itself, instead of through the not-found fallback, which re-resolved the path and could miss once the handle was released and the cache entry evicted. - A not-found from the second request is final. The flush installs the base before it clears dirtyMetadata, and keeps it set when a write landed meanwhile, so the fallback could return a file another mount had removed. - Test gates release on cleanup, so a failing test leaves no handler blocked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a placeholder's entry the way GetAttr does The previous commit answered a not-found for a placeholder from the handle's live entry under entryLock. Neither of the entry's writers takes that lock: Write and the metadata flush change size, times and chunks under the handle lock, and async upload workers append chunks under the LockedEntry lock, so the lookup could read an entry while it changed. Answer with the copy the create cached when it is still this file's (same inode), as the not-found fallback already prefers. Otherwise copy the handle's entry under both writers' locks, in GetAttr's order (handle lock shared, then the LockedEntry lock), and convert the copy. No caller of lookupEntry holds a handle lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: cache a deferred create's placeholder in filer ids The meta cache stores filer uid/gid and maps them to local ids on every read, but createRegularFile cached the placeholder with the caller's local ids. Under a uid/gid map whose local id is also a mapped filer id, a lookup or stat answered from the placeholder reported the wrong owner. Cache a mapped clone and keep the handle's entry in local ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: assert the placeholder is cached before checking its owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the snapshot owner after evicting the cached placeholder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
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.