Commit Graph
3 Commits
Author SHA1 Message Date
16a6a70a08 mount: keep delayed events about an earlier file off the next file at its name (#13445)
* mount: keep delayed events about an earlier file off the next file at its name

A writer that publishes a status file by writing NNNN.json.tmp-PID,
fsyncing it and renaming it over NNNN.json recreates the tmp name every
few seconds. Without -writebackCache a mount applies its own events from
the metadata subscription after the local apply (the events of a rename
stream carry the response time, not the log position, so the dedup ring
does not match them), and their invalidations reach whatever file sits at
the path by then. With about 200 such writers in one directory, two of
these events failed a round of the next file:

- the rename of round k moved round k+1's tmp file to NNNN.json. Its
  handle published under that name and was refused (EIO); the retry wrote
  into NNNN.json, and the rename of the tmp name failed with ENOENT.
- the create of round k became the entry and base of round k+1's file,
  and every flush of the round was refused (EIO).

Both hit the new file in the window in which Create had put its handle in
the map but not yet marked it an unpublished create: it did that
afterwards, holding no lock, so the event found a clean handle with a base
and took it for a published file. On master the second event, which
carries the inode number the creating mount stored, makes the handle give
the name up instead (replacedByAnotherFile) and marks it deleted: its
writes are never published, and close returns success.

- AcquireCreatedFileHandle puts a new handle in the state the create
  leaves it in before the handle is in the map. An existing handle, whose
  inode number outlived an earlier file, is installed under its lock.
- An invalidation carries which file its event is about: the inode number
  the file's creator stored and its creation time (hard links excluded).
  An open handle ignores a rename of another file, and any other event
  about an earlier one (another number, created before the file held). A
  later file at the name still reaches the handle.
- MovePath takes the inode number a rename event reports. A source that
  maps to another inode, while the table knows the renamed file by that
  number, holds another file and stays.

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

* mount: judge another file by its creation time only for this mount's own events

A peer's file can take the name with an older creation time: renamed in
from another name, or created on a host whose clock runs behind. Dropping
its event left the name on the replaced file's inode. A peer's rename can
also name a file by a stored inode number another file here holds, when two
mounts made the same path within one second, and was refused.

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

* mount: a delete of another file at the name leaves the open handle alone

Like a rename, a delete names the file it removed. A peer's delayed delete
of an earlier file at the name, logged by a filer other than the one behind
the handle's version, marked the held file deleted and dropped its writes.

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>
2026-12-05 11:12:29 -08:00
Chris Lu b1fecf3b44 mount: mark windows files archived and ignore a zero timestamp (#10559)
* mount: mark windows files archived and ignore a zero timestamp

Windows synthesises NORMAL when a file reports no attributes at all, which
is not the same as ARCHIVE and is what create_fileattr_test checks.

Utimens also wrote a zero timestamp through. Windows sends zero for a field
it is not setting, and storing it put 1970 in the atime overlay, which then
overrode the entry's real time — so a file created a moment ago reported an
access time of 1970 whenever the caller asked through an open handle.
Reading the path instead went down a different route and looked right,
which is why a probe of a fresh file showed nothing wrong.

* mount: match the file type by its mask, and only treat the epoch as unset

S_IFDIR is part of the multi-bit type field rather than a flag, so masking
against it alone also matched a symlink, which shares the bit. A regular
file is now identified by the type mask.

Rejecting every timestamp at or below zero also rejected a date genuinely
before 1970. Only the epoch itself is what Windows sends for a field it is
not setting, so that is all that is refused.

create_fileattr goes back on the known-failures list: the archive fix
works and the test simply moves on to ask for READONLY too, which needs
Chflags. Taking it off was premature.

* mount: drop the time overlays when an inode is released

atimeMap and dirMtimeMap are keyed by inode and were only ever trimmed by
a random eviction at capacity. Inodes are derived from the path, so a
delete and recreate hands the same number to a different file, which then
reported the previous file's access time — a file created a moment ago
answering with a time from long before it existed.

Cleared when Forget actually releases the inode, not on every decrement:
a partial forget still has users. Forget now reports that so callers
holding state keyed by the inode know when to drop it.

* ci: keep getfileinfo listed while its access time is unexplained

Two causes have been fixed and neither closed it, so the honest state is
listed-with-a-reason rather than removed in hope.

* mount: drop timestamp overlays while the inode table is locked

Forget released the inode under the table's lock but cleaned up the
atime and dir-mtime overlays after returning from it. Inode numbers are
derived from the path, so a lookup arriving in that window is handed the
same number back and can store a time that the cleanup then deletes.

Run the cleanup at the release point instead, as a callback under the
lock. The directory-cache purge stays deferred until after the unlock,
where it has to be.

Claude-Session: https://claude.ai/code/session_01EgY2QA3iiPtiu6ww3P2EBn
2026-08-04 16:42:33 -07:00
Chris Lu d5ee35c8df Fix S3 delete for non-empty directory markers (#8740)
* Fix S3 delete for non-empty directory markers

* Address review feedback on directory marker deletes

* Stabilize FUSE concurrent directory operations
2026-03-23 13:35:16 -07:00