mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
41f1c25d0174a4ff2fdf5f0035a52ff3f0fed13a
483
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a1764358cf |
filer, mount: keep a hard-linked file to one link id and count its names on the filer (#13006)
* filer, mount: keep a hard-linked file to one link id and count its names on the filer A hard link's bookkeeping was done by the client. To link a file a mount reads its entry and sends two writes, an update of the source and a create of the new name, both with a link id and a count of the file's names. Two clients that link one file at the same moment each worked from the entry as it was before the other's writes: - With no link id on the entry yet, each made one up. The second update moved the source to its id, the store took the name off the first, and the first client's new name was left alone on it: one file's chunks under two link ids. - With a link id there, both read the same count and sent it plus one. The record counted one name fewer than the file had. Any write through a name carried the client's copy of the count and replaced the record the same way. Either way the delete of the last counted name deleted the record and the chunks while another name still read them. The filer's own store now counts the names of a hard-linked file itself (countLink): one more when the name written did not hold the link before, the same when it did or when a rename moves it there (WithMovedLink), one for a record that starts. The count sent is not used, and the entry gets the count stored, so the response and the event carry it. The lookup of the name, the count, the record and the name are stored as one change of the record (changeLinkRecord), which DeleteHardLink goes through as well: under a lock per link id, and in a transaction where the store refuses a commit over a change made since it began, run again when it does. A wrapper around a copy of some entries, such as a mount's metadata cache, sees only some of the names and stores the count it is given. UpdateEntry refuses to give a name that holds a hard link another link id that no file has yet (refuseSecondHardLink). The mount sends a file's first link's update as a unary RPC, which keeps that refusal apart from an I/O failure, reads the entry again and links under the id the file has by now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: take a replicated update's link id without refusing it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: look a path-specific name up outside the record's transaction Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: check the leveldb open and close it in the hard link test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: send a refused first link again from the entry as stored Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a first link's refusal over the next filer's error Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: count a hard link's names next to the clients' count instead of in its place The filer's count replaced the one clients send, which lost two things that count did by being worked out ahead: - A link's first write, the update of the source, carries the count with the new name in it already. While the second write is on its way that kept a delete of the source from being taken for the delete of the file's last name (lastLinkDropped goes by the count it read), and the chunks from being deleted under the name about to come. Counted only when it arrived, the new name was stored with chunks that were gone: 104 of 300 rounds of a mount linking a file while another deletes it. - A write of a name the store refused had counted the name already, and sent again counted it once more. The filer now keeps its count of the names in a key of its own next to the record (linkNames), written once the name is stored, and the record gets whichever is higher: the count the client sent or the names counted. It is never lower than what the client alone would have left, and never lower than the names the file has. A record from before has its count recorded as the names when it is first written again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: send a refused first link again with the file's inline content The second attempt builds the new name's create from the entry as the filer has it by now: attributes, chunks and extended attributes. A file the filer keeps inside its entry has its bytes in Content, and the create is what the filer writes the link's shared record from, so without them the record lost the file's content. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: store a path-specific name before the record's lock is let go A second create of the same new name on this filer took the lock between the first one's count and its name write, missed the name, and counted it again: the file's record and chunks then outlived its last name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a link's names key out of the keys of a directory's entries The key began with the link's random id. One that began as the root's entry keys do in a store keyed by path put the names' 4 bytes in the root's listing, and it failed to decode: listing / and the etcd scan under fsck failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: record a hard link's name before it is stored, and take it off if it is not The names counted for a hard link were recorded once the name was stored. On a store without transactions a failure of that write left the name stored and not counted, and the write sent again found the name there and did not count it either: the names recorded stayed one below the names stored, the side a file is deleted under a name from. They are recorded first now, inside the change of the record that counted them, and a name the store then does not take is counted off again (storeCountedName). A failure halfway leaves them one above the names stored, and the file leaked. A name in a path-specific store is recorded with the record as well, and counted off in a change of its own. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * filer: keep a hard link's name counted when a failed write stored it A write whose deadline passes after the store took the name returns an error, and counting the name off then left the names one below the names stored. A later write with the count from before the link lowered the record to them, and the file was deleted under a name it still had. Read the name back first, and keep it counted where that cannot be told. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: carry the stored RemoteEntry into the name a retried first link adds The retry rebuilds the new name from the entry the file has once another client linked it, but kept the RemoteEntry of the entry first read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
5e796fa985 |
mount: keep a file's inline content when it is written to or resized (#13009)
* mount: keep a file's inline content when it is written to or resized A small file the filer keeps inside its entry (-saveToFilerLimit, or ?saveInside=true on the upload) has its bytes in the entry's content and no chunks. A mount dropped the content at the first write to the file, or copy into it, and published the write's chunk alone: the bytes the write did not cover read as zeros from then on, for an append as for two bytes in the middle. A change of size left the content as it was. Grown, the file read no further than its content on the mount and as zeros through the filer; cut and grown again, it had the bytes that were cut off back. The content now becomes a write of the handle's own, older than the one about to change the file, and is flushed with it as a chunk (bufferInlineContent: Write, CopyFileRange, Fallocate). SetAttr cuts it to a smaller size, and stores it as a chunk before the file grows past it (resizeInlineContent). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: store resized inline content in chunks of the mount's chunk size A file that grows past its inline content had the content stored as one chunk, whatever its length, where a buffered write is split at the mount's chunk size: content longer than a volume server takes in one upload could not be stored, and the file could not grow. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
bd1f24a09b |
mount: carry a file's inline content into the name a hard link adds (#13008)
* mount: carry a file's inline content into the name a hard link adds A small file the filer keeps inside its entry (-saveToFilerLimit, or ?saveInside=true on the upload) has content and no chunks. To link it a mount updates the source and creates the new name, and the filer writes the link's shared record from each of the two. The create carried the source's attributes, chunks and extended attributes but not its content, so the record was left with a size and nothing behind it: both names read zeros from then on, through the mounts and through the filer. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: carry a remote-only file's RemoteEntry into the name a hard link adds A file under a remote mount that is not cached yet has no chunks and no content; its RemoteEntry is what sends a read to fetch the object. The create of the new name left it out, so the hard link's shared record lost it and both names read zeros. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: cache a remote-only file before a hard link gives it a new name The filer resolves a remote object from the name a read goes through, and the new name has no object of its own, so a read through it failed until the source name had been read. The link now has the filer cache the object first, so every name shares its local chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: cache a linked remote-only file through its open handle The cache moved the stored entry off the base of a handle open on the source, so the handle refused the link change and its next flush failed. A handle with buffered writes now publishes them first, and the cache goes through the handle as a read does, which moves its base along. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
7638cf2f66 |
mount: keep the data past a sparse file's first hole when merging chunks (#12978)
* mount: merge each run of a sparse file's data, not just the run before its first hole The chunk stream reader ends at a hole, so the merge stopped there and replaced every chunk with ones covering only the data before the first hole. Read and save each contiguous run of visible data on its own, and leave the holes between runs unwritten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: skip the small-chunk merge for a sparse file The merge reads the chunks through the stream reader to its end, which stops at a hole, and keeps only the chunks before its start offset, so an append to a sparse file lost the data past the first hole after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
dbc64144ca |
mount: support NFS re-export file handles after inode eviction (-nfsExport) (#12979)
* mount: update go-fuse for the export support option Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: optionally retain the paths of forgotten inodes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: answer lookups of "." and ".." for file handle decoding Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: add -nfsExport to negotiate export support and retain forgotten inodes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test file handle lookups of "." and ".." Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a file handle lookup when its path now holds another file A "." lookup resolved a forgotten inode by its remembered path, so a file created at that path since was served to the old handle. Compare the entry's inode with the handle's and answer ESTALE on a mismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: register a file handle's inode under the table lock A "." lookup checked the file at the remembered path and then registered it with Lookup, which hands back whatever inode holds the path by then. LookupHandle takes the reference on the handle's own inode, or enters it at the path only while no other inode holds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a forgotten inode's retained path across a rename A rename whose source inode the kernel had already forgotten left the retained path at the old name, so its file handle failed with ESTALE. An index from retained path to inode lets MovePath move it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: register a file handle only at its current retained path A rename between resolving a forgotten inode's path and registering it moved the retained entry, yet LookupHandle still entered the old path. It now compares the path with the retained one under the table lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop the target a forgotten inode is renamed over Moving a forgotten inode's retained path onto a live name left the replaced inode mapped there. Once a retained entry moves, the target is taken apart as for a live source and reported as replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test that a renamed path-inode file fails its file handle closed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * go.mod: use the go-fuse v2.9.5 release Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d95f5e67fb |
mount: refuse an exclusive create of a name another mount holds (#12966)
* mount: create at the filer only where no entry is stored A create sent to the filer at open time (mknod, and every create under EagerFilerCreate) went without OExcl, so the filer stored it as an update of a file another mount had created there: open without O_EXCL emptied that file and mknod replaced it. Send OExcl, report EEXIST, and drop the cached listing so the reopen finds the stored entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: store an exclusive create at open A create is deferred to the first flush and checks only this mount's view, so two mounts could both open the same new name with O_CREAT|O_EXCL. Send an exclusive create to the filer at open instead, where OExcl refuses the name another mount already stored. Writeback keeps deferring: it assumes one writer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fe816eaac8 |
mount, filer: stamp merged and manifest chunks instead of leaving them at 0 (#12962)
* filer: stamp a manifest chunk with the newest chunk it folds mergeIntoManifest saved the manifest with tsNs 0, so manifest chunks carried no modification time. Give it the newest ModifiedTsNs of the chunks it holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: stamp merged chunks with the newest chunk they replace maybeMergeChunks uploaded the rewritten chunks with tsNs 0, so any older chunk that overlaps them later, like a covered chunk sent with the commit, outranked the merge. Give them the newest ModifiedTsNs of the chunks they replace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: stamp a merged chunk with the oldest data it holds The newest stamp of the whole merge outranked a peer's pending write that is newer than the bytes the merge carries for its range but older than the newest of them. Stamp each merged chunk with the oldest visible data in its range, or 0 over a hole, so such a write still shows while chunks older than all of its data lose to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: find a merged chunk's range by binary search Each uploaded chunk scanned the visible intervals from the front. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
07e1299f98 |
mount: add -idmap to allow ID-mapped bind mounts (#12922)
* mount: add -idmap to allow ID-mapped bind mounts FUSE allows ID-mapped mounts only for a server that announces FUSE_ALLOW_IDMAP. Once announced, the kernel sends uid and gid 0xFFFFFFFF on most requests after checking permissions itself, so the checks that read the caller treat that value as already checked. * fuse: refuse an unsupported -o idmap before starting the child The child exits on checkIdmap, but the parent waits for its readiness signal and never returns, so weed fuse -o idmap hung on macOS and FreeBSD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse -idmap on Windows instead of ignoring it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fuse: take -o defaultPermissions as the mount flag -o defaultPermissions=false was forwarded to the kernel as an unknown option, which failed the mount, and left the flag at true, so -o idmap,defaultPermissions=false passed the idmap check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5f97a9d088 |
mount: keep an unpublished create's writes, unpublished, when a peer renames onto its name (#12960)
* mount: publish an unpublished create's writeback drain after a peer rename onto its name With -writebackCache, the drain flushes metadata only while the saved path still maps to the handle's inode. Another mount renaming its file onto the name of a file this mount created and has not published moves that path to the peer's inode, so the drain skipped the flush and dropped the writes without an error or a failed-metadata record. A local rename or unlink of a draining handle waits for the drain or marks it, so for an unpublished create a lost mapping means another mount's file took the name. Skip the guard for it: the create-if-not-exists commit then keeps a recovery record when the name is taken and publishes when it is free. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(fuse_dlm): accept only EEXIST on O_EXCL as an early second-create refusal The concurrent create test returned early on any error from the second open, so an EIO, or an open failure in the O_TRUNC case, passed without writing either payload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse publishing an unpublished create after a peer renames onto its name Another mount's rename onto the name of a file this mount created but has not published takes that name. The create used to publish there later with create-if-not-exists as soon as the name was free again: after a local unlink of what the name showed, it reappeared, and after a move of its directory it landed under a path no longer reachable. markHandleReplaced now records that the name was taken, and the publication check refuses the handle from then on: a writeback drain keeps a recovery record and default mode fails close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
dbbf2907a6 |
webdav: refuse to delete, move or overwrite entries under Object Lock or WORM (#12959)
* webdav: refuse to delete entries under Object Lock or WORM DELETE removed versions under legal hold or retention and WORM files that the S3 API and the filer HTTP API refuse to delete. Check the entry, and for a collection everything below it, then pin the delete to the Object Lock state that was checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: refuse to move entries under Object Lock or WORM MOVE could rename a locked version or WORM file away, move a directory holding them, or replace a protected target. Check the source, a source directory's contents and the target before the rename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: refuse to overwrite entries under Object Lock or WORM PUT and COPY replaced a locked or WORM file with a fresh entry, dropping its content and its lock. Check an existing file before creating over it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: pin an upload's final update to the Object Lock state it read An upload writes the whole entry back when it closes. A hold or retention set on the new object while the upload was buffering would be dropped, so the filer now refuses the update if that state changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: recheck an upload's target when it commits instead of pinning it The precondition on the final update sent it to the path's write owner, while the placeholder create stayed on the connected filer. With separate filer stores the owner could miss the placeholder and refuse the update, leaving an empty file. The upload now rechecks the target right before the update, as the SFTP upload does, and the update stays local. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: share the WORM retention and subtree checks FilerConf.WormEnforced and IntersectsWorm replace the copies in the filer server and mount; ReadFilerConfFromClient reads filer.conf over a filer client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp, webdav: use the shared Object Lock and WORM helpers Both servers now call FilerConf.WormEnforced, IntersectsWorm, ReadFilerConfFromClient and s3_objectlock.ObjectLockState instead of keeping their own copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
488bdafbbb |
mount: decide chown's set-id clearing by the caller, keep it on directories (#12955)
* mount: decide chown's set-id clearing by the caller, keep it on directories SetAttr read input.Uid as the caller, but in SetAttrIn that field is the new owner; the caller is input.Caller.Uid. Root giving a file away cleared its SUID/SGID bits, a user giving a file to root kept them, and every chown to a non-root owner cleared the SGID bit of a directory, which Linux keeps so new entries go on inheriting the group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: let Linux decide chown's set-id clearing The mount does not handle killpriv, so Linux sends the cleared mode with a chown that must drop the set-id bits. Clearing them again by caller dropped the SGID bit Linux keeps on a file without group execute when a user changes only its group. Other systems keep the caller rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ae60559da9 |
mount: keep the furthest dirty stop when a read spans chunks (#12957)
PageWriter.ReadDirtyDataAt walks the requested range one chunk at a time but overwrote maxStop with each chunk's result. When an earlier chunk had dirty data and a later chunk in the same read was clean, the clean chunk's 0 replaced the earlier stop, so the caller under-reported how much of the buffer the dirty pages filled. Take the maximum across chunks instead. Fixes #12946 |
||
|
|
da9518718f |
mount: keep an unpublished create's writes when another mount takes its name (#12943)
A file created on a mount is published to the filer at flush; until then its handle is dirty and has no base. When another mount creates the same name and its event arrives first, invalidateOpenFileHandle skips the branch that keeps a dirty handle's writes, because that branch needs a base. It falls through, destroys the handle's dirty pages and installs the other mount's entry as the base. The flush then has nothing to publish, and close() returns 0 although the writes are gone. A delete or rename of the name by another mount marks the handle deleted or moves it, with the same result, and a rename onto the name has onEntryInvalidation mark it deleted. The filer holds nothing of such a file, so an event at its name is about another file. Leave the handle alone. Its create-if-not-exists commit then reports a taken name as a conflict (close() fails with EIO, or with -writebackCache the request is kept in failed-metadata), and publishes as usual when the name is free. Part of #12941. |
||
|
|
caeadb2db2 |
mount: refuse RENAME_EXCHANGE instead of renaming over the target (#12921)
* mount: refuse RENAME_EXCHANGE instead of renaming over the target renameat2(a, b, RENAME_EXCHANGE) asks for the two names to be swapped atomically. Rename let the flag through and went on as a plain rename, so a was moved over b, b's content was gone, and the call reported success. The filer's rename moves one entry and cannot swap two, so the mount now answers EINVAL, which is what renameat2(2) returns for a flag the file system does not support, and callers fall back on it. RenameWhiteout was 3, which is RENAME_NOREPLACE|RENAME_EXCHANGE; the flag is 1<<2. Both values, and any other flag the mount does not implement, now get the same EINVAL (3 answered ENOTSUP, 4 already EINVAL). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: trim the rename flag comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
93e7a81b01 |
mount: refuse names that are not valid UTF-8 instead of rewriting them (#12952)
The mount replaced every invalid UTF-8 run in a name with "_" so the name could go into proto string fields. That mapped different names to one entry: two legacy-encoded names shared one file, a write or unlink through an invalid name hit an existing file with "_" in its place, and O_EXCL failed with EEXIST for a name that did not exist. Making such a name (create, mknod, mkdir, symlink, link, rename target) now fails with EILSEQ, and looking one up or removing it answers ENOENT, before anything is sent to the filer. Entries stored earlier under a rewritten name stay reachable by that name. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9fc8a6aec2 |
mount: read SSE-S3 objects through the S3 gateway (#12909)
* mount: read SSE-S3 objects through an authenticated S3 gateway * mount: check each comma-joined mount option against -sseS3ReadEndpoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a mounted version file by its object key and version id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a current null-version object without s3:GetObjectVersion Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: declare -sseS3ReadEndpoint with the other mount options so weed fuse accepts it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: require the canonical bucket path as the root of an SSE-S3 read mount Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fall back to the null version when the current object is another version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: list the S3 endpoint each S3 gateway advertises Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: advertise the gateway's S3 endpoint to the master Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: find the S3 gateway through the masters instead of -sseS3ReadEndpoint -sseS3Read turns gateway reads on. The reader lists the S3 endpoints the filer's masters have registered, prefers HTTPS, and picks another gateway when the current one cannot be reached. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry an unreachable S3 gateway read on a different gateway Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: warn when -sseS3Read falls back to a plain-HTTP gateway Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: do not retry an unreachable HTTPS gateway over plain HTTP Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: tell HTTPS gateways apart by the parsed URL scheme An S3 gateway advertised as HTTPS://host lost the HTTPS preference and the plain-HTTP fallback guard, since the check matched the raw string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6f248fc190 |
mount: keep a clean handle off the file a peer renamed over the one it has open (#12920)
* mount: keep a clean handle off the file a peer renamed over the one it has open
A peer renames another file over the one a handle has open here. When this
mount has looked the rename's source up, MovePath reports the handle's inode
as replaced and the handle is marked deleted. When it has not, which is the
usual case for "write a temp file, rename it over the real one" done on
another mount, MovePath has nothing to move and reports nothing. The event
for the target path then reaches the handle as an update: a dirty handle
refuses it, but a clean one installs the newcomer's entry, and everything
the descriptor does afterwards lands in the replacement: writes, mmap
writes, ftruncate, fchmod, fsetxattr.
A clean handle now takes an entry with another inode at its path for what it
is. The handle is marked deleted, as after a delete, and its inode gives the
name up as a replaced rename target does, so the kernel gets ESTALE for the
old inode, walks the path again and reaches the newcomer under an inode of
its own. An entry or a handle without an inode cannot tell and installs as
before, and so does an update in place, which keeps the inode.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* mount: a replaced handle keeps a surviving hard link, a renamed one ignores its old name
From the review of
|
||
|
|
ae0f1a2525 |
mount: delete chunks overwritten before their first publication (#12910)
* mount: send covered chunks no stored entry named, so the filer deletes them A flush compacts the handle's chunks before it publishes them, dropping chunks later writes fully cover. The filer deletes only the chunks the stored entry loses and the ones the request itself covers, so a chunk uploaded and then overwritten before any publication named it (a file rewritten in place before close, like FFmpeg's +faststart pass) was left on the volume servers with no reference. Both the close flush and the periodic metadata flush now carry those chunks along in the request, after the base snapshot, when the request's own plain chunks still cover them; the filer compacts them out and deletes them after the commit. Chunks rewritten by a merge are stamped 0 and the filer does not look into manifests, so a chunk that would show through again is not sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test that flushes hand covered unpublished chunks to the filer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check each covered chunk against the request's own chunks The coverage check compacted the dropped chunks together with the request's, so one dropped chunk could hide another. Only the request's chunks reach the filer with it: after a merge, whose chunks are stamped 0, an older dropped chunk hidden only by a newer dropped one would show through and the filer would delete the merged chunk instead. Each dropped chunk is now sent only if newer visible plain chunks of the request hide all of its range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6adc9f0a21 |
mount: read chunks with filer-issued exact-file read tokens (#12800)
* mount: read chunks with filer-issued exact-file read tokens * mount: preserve read authorization across delayed lookups and hard links * mount: retain response tokens across read cache eviction * mount: keep a shared read-token lookup alive when its first caller is cancelled Token refreshes for one entry share a singleflight lookup that ran under the first caller's context. An interrupted read cancelled that lookup, so every other read of the entry waiting on it got no token, went out unauthenticated, and failed with EIO on a volume server enforcing read JWTs. Run the lookup detached from the caller (each attempt stays bounded by the filer RPC wait) and let a cancelled caller stop waiting at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: serve a cached chunk past the cache cutoff instead of fetching it The full-chunk read path consulted the chunk cache only for chunks below the cache size cutoff. Read-auth and peer-sharing mounts cache every chunk they upload, so a read-after-write of a high-offset chunk went to the volume, where a read-auth mount has no token before the entry is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: re-track read tokens when this mount renames an open file Writeback mounts skip their own rename event, so only the subscriber path re-tracked an open handle's chunks. After a local rename a token refresh looked up the vacated name and the read failed. The rename response, the subscriber rename and the surviving hard link now share ReadAuth.TrackHandle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
907c46fe47 |
mount: answer ESTALE for an inode the kernel holds but whose name is gone (#12887)
* mount: answer ESTALE for an inode the kernel holds but whose name is gone A rename over an existing file drops the replaced inode's path in InodeToPath.MovePath as soon as the rename's response arrives from the filer, which sends it before it commits. Until the RENAME reply reaches the kernel, the kernel still maps the name to the old inode, so an open, stat, access or xattr call resolved in that window reaches maybeReadEntry or AcquireHandle for an inode without a path and fails with ENOENT, although the name exists. A rename made through another mount opens the same window for as long as this kernel keeps the name's dentry. A process polling a file that another one replaces with tmp + rename sees sporadic ENOENT; a slow commit turns the window into a burst. While the kernel has not forgotten the inode, answer ESTALE: the kernel redoes the path walk once with LOOKUP_REVAL and opens the current entry, as on NFS. A forgotten inode keeps ENOENT. One writer replacing a file with tmp + os.replace and four readers opening it in a loop on one mount, for 120 s: each reader got 897k-967k ENOENT before (130k reads succeeded), none after (272k reads). With the readers on a second mount that also lists the directory: 1,277-1,550 errors per reader before, 7-13 after, at about 140 replacements a second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: answer ESTALE for a pathless inode only on Linux Only the Linux VFS redoes a path walk on ESTALE (LOOKUP_REVAL). FUSE on macOS and FreeBSD purges the vnode's name cache when GETATTR or OPEN answers ENOENT, so the next lookup finds the replacing file; ESTALE skips that purge and keeps failing until the entry times out. WinFsp maps the unknown errno to EIO. Keep ENOENT there. 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> |
||
|
|
78e2a4c2b4 |
mount: check the next inode number before AllocateInode returns it (#12884)
AllocateInode probes from the number a path hashes to while that number is taken, but the loop re-checked the number it had just stepped off and then advanced once more. When the first candidate was taken, it returned the number after the first free one without looking at it, and that number can belong to a live file. The new entry stores the number in its attributes and the mount reports it as st_ino, so the two files stat as the same file. A writer that replaces a file with tmp + rename several times a second runs into it: the next temp file hashes to the number the previous one carried to the target, and GNU mv refuses the replacement with "are the same file". With readers holding the replaced file open, 56 of 3446 such replacements failed that way on our mounts; none did with this change. Lookup's probe already checks the next number; AllocateInode now does the same. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b4f5b1a354 |
mount: hold a rename's names against this mount's own publications (#12889)
* mount: hold a rename's names against this mount's own publications
A rename of an open file can fail with EIO on a filer store with optimistic
transactions (TiKV). Rename publishes the handle's deferred create first. A
FLUSH of the same handle (a forked child closing the inherited fd, say)
that looked at the dirty flag before that publication waits on the locks,
then publishes the identical entry again while the filer moves the file,
and TiKV refuses the rename's commit on the source key ("write conflict
... reason:Optimistic"). safetensors checkpoints hit this: they write
.tmpXXXXXX and rename it while the fd is still open, and our training jobs
fork a subprocess every second.
- flushMetadataToFiler checks dirtyMetadata again under its locks and
publishes nothing for a handle another flush has already published.
- Rename holds the publication locks of both names, in path order, across
the filer call and the local move. A flush, chmod/utimes or xattr change
of either name through this mount waits for it, then publishes under the
name the rename left: lockFlushTarget (content flushes, now also the
periodic flush) and lockNodePublication (attribute changes) resolve the
name again after the wait. A failed rename restores the target's handle
before the locks go.
Tests: weedfs_rename_publish_test.go, with a filer that records every
write made while a rename is in flight. On master six of the seven fail,
the incident among them (the deferred create published twice); the one
that passes guards against deadlock between renames. The chmod stress run
fails on master with ENOENT. TestFlushMergeThroughChunkProxy marks its
handle dirty before it flushes: doFlush only flushes a handle with changes,
and the clean handle it used would now publish nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: give up on an attribute change whose node keeps moving
lockNodePublication went ahead on its fourth wait even when the node had
been renamed again meanwhile, and the change went to a name the node no
longer had, without that name's lock. It now returns EAGAIN then, as the
flush path already refuses after its fourth try. The stress tests accept
EAGAIN from a chmod racing back-to-back renames.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test the chmod that gives up on a file that keeps moving
The chmod waits for a name's lock that the test holds shared, so a
shared try fails exactly while the chmod is queued for it; the test
moves the file each time, four times, and expects EAGAIN with nothing
written.
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>
|
||
|
|
ebd90c3a45 |
fips140=only: SHA-256 in place of MD5 and SHA-1 so the server starts and serves S3 (#12855)
* util: SHA-256 stands in for MD5 and SHA-1 under fips140=only GODEBUG=fips140=only panics on MD5 and SHA-1. NewMd5 and NewSha1 return those hashes as before, and under fips140=only SHA-256 cut to the same size, so digests keep their length. Md5, HashStringToLong and HashToInt32 use NewMd5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer stores: hash directory keys with NewMd5 and NewSha1 leveldb2, leveldb3, rocksdb and arangodb hash directory keys with MD5, tikv with SHA-1, which GODEBUG=fips140=only refuses, so the filer panicked at startup. They now use util.NewMd5 and util.NewSha1. Keys made under fips140=only differ from MD5 keys, so leveldb2 and leveldb3 mark an empty database opened under fips140=only and refuse a database whose keys are of the other kind instead of showing it empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * operation, volume: no Content-MD5 checks under fips140=only Under GODEBUG=fips140=only the uploader's digest is not an MD5, so it is no longer sent as Content-MD5, which volume servers outside that mode would reject; the digest still becomes the chunk ETag. A Go volume server in that mode keeps a client's Content-MD5 unchecked instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, filer: ETags and content digests with util.NewMd5 ETags, entry Md5 attributes and chunk digests now use util.Md5 and util.NewMd5, so under GODEBUG=fips140=only they are SHA-256 cut to 16 bytes instead of panicking. That digest cannot check a client's Content-MD5, so in that mode Content-MD5 is accepted unchecked, and the filer stops returning Content-MD5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, iam, master: SHA-1 names with util.NewSha1 Multipart upload ids, IAM policy ids, the OIDC provider, audit and session revocation file names, and the master's read-only copy dir hash names with SHA-1. They now use util.NewSha1, which GODEBUG=fips140=only turns into truncated SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * postgres, oidc, update: refuse MD5 and SHA-1 checks under fips140=only PostgreSQL md5 authentication, OIDC TLS thumbprints (SHA-1 by definition) and weed update's MD5 check of the download cannot run under GODEBUG=fips140=only. They now fail with an error saying so instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: no empty-body MD5 when Content-MD5 is not checked Under fips140=only a bodyless signed request still reached md5.Sum(nil) before the nil check and panicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: empty copy part ETag from the digest it stores Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: skip the native MD5 test under fips140=only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3sink: no Content-MD5 under fips140=only The entry's Md5 attribute is truncated SHA-256 there, which an S3 destination checking Content-MD5 would reject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: move OIDC provider and revocation records to this mode's name The record names hash the ARN or JTI with util.NewSha1, which differs under GODEBUG=fips140=only. On the first use of a filer, each store renames records whose name does not match the one derived from their content, so lookups, revocation checks and deletes find records written in the other mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: test the rename with the names each fips140 mode derives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: rename a record only if it is unchanged, under its new name's lock Two processes renaming after a mode switch could both list a record; if one renamed it and the provider was then deleted, the other wrote it back. The rename is now one filer transaction locked on the new name, like the stores' conditional writes, that requires the old entry to be unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f28d101a82 |
filer, mount: fail writes to a read-only path at once, as EDQUOT (#12823)
* filer: report a read-only create in the response, not as a gRPC error CreateEntry returned a storage rule's read-only verdict (a bucket over quota) as a status-less error, which reaches clients as codes.Unknown. Clients retry Unknown like a filer outage. A mount retried the create of every new file four times (1/2/4 s) before returning EIO, so each close() on an over-quota bucket hung 7 s, git on its index.lock included. Report it the way AssignVolume already does: a successful RPC whose response carries the text and FilerError_READ_ONLY. CreateEntryWithResponse and the mount's stream path already map that code to filer_pb.ErrReadOnly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a write to a read-only path at once, as EDQUOT On a read-only path (a bucket over quota), close() of a new file retried its create for 7 s and then returned EIO, and a failed chunk upload returned EIO as well. The verdict holds until the bucket is back under quota, so a retry gains nothing, and EIO names no cause. - isRetryableFilerError does not retry filer_pb.ErrReadOnly. - grpcErrorToFuseStatus, writeErrorToFuseStatus, and mkdir, symlink and link return EDQUOT for it. ENOSPC still means the cluster is out of space. - ShouldReassignUpload never reassigns on it, even when the path in the message contains "transport". - CreateEntryWithResponse and the stream path recognize the text an older filer sends ("read only: <prefix> ...", as codes.Unknown or as a bare message). The mount stops retrying even before its filer is upgraded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * admin, iam, shell: check a create's response, not only the RPC error A filer reports a refused create in CreateEntryResponse with a nil RPC error: an existing directory, a parent that is a file, a store error, and now a read-only path. Ten callers sent CreateEntry directly and looked only at the RPC error, so they took every refusal for success. An admin upload into a bucket that went read-only mid-upload reported success and skipped its chunk cleanup, and a session revocation that the filer refused left the session usable. They now go through filer_pb.CreateEntry, which returns the response's error as the call's error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb, mount, operation: read a filer verdict as an answer, not a failure A filer verdict, such as a read-only path, names the path in its message. Classifiers that fall back to matching that text for words like "transport" still read a refusal of /buckets/b/transport/f as a broken network: - shouldInvalidateConnection closed the shared filer channel, failing every other RPC in flight on it. - The mount's withFilerClient retried the call for about 13 s. filer_pb.IsFilerVerdict reports whether an error carries a sentinel that a filer response code maps to. shouldInvalidateConnection keeps the channel for such an error, and also for an older filer's read-only refusal that arrives as codes.Unknown. withFilerClient no longer retries it, and an upload with RetryForever no longer loops on a read-only assignment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep the first filer's verdict when another filer is down withFilerClient walks the filer addresses and keeps the last error. When the first filer refuses a write to a read-only path and the next one is unreachable, the walk returned the Unavailable from the second, so the call was retried for 13 s and then failed without the verdict. Stop the walk at a verdict and keep that filer as the one to try first: it answered, and every filer gives the same verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * java client: fail a metadata write the filer refuses in its response The filer now reports a create on a read-only path in CreateEntryResponse instead of as a gRPC error. writeMeta ignored the response, so closing a zero-byte file under a read-only rule reported success without creating it. 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> |
||
|
|
e012fca9a2 |
mount: keep lookups from stalling behind directory cache rebuilds (#12754)
* mount: release the meta cache lock between batches of a rebuild wipe deleteFolderChildrenForRebuild held mc's write lock while it listed every cached child of the directory and deleted them. Every metadata read in the mount (FindEntry, IsNameFresh, isOversized) takes the read lock, and a waiting writer blocks new readers, so while a large directory was wiped, lookups and getattrs in unrelated directories queued behind the scan. The scan gets slower as leveldb accumulates the deletion markers of earlier wipes of the same directory, which happens quickly once lookups rebuild expired directories. Wipe rebuildWipeBatchSize (1024) children per lock hold and drop the lock between batches. A child is judged pinned under the same lock that deletes it, so a local-only create is kept whether it was pinned before the wipe started or between batches. The listing that refills the directory already ran outside the lock, so batching adds no interleaving the build did not allow. Add LevelDBStore.BatchDeleteEntries, the counterpart of BatchInsertEntries. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: bound how long a lookup waits on the directory rebuild it starts Since #11268 a lookup whose parent's cache expired rebuilds the parent and every expired ancestor up to the mount root before it answers, and every lookup beneath them joins the same builds. With a slow listing (a large directory, a busy filer, or the meta cache lock held by another rebuild) a plain stat, an ls -l, or the parent touch after mkdir waited for all of it. Wait at most lookupRebuildTimeout (2s), then fall back to one LookupEntry RPC. Since #12206 the shared build does not run on the requester's context, so it keeps going after the waiter gives up and later lookups find the directory cached. A timed-out wait records a rebuild attempt, so lookups during the cooldown do not queue on a build that is already known to be slow. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: wait for the rebuild's listing in TestLookupDoesNotWaitOutSlowRebuild The build runs on its own goroutine, so the lookup that stopped waiting for it can return before the build's ListEntries reaches the filer. The test read `started` without waiting right after the lookup returned, which relied on an ordering nothing guarantees, and the ListEntries count taken afterwards assumed the same. Wait for the listing to arrive, bounded by the test's deadline. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: keep children inserted while a rebuild wipe runs A deferred create inserts its placeholder before Create registers the handle that pins it. The single-lock wipe made such an insert wait until it finished, so the placeholder survived; a batch that runs in that gap judged it unpinned and dropped it, and the rebuilt listing then omitted the file until its flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop a cached path that an event vacates during a rebuild wipe A build replays only the events later than its listing's snapshot and leaves the earlier ones to the listing, which starts after the wipe. With the wipe in batches a file's whole life fits inside it: created, flushed, then unlinked or renamed away. Both events are earlier than the snapshot and are skipped, the listing has no such file, and the placeholder the wipe kept stays in the published directory until the next rebuild. While a directory's wipe runs, an event buffered for it now takes the path it vacates out of the store at once, fenced by versions like any other event. After the wipe the store holds what the listing put there, and a removal earlier than the snapshot may still arrive, so from then on the event is left to the replay as before. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: check which file a removal took away during a rebuild wipe Two things the removal applied during a rebuild wipe got wrong. A placeholder is unversioned, so the version gate lets every removal through. One that arrived late, for an earlier file of the same name, took out the placeholder of a file created since. The entry the event took away is now compared with the cached one, by inode or, with no inode to compare, by creation time. An event that only names the file cannot tell and is taken at its word. The entry was deleted without OP=MV, so taking one name of a hard-linked file out of the cache also took one off the count its other names share. A replayed event that vacates a path already deletes with OP=MV. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: keep a removal the rebuild wipe declined out of the replay The wipe declines a removal when what is cached there is newer than the event or is another file than the one it took away. The event stayed buffered anyway. An unversioned listing clears the children's version records and replays every buffered event, so the declined removal then deleted the entry the wipe kept and the directory was published without it. A declined removal now buffers only the name it puts in place, so a rename still lands on replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check a declined removal again when the build replays it The previous commit dropped the removal half of an event the wipe declined, judged by the file cached when the event arrived. Earlier buffered events can replace that file during the replay: a listing attempt that failed leaves its events buffered, so the retry's wipe may see the first attempt's file while the replay puts a later one in place first. The dropped delete then left that later file published. The wipe now records which removals it declined, and the replay checks each against the entry it finds at that point, replaying only the name the event puts in place when that entry is still another file. A removal declined by version is replayed as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a declined removal's invalidation off the placeholder's handle After the replay the build invalidates every buffered event again, raised to the snapshot, and it still sent the original of a removal the replay rejected. A late delete of an earlier file then reached the handle of the placeholder at that name: the placeholder is unversioned, so the raised timestamp got past it and the handle was marked deleted. The replay's decision on a declined removal now replaces the event in the buffer, and the invalidations use what was replayed. It is made before the snapshot check, so a removal the listing covered is judged the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep an event's signatures on the halves a rename is split into A declined removal replays as its rename's create half, and a rename across a building directory is split in two. Both dropped the event's filer signatures, so a handle stamped by that filer no longer fenced the replayed invalidation by timestamp and could take older listed contents over newer ones it had read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drain invalidations around the declined-removal build check Invalidations run on a background worker, so the baseline could miss the removal's own and the final read could run before the build's arrived. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
c7d8b106d5 |
mount: follow a peer unlink to the surviving hard link for closed inodes (#12737)
* mount: drop a peer-unlinked name only while its inode keeps another Move the survivor check from followSurvivingLink into InodeToPath.RemoveAlias so the check and the removal happen under one table lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: follow a peer unlink to the surviving hard link for closed inodes A peer deleting one name of a hard link only moved an open handle to the surviving name. A closed inode kept the deleted name as its primary path, so the next open by the kernel's nodeid failed with ENOENT. Co-authored-by: skymazer <54621405+skymazer@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: share the cached-entry freshness check of peer invalidations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a name a local rename reclaimed before the peer unlink arrived Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a name a local rename or link gave the inode after an older peer delete The cached-entry check only covers a cached parent. InodeToPath now records, per hard-linked inode, the newest name a local rename or link gave it with the filer stamp, and the closed-inode peer-delete path keeps that name when the delete is older. The record lives in a side map dropped on Forget, so InodeEntry keeps its size class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: sign rename stream responses with the filer signature A rename response carries the stamp of the filer that applied it, so the mount can tell which clock the stamp belongs to, as it does for create acks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: order a peer delete against a local rename or link only on one filer clock The stamp of a local rename or link comes from the filer that applied it, and a delete logged by another filer runs on a different clock. Keep the name only when both carry the same nonzero filer signature; otherwise drop it as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop the local-name stamp fence for uncached parents Ordering a delayed peer delete against a local rename by filer stamp needs a record per alias, a shared filer clock, and the open-handle path to follow; that is a larger change than this fix. Back to the cached-entry check, which covers a cached parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: skymazer <54621405+skymazer@users.noreply.github.com> |
||
|
|
a3b2fd722d |
mount: report opens for reading with TouchAccessTime (-accessReport) (#12721)
* mount: report opens for reading with TouchAccessTime (-accessReport) An open answered from the metadata cache never reaches the filer, so a filer that tracks access cannot see that a cached file is still being read. With -accessReport, the mount sends one TouchAccessTime per open for reading, with the open time, whether the open was answered from the cache or not. Write-only opens are not reported. Reports go out in the background and never hold up the open: a report that does not fit in the queue is dropped, and drops and failures are logged once a minute. A filer that answers Unimplemented pauses reporting for 10 minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: address review of the access report - Drop reports still queued when reporting pauses; the filer that answered Unimplemented would answer them the same way. - Bound each filer attempt to 2s, so a filer that accepts the connection but never answers leaves time for the next one, and keep using the filer that answered. - Fail over only when a filer cannot be reached. Any answer, Unimplemented included, ends the walk. - Report an O_CREAT open of an existing file with read access, which comes through Create instead of Open. A new file has nothing to read and is not reported. - Stop the reporter on unmount: stop ends the workers and cancels the report in flight. - Say in the flag help that it has no effect unless the filer implements TouchAccessTime. - Tests no longer wait a fixed time to see that nothing else was sent; they look at the queue of a reporter that is not started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail an access report over only when the filer did not answer A status the filer sent ends the walk even when its message contains a word the transient classifier matches, so an Unimplemented answer still pauses reporting and a rejected request is not resent elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a filer selection made while an access report failed over A report that reached a later filer moves the mount there only if the selection it started from is still current, so a slower report cannot undo another call's failover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: share an access report's time with the filers not yet tried Each attempt is capped by an equal share of the report time left, so a row of stalled filers cannot use up the report before a healthy one later in the list is tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report the path an open for reading came through A create that opens an existing hard link reports the name it was given rather than the inode's first known name. Open reads the inode's path from the inode table rather than the handle's saved path, which other handle operations may rewrite concurrently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the access report stop and failover tests without races The post-stop report is checked on a reporter without workers, so no worker can take an accepted report before the check, and the failover test asserts that the stalled filer was tried first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: keep the shared channel when the peer answers with its own status gRPC never raises InvalidArgument, NotFound, AlreadyExists, FailedPrecondition, OutOfRange or DataLoss itself, so such a status is the peer's answer. It fell through to the string matching, and a message naming a path like /transport closed the cached channel and cancelled every other call on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: say which filer selection an access report keeps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: bound the in-flight call in the rejected-report channel test The call held in flight went through touchAccessTime, whose 2 s attempt cap could expire on a slow runner and fail the test on a healthy channel. It now uses callFiler with the test deadline. The wait for it to reach the filer also ends if it returns early or the deadline passes, and the blocked handler is released on every exit path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report each file at most once per -accessReport.interval Every read open used to send a TouchAccessTime, adding a filer metadata call per open. A path reported within the interval (default 1h) is now skipped; the last report times live in a bounded LRU. 0 keeps reporting every open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report an open again once the file was modified since its last report Within -accessReport.interval a read open was skipped even after a write, so the filer kept an atime older than the mtime until the interval ran out. relatime records that first read after a write; do the same by comparing the entry's mtime with the last report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep the report time apart from the mtime it saw Recording max(now, mtime) as the last report let a file dated a day ahead suppress reports for a day plus the interval. Record when the report was sent and the mtime the entry had, and treat any change of that mtime as a modification, so neither clock can stretch or shorten the interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
ecbf7af1ca |
mount: compare permissions against local ids without mapping them again (#12726)
* mount: compare permissions against local ids without mapping them again Access, open and create (without -defaultPermissions) ran FilerToLocal on entries that maybeReadEntry and maybeLoadEntry already return in local ids. Under a uid/gid map where a local id is also a mapped filer id, the owner was mapped twice and the check refused the file's own owner. 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 deferred or writeback placeholder with the caller's local ids. The second mapping in the permission checks used to cancel that out under a swapping id map; without it the owner of a placeholder was refused. Cache a mapped clone and keep the handle's entry in local ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test that a deferred create returns its entry in local ids Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
72ac9e96b2 |
mount: answer an interrupted read with EINTR, not EIO (#12723)
* mount: answer an interrupted read with EINTR, not EIO The kernel's FUSE contract (Documentation/filesystems/fuse/fuse.rst, "Interrupting filesystem operations") lets a filesystem either ignore an INTERRUPT or honor it by replying EINTR to the original request. Read did neither: the FUSE cancel channel cancels the read's context, the chunk fetch fails with "context canceled", and every error became EIO. Interrupts come from any signal the reader handles. Go's runtime sends SIGURG for goroutine preemption, so Go programs reading under load hit this on healthy data: on a 128-thread 64 KiB random-read test about 250 of 5 million reads failed with EIO, and none with GODEBUG=asyncpreemptoff=1. Read now returns EINTR when its own context was cancelled, the way dirReadStatus already does for directory reads and lookups do since #11717. Go's os.File retries EINTR, so those readers see no error. A cancelled read also skips the entry refresh retry, and neither read log line reports an interrupt as a warning or error. Failures without an interrupt stay EIO. Tests: TestReadInterruptedReturnsEINTR (fails on the old code with EIO), TestReadFailureWithoutInterruptReturnsEIO; weed/mount/... passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: require the failed-read test to reach the filer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip the read retry once the request is interrupted 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> |
||
|
|
11af0e0c12 |
mount: move an open file's read view to the chunks a merge wrote (#12722)
* mount: move an open file's read view to the chunks a merge wrote When a flush finds that a file's chunks take more than twice its size, maybeMergeChunks reads the file back and writes it again as new chunks. The commit that publishes them makes the filer delete the chunks they replaced. The flush put the new chunks into the handle's entry but left its read view on the old ones, so every descriptor that kept the file open went on reading the replaced chunks. Those read back until their volume is vacuumed. After that a read first retries the fetch of the missing needle for about 13 s; then refreshEntryForRead installs the filer's entry and the read is retried. The refresh skips a handle with writes it has not flushed, and such a read returns EIO instead. Files that are kept open and rewritten in place, such as PostgreSQL data files and SQLite databases, are the ones whose chunks bloat, so they are the ones that hit this. installRewrittenChunks puts the merge's chunks into the entry and the read view together, under the entry lock. Chunks attached while the merge ran were not part of it and stay. Flushes without a merge are unchanged. TestMergeMovesReadViewOffReplacedChunks covers the handle. TestReadOpenHandleAfterChunkMerge runs it on a real mount, with and without an unflushed write; for it, the fuse_integration framework starts mini on a free master port and exposes the address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drain uploads before a merge replaces the chunks Uploads attach their chunks without the handle lock, first to the entry and then to the read view, and writes that landed after doFlush drained the pages may still be uploading when the flush takes its lock. An upload that attached during the merge could keep a chunk older than data the merge already holds, or put a chunk the merge replaced back into the read view. Either outranks the merge's zero-timestamp chunk. When the chunks are bloated enough to merge, the flush now drains the pages again while its lock holds writes off, and takes the chunks again. FlushAll returns only after every upload has attached to both the entry and the read view, so nothing attaches during the merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: leave a pre-merge upload failure to the next flush The drain before a merge returned an upload failure through the metadata flush. doFlush then retried it as a filer error and answered EIO, where the page flush answers a full disk with ENOSPC. The drain is there only to wait for the uploads: a failure stays with the pages, and the next flush reports it as a write error, as it would without a merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep chunks attached while a flush installs its compacted list A write that lands after doFlush drained the pages can still be uploading when flushMetadataToFiler takes its chunk snapshot. Its upload attaches the chunk without the handle lock, and the plain flush then replaced the entry's chunks with the list compacted from the snapshot, dropping it from the handle and from every later commit. Keep chunks attached after the snapshot, as the merge path already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a merge's flush on a failed drain A failed upload found by the drain before a merge was only logged, and the flush went on to publish a size covering bytes that no chunk stores. It now fails the flush as a pageUploadError before anything is published; doFlush maps it with writeErrorToFuseStatus, as it does its own FlushData failure, and does not retry it as a filer error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: clone a flush's request entry under the entry lock The request snapshot cloned the live entry after GetEntry had released its read lock. Uploads attach chunks without the handle lock, so an AppendChunks that landed during the clone raced it on the Chunks field. Clone inside UpdateEntry, as content flush recovery does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: leave a merge to a later flush while uploads are pending Before a merge the flush drained the pages while it held the handle and publication locks. A writeback upload retries a transient storage error until it succeeds, so that drain could hold both locks for as long as storage stayed down, stalling reads, writes and stat on the handle. The flush now checks for pending uploads and, if any, publishes the compacted chunks and leaves the merge to a later flush. With none pending the lock still holds writes off, so nothing attaches during the merge, and a failed upload still fails the flush as a write error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep room for pending uploads when a flush merges onto a moved entry A flush that leaves the chunk merge to a later flush publishes while uploads are still pending, and writes that landed after the drain can be uploading on any flush. Merging a peer's inline content or a shrink into such a publication lets the upload attach its chunk next to the inline bytes, where reads never reach it. Tell createContentEntry when uploads are pending so the merge keeps room for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test chunk merges through the filer's chunk proxy, also under load The tests serve the filer's chunk proxy, and like the filer the fake deletes the chunks each commit replaces, so a read view still naming them fails: - TestFlushMergeThroughChunkProxy/Quiet: the flush merges, and reads through the open handle return the file from the merged chunk alone. - TestFlushMergeThroughChunkProxy/UploadInFlight: an older page is still uploading while a newer page of the same bytes has attached. The flush leaves the merge, reads return the newer page, and the next flush merges. - TestFlushMergeRacesWithWritesAndReads: four writers, three flushers and a reader on one handle, with uploads delayed at random. The writers pause now and then, so 14 to 18 flushes a run merge and the others leave the merge to a later one. Every read must succeed within 2 s, and at the end the handle and the filer must both hold exactly what was written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: let a held upload go when UploadInFlight fails The subtest's proxy holds the older page's upload until the test releases it, and only the passing path did. A failure in between left the handler blocked, so the proxy's cleanup waited on it and the failure surfaced as a suite timeout. Release it from a cleanup as well, once, and bound the waits for the upload and the drains. 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> |
||
|
|
de5b3305a7 |
mount: ask the filer again when a deferred create is published mid-lookup (#12720)
* 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> |
||
|
|
4f70ad015e |
mount: fail the write when the swap file chunk cannot be created (#12655)
* mount: fail the write when the swap file chunk cannot be created #7957 added a nil check after NewSwapFileChunk so a failed swap file creation returns an error instead of panicking. The result was assigned to pageChunk, a PageChunk interface, before the check, and an interface holding a nil *SwapFileChunk is not nil, so the check never fired: SaveDataAt stored the nil chunk and panicked in WriteDataAt. Check the *SwapFileChunk before converting it. The new test points the swap directory below a regular file; on master it panics in SwapFileChunk.WriteDataAt. Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com> * mount: grow the file only after its write is buffered Write set the new size, times, pending append offset and uncommitted bytes before AddPage. When AddPage failed (now that a swap file chunk that cannot be created returns an error), the write was reported as failed but the larger size stayed on the handle's entry, so the next flush published it with a hole where the data should be. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report a partly buffered write as a short write PageWriter.AddPage fills one chunk at a time, so when a later chunk cannot be created the earlier chunks already hold their bytes. Return how much was buffered, and let Write grow the size and times over that prefix and report it, instead of failing the whole write while the prefix still reaches the next flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: report the bytes a failed copy_file_range already buffered A streaming copy whose page fails partway returned an error even though earlier pages, or the start of the failing one, were already buffered and would reach the next flush with the destination size left short. Count the buffered bytes, grow the destination over them, and return them as a short copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: free the copy test's destination pages The buffered memory chunk counts toward the process-wide memory chunk ceiling, so repeated runs of the test pushed later ones onto the unusable swap directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: count only the bytes a swap chunk stored A swap chunk whose file write fails stores a prefix or nothing, but SaveDataAt returned no error and AddPage counted the whole span as buffered. SaveDataAt now reports the short write, and AddPage passes the stored count up so a write is never acknowledged past it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fail a partly buffered writeback write Kernel writeback ignores the count in a WRITE reply, so a short write there drops the unbuffered rest without an error. A write flagged as page-cache writeback now keeps its buffered prefix but returns the error, which the kernel reports on fsync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Signed-off-by: anant <170962632+antcybersec@users.noreply.github.com> Co-authored-by: anant <170962632+antcybersec@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
53377bcb5d |
mount: keep a handle dirty when a write lands during its flush (#12652)
A flush uploads the dirty pages without the handle lock, then commits the entry under it. A write in between grows the entry's size, but its pages are not in the committed chunks. Clearing dirtyMetadata then made the next flush skip the commit, leaving a file with the new size and no chunk for the write, which reads back as zeros. Count page writes on the handle and clear dirtyMetadata only when none landed since the flush started uploading. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6ad4b07598 |
mount: scope and order the final-release writeback fence (#12651)
* mount: fence a dropped handle only when it holds unpublished content dirtyMetadata is also set by chmod, xattr and fallocate, so a failed metadata-only close refused every later write of the inode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fence the inode before its last handle leaves the handle map A reopen between the map removal and the fence could publish at the stale kernel EOF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fence a failed metadata flush only when the handle holds content A refused synchronous flush or an abandoned writeback metadata flush of a handle with only chmod, xattr or fallocate changes fenced the inode, so later writes were refused until FORGET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: count a size change on an open handle as unpublished content A truncate or extend through an open handle changes the entry's size and chunks, but it set only dirtyMetadata. A failed close then skipped the final-release fence, so a reopen before FORGET could publish against the untruncated entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: mark copied content dirty before each page of a streaming copy A copy that failed or was cancelled after earlier pages were accepted left dirtyContent false, so the final-release fence skipped that content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: mark copied content dirty only after a page is accepted A copy whose first page is rejected leaves the destination unchanged and the kernel EOF where it was, so fencing the inode on release only blocked later writes until FORGET. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip the server-side copy while the destination holds unpublished content A whole-file server copy clears dirtyContent when it commits, so a page a cancelled streaming copy left behind would lose its release fence. Fall back to the streaming copy instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip the server-side copy while the source holds unpublished content The filer copies the stored source, so pages still pending on the source handle would be missing from the destination. The streaming copy reads them through the dirty pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the publication fence before a server-side whole-file copy The filer copy publishes the destination without going through the flush-time guard, so a fenced writeback inode could still take new content before FORGET. Fall back to the streaming copy, whose flush is guarded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
65ecb6aa12 |
fix(mount): prevent negative activity-score shifts (#12631)
fix(mount): bound activity decay shifts across time regressions |
||
|
|
10f8b2d5b1 |
mount: guard peer-truncate gaps, stale append EOF, and terminal writeback refusal (#12630)
* mount: guard append gaps over concurrent content merges * mount: fence a writeback inode when its async publication is abandoned A drain that gives up on a non-precondition error left the token clear, so a reopened writeback handle could publish past the stored EOF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fence a writeback inode when its async data flush fails Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: fence the inode when its last handle drops uncommitted content A synchronous release whose final flush fails destroys the handle's dirty pages, while under writeback the kernel EOF already counts them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b50d4a9cab |
mount: don't spend the close()/fsync commit deadline on uploads (#12641)
* mount: start the close()/fsync commit deadline after the data upload Flush, Fsync and the truncate path of SetAttr create the 30 s metadataFlushTimeout context on entry and pass it to doFlush, so the clock also runs through FlushData, the upload of the dirty pages. That upload has its own timeouts and retries. When an assign through a stalled filer or a slow volume server takes most of the 30 s, CreateEntry then fails at once with "context deadline exceeded" and close() returns EIO for data that was already stored. The deadline is meant for the commit alone (#10102: "a healthy CreateEntry completes in well under a second"). doFlush now takes the commit timeout and starts the deadline once the data is uploaded. close() still cannot hang on a stuck filer: the commit keeps its 30 s bound. Release and the flush before a rename pass 0, as before (no overall bound, only the per-call filer timeouts). Seen in production on a training cluster: a 30 s stall of one replica's disk, and a filer that stalled for about 30 s, each failed close() with EIO although the upload had succeeded. Tests: close(), fsync() and a truncate below dirty data, each after an assign slower than the deadline (all three fail before this change), and a filer that never answers CreateEntry still fails close() at the deadline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: charge the flush commit deadline only for its filer calls Starting the 30 s deadline after the data upload is not enough. flushMetadataToFiler does more than call the filer before it commits: it waits for the handle's locks, reads the file back and uploads it again when its chunks are bloated (maybeMergeChunks), and uploads a manifest once enough chunks have built up (MaybeManifestize). None of that takes the context. When it outlasts the deadline, CreateEntry again fails at once with "context deadline exceeded", and close() or fsync() returns an error for data that was stored. The deadline becomes a budget, commitBudget, charged only while a filer call of the commit runs: CreateEntry, and the read of a changed hard link before it. The attempts of one flush share it, and a flush is not retried once it is spent, so a stuck filer still fails close() after 30 s. Release, the flush before a rename and the async flush pass no budget, as before. Seen in production: the merge of a 1.8 MiB sqlite file with 183 chunks took 32 s because one chunk's read first tried a volume server that was down, and the commit failed 32 microseconds after the merge finished. Tests: a flush whose manifest upload is slower than the deadline commits (it fails without this change), and the filer calls of one flush share the budget. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * mount: give the stalled-lookup refusal test the new doFlush argument TestContentFlushRefusalWithStalledLookup came in from master after this branch changed doFlush's signature, so the merged package did not build. 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> |
||
|
|
e0890391ac |
mount: keep a refused content create refused when the stored-entry read stalls (#12629)
The read of the stored entry ran in the create's filer callback, so a read that hit the call deadline turned the refusal into a filer timeout, and both retry layers resent the refused create. Read it in its own call, bounded to one filer call. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4fc41872e3 |
mount: keep an open file publishing when a peer unlinks one of its hard link names (#12613)
* mount: record a hard link's looked-up names on its inode Lookup mapped a second name of a hard-linked file to the existing inode without adding it to the inode's names, so GetAllPaths missed it and the final forget left it mapped to a released inode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep an open file publishing when a peer unlinks one of its names A delete event from another client marked the inode's open handle deleted even when other names still held the hard-linked file, so every later fsync reported success without saving metadata. The delete event's entry carries the link count the filer decided on, so an alias delete now drops only that name, keeps the handle on a name this mount knows, and has the next flush read the survivor's stored entry before publishing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test peer unlinks of a hard link name held open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: leave an unlinked file out of the periodic metadata flush flushFileMetadata did not check the handle's delete mark. A file unlinked while open before its deferred create reached the filer was created again by the next periodic flush, which expects no entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read a pending link change before a periodic metadata flush Only flushMetadataToFiler applied linkRefresh. After a peer unlinked one name, the periodic flush kept publishing over the old link count, so the filer refused every one until a regular flush ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test the periodic flush after a peer unlinks a hard link name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
68b6a2ed08 |
mount: model the refused async flush as a replaced file in recovery tests (#12628)
A peer's chunk append now merges into the flush, so these tests no longer saw the refusal they exercise. A replaced file is still refused. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d1a97f4c3d |
fix(mount): retain refused async metadata before releasing handle (#12598)
* fix(mount): retain refused async metadata before releasing handle * mount: sync the failed-metadata directories with util.FsyncDir Directory fsync fails on Windows, where the mount also builds, and returns EINVAL on some filesystems. Either kept the retention loop retrying a record that could never be saved, so the drain never finished. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep failed-metadata records in a per-user directory The write cache root defaults to the shared temp directory. The first mount to save a record created failed-metadata there as 0700, so another user's mount could never save one and its drain retried forever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop the async conflict probe test TestContentAsyncConflictKeepsRecoveryRecord drives the same refused drain with the retry backoff stubbed out; the probe slept through the real backoff (7 s) and its kept-handle branch could not run. Its peer-entry check moves into the recovery record test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
911bfe4014 |
mount: stop overwriting the mount root's filer entry (#12623)
When a mount is rooted at an existing directory, two code paths replace that directory's filer entry with one the mount builds itself: - every mount start re-creates the root with a non-exclusive mkdir, which the filer handles as an update of the whole entry; - creating or removing an entry directly in the root saves the root's entry to touch its mtime, and maybeLoadEntry synthesizes that entry from the mount options instead of reading the filer. The filer keeps only crtime and inode on such an update, so the root loses its mode, owner and extended attributes. When the root is a bucket it also loses the bucket quota, which silently drops to 0 (unlimited), and the settings S3 keeps on the bucket entry. The explicit allowEmptyFolders=false that #11370 meant to keep is replaced by true at every mount start, because the mkdir has wiped it before ensureBucketAllowEmptyFolders looks. Create the root only when a lookup says it is missing, and then exclusively. Leave the root out of the filer-side mtime touch: its attributes come from the mount options (setRootAttr), so the filer copy of its mtime was never visible through the mount anyway. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
737ef68a11 |
mount: keep publishing an open file through its surviving hard link (#12609)
* mount: keep flushing an open file whose other hard link survives an unlink Unlink marks the inode's open handle deleted so no flush recreates the removed name. When the entry was one of several hard links the inode lives on under another name, yet the mark stayed and every later fsync and close returned OK without publishing metadata. Lift the unlink's own mark once the name is gone and the inode still has a path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: carry a link's stored entry into the file's open handle Link rewrites the source entry with the new hard link id, count and times, but an open handle kept its old base and entry. Its next conditional content flush was refused (EIO), and an unconditional one would have dropped the hard link id. Move the handle onto the stored entry when only the link fields and times changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: carry an alias unlink's stored entry into the open handle Removing one of several hard links lowers the stored link count and stamps a new ctime, and the handle may still hold the removed name. Look up the entry at the name the handle flushes through and adopt it, so the next content flush matches the stored entry, writes the right count, and attribute saves address the surviving name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test an open handle across link and alias unlink Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read an alias unlink's lost entry again at the next flush When the read of the surviving entry right after an alias unlink fails, the handle kept a base with the old link count and ctime, and every later flush was refused even after the filer recovered. Leave the hard link id on the handle and have the next flush read the stored entry and adopt it before publishing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: publish a queued close before unlinking a name another link keeps With writeback caching, close only queues the flush. Unlink marked the handle deleted before waiting for that flush, so the flush skipped its metadata and the surviving link kept the content from before the close. When another link keeps the file, wait for the queued flush first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: let a queued close reach the filer before linking the file With writeback caching a new file is created on the filer by its queued close, and a listed directory serves the source from the cache, so a link right after close updated a name the filer did not have yet and failed with EIO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip a link change no newer than the handle's entry A link change carried into the handle could replace a base already moved past it by a later acknowledgment. Use the same clock-domain check as installAckedEntry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a link change's ctime in the dirty entry The flush does not restamp times, so a dirty entry carrying an earlier write's ctime moved the filer's ctime back from the link or unlink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: flush through the file's current name when the resolved one is gone doFlush resolves the name before uploading the data. An unlink of that alias, or a rename, in the meantime sent the publish to a name the file no longer has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep the pending link read when its name is already gone A flush could read the removed alias name, find nothing, and drop the pending read of the surviving link, leaving the stale base in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test link and alias unlink across queued closes, flush races, versions and ctime Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: pick a flush's name again once its locks are held An unlink or rename that lands between the name pick and the locks would otherwise send the flush to the removed name, where the create guard fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test a flush waiting on its lock through an alias unlink Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the flush target after every lock acquisition A flush whose name kept changing published to the name chosen before its last lock wait. Check after each acquisition and return a retryable error once the attempts run out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test a flush whose name changes during every lock wait Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
652648d9c4 |
mount: merge concurrent content changes from another mount instead of failing or dropping them (#12596)
* mount: merge a refused content flush onto the stored entry A content flush conditioned on the handle's base failed with EIO whenever a peer had changed the file since, so two mounts appending to one file could not both close it cleanly. On a refused condition, reread the entry and replay this handle's changes since its base onto it: the chunks it added or dropped, and the attributes, extended keys and inline content it changed. A local truncation keeps its size and clips the peer's chunks to it; otherwise the larger size wins. The merged entry is published against the stored one, up to three times, and installed in the handle so its next flush keeps the peer's chunks. A replaced or deleted file is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: merge a peer's content change into a dirty handle A subscription event carrying a peer's content change replaced a dirty handle's entry and discarded its unflushed pages, so the handle's writes were lost and its close still returned OK. Fold the peer's entry into the handle with the same merge a refused flush uses, keep the dirty pages, and take the peer's entry as the new base. A replaced file still invalidates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: stop a flush merge once a filer accepts the write withFilerClient can call the callback on several filers. A refusal from one left its stored entry behind, so a later filer's success went on to another merge round. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse a merge that puts inline content next to chunks A read inside the inline bytes returns them without looking at chunks, so one side's inline content merged with the other side's chunks hid data after a successful flush. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse to merge a whole-file rewrite over a peer's chunk change maybeMergeChunks re-uploads the handle's whole view as unstamped chunks. Merged after a peer's change, they tie with a peer's own rewrite or bring back a range the peer truncated, so that flush fails as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: clip peer chunks at the lowest truncate, not the final size A handle that truncated and then wrote past the old end ends up larger than its base, so the merge did not see the truncate and kept the peer's chunks inside the range the truncate cleared. SetAttr now records the lowest size truncated to over the current base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a peer's truncate when the handle left the size alone The merge took the larger of the handle's and the stored size, so a peer truncate came back as a zero-filled tail when the handle only overwrote bytes inside it. The stored size now stands unless the handle changed its size or wrote past it, and rebasing keeps only the growth writes made after the flush was taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry a read view whose merged manifests did not resolve A failed SetChunks leaves the chunk group answering every read with the resolution error, and nothing re-ran it while the entry stayed the same. The handle now marks such a view (on rebase and on SetEntry) and the next read or lseek resolves the entry's chunks again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a dirty handle's writes when a peer change cannot merge The new merge refusals sent a peer event on the same file down the old path, which discarded the dirty pages and adopted the peer's entry, so close returned OK without the writes. The handle now keeps its writes and base, and the flush meets the conflict and fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep an unpublished truncate across a peer's base change The truncate mark was tied to the base pointer, so a peer event that moved a dirty handle's base (a merged content change or a metadata-only change) dropped it, and a later merge on a regrown file kept peer chunks inside the truncated range. Those base moves now carry the mark; a flush ack or a discarded handle state still clears it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: wait for the flush before merging a shrink over buffered writes A write inside the file leaves its bytes in dirty pages without moving the size. Merging a peer's truncate then adopted the smaller size, and the chunk uploaded later sat past it, unreadable through the handle. The event path and the periodic metadata flush now refuse a merge that shrinks the handle; the close flush uploads the pages first and merges then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: tell a shortened base chunk from a whole-file rewrite A truncate shortens a base chunk in place, so it gets a new reference key, and an old chunk can carry no timestamp. The rewrite refusal now applies only to unstamped chunks whose file id is new to the base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: check the creation time when the base has no inode An entry without an inode or hard link id matched any replacement at the same path, so a stale handle could merge into a different file. Without an inode the merge now needs the same creation time. The filer keeps it across updates; only a synthesized base has neither and still merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a dirty handle's writes when a peer replaces the file A peer entry with another inode at the handle's path went down the fallback that destroys the dirty pages and installs the replacement, so close returned OK without the writes. The handle now keeps its writes and base like it does for an unmergeable change, and its flush refuses to update the replacement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: build the content flush tests on freebsd The invalidation tests, which every platform compiles, now use the content flush helpers, so the freebsd cross-compile vet failed with undefined: flushConditionEntry. Nothing in the file is freebsd-specific. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep a dirty handle's base when a same-content file replaces it A replacement with the base's chunks but another inode counted as a metadata-only change, so the dirty handle adopted it as its base and the next conditional flush overwrote the new file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: bring a peer's metadata change into a dirty handle A metadata-only event moved a dirty handle's base but left its live entry, so the next flush read the peer's chmod as a local edit and published the old mode back. Replay the handle's own changes onto the peer's entry instead, as for a content change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: wait for the flush before merging peer inline content over buffered writes A buffered write is not a chunk yet, so a merge could install a peer's inline content that later reads return ahead of the write's chunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: track a whole-file chunk rewrite on the handle The merge told a rewrite by its unstamped chunks, which a manifest fold hides: manifests are unstamped either way. Record the rewrite against the base it was made from, carried across peer base changes like a pending truncate, and refuse the merge from that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: refuse a merge that shortens a manifest at the truncate Clipping a manifest reference leaves its members whole, so peer bytes past the handle's truncate could reappear once the file grew again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: flush a dirty handle after a peer replaces its file The replacement test checked only the retained handle state. It now flushes against a filer holding the replacement, including one with the base's content, and checks the flush fails and leaves it unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test an append fsync after a peer's attribute-only change A second mount's acknowledged chmod, chown, utimes or setxattr leaves the content alone, so the writer's conditional content flush must still publish its append and keep that change. On master the refused flush surfaces as EIO from Fsync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c2b2ed769b |
fix(mount): preserve appended chunks during stale attribute updates (#12593)
* fix(mount): preserve acknowledged chunks during attribute updates * mount: keep the WFS field block aligned Adding the publication-lock fields inside the aligned block made gofmt re-indent 25 unrelated lines. Put them in their own group after dirIdleEvict, matching the enterprise layout, so syncs do not conflict there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: finish attribute saves through a FUSE interrupt saveEntryAttributes derived its RPC context from the syscall's cancel channel, so an interrupt while the conditional UpdateEntry was at the owner returned EIO for an update the owner then applied, and skipped the local install and retention. Keep the metadata deadline but drop the cancellation, like the other metadata mutations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: map attribute CAS ids in place instead of cloning the entry saveEntryAttributes cloned the whole entry three times per attempt only to rewrite uid/gid for the filer, and each clone is as large as the chunk list. Switch the ids in place and restore the exact local values after the call, keeping one clone. The test now checks the reply carries the local uid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: compare attribute updates against the filer's own uid/gid With -map.uid/-map.gid, a filer id that is also a mapped local id reads back unchanged and maps forward to another filer id. The IF_ENTRY_EQUAL expected entry then never matched, so chmod, utimes and xattr changes on such files failed with EAGAIN after three attempts, and an update would have rewritten the owner. Keep the filer ids read with the entry for the ids the syscall leaves alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(mount): align attribute retention with read lock order * mount: take the handle lock before entryLock in the attribute snapshot attributeEntrySnapshot held entryLock while it queued for the shared handle lock. A Read holding that lock waits on entryLock, the snapshot waits behind a queued exclusive (an invalidation or a Write), and the exclusive waits on the Read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(mount): complete handle lock order and preserve explicit ID intent * mount: re-read a refused attribute update from the file's owner filer The filer checks the IF_ENTRY_EQUAL condition on the owner of the path's write route key. The retry read any filer, so behind one that had not applied the owner's latest update, every attempt sent the same stale base and the syscall failed with EAGAIN. Read from the owner once the lock ring is known, like lookupFilerEntry, but keep the filer's raw ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d7ae08ecad |
fix(mount): refuse stale whole-entry content flushes (#12594)
* fix(mount): condition content flushes on the observed entry * mount: stop retrying a flush the filer refused on its condition The filer reports a failed CreateEntry condition as FilerError_PRECONDITION_FAILED in the response, which surfaces as filer_pb.ErrPreconditionFailed rather than a FailedPrecondition status. The flush retry loop treated it as transient and replayed the refused flush three more times over 7 s before returning EIO. The test filer now answers like the real one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: take the handle base from the entry the filer stored After an acknowledged flush the handle base was the requested entry, but the filer stores it with a fresh commit_ts_ns (and fills crtime, inode, atime), so the next IF_ENTRY_EQUAL flush on the same handle never matched: write, fsync, write, fsync returned EIO, as did close after a periodic metadata flush and the first flush after an eager create. Use the stored entry from the acknowledgement's metadata event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: condition the periodic metadata flush like the close flush The periodic metadata flush of an open, dirty handle sent the same whole entry through an unconditional CreateEntry, so a file held open past the flush interval still overwrote a peer's acknowledged append, and the close flush then matched the overwritten state. Both paths now publish through one helper that carries the handle's write condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: republish a refused flush once when the stored entry is unchanged A handle's base can differ from the stored entry without any peer write: a rename while the file is open restamps the entry under its new name, and with -map.uid a filer id that is also a mapped local id does not map back to itself. Each made every flush of the handle fail with EIO. On a miss, read the stored entry and, if it still holds the observed state apart from name, commit stamp, id encoding and derived size, retry once with that entry as the condition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: take the filer's entry once a write open holds the DLM lock The lock orders this writer after the previous holder, but the holder's flush may not have reached the local cache yet, so the handle's base named the entry from before the wait and the conditional flush refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: share the open-existing path of Create Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: open the file a previous DLM holder created during a deferred create A deferred create never asks the filer, so a create that waited for the lock went on to publish over a file the previous holder had just made, and its flush expecting no entry was refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: send the lock ring snapshot to mounts A mount running -dlm is a lock client like the S3 gateway, and needs the ring on connect to reach a file's owner filer before the next membership change is broadcast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: follow the masters' lock ring under -dlm The lock client only knew the seed filer, so every lock took the forward hop and the mount had no way to tell which filer owns a file. Subscribe to the masters named by the filer, like the S3 gateway, and wait briefly for the first ring before serving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: read the DLM-ordered entry from the file's owner filer The filer checks a flush's condition on the owner of the path's write route key, and another filer may not have applied the previous holder's flush yet. Look the entry up on that owner once the ring is known. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e0f8438284 |
mount: retry a writeback metadata flush until the filer answers (#12578)
* mount: keep the filer status in the flush create error flushMetadataToFiler formatted the CreateEntry error with %v, so callers classifying it saw only the message, which includes the file path. Wrap it so the gRPC status the filer sent stays reachable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry a writeback metadata flush until the filer answers With -writebackCache, close() returns before the chunk references reach the filer. The deferred flush gave up after four attempts, about a minute once each attempt's own filer retries are counted, then released the handle: a longer filer outage dropped the file even though write() and close() had succeeded, and its uploaded chunks became orphans. Keep retrying for as long as the filer is unreachable, as the writeback chunk uploads already do. A filer that answers with an error still ends the flush after the bounded attempts, and an unlink of the draining file still ends it on the next attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry only an unanswered filer call without a bound The unbounded phase used util.IsTransientError, which falls back to matching the error text. A refusal the filer sends in its response (read-only, name too long, a plain error string) has no gRPC status, and the flush error carries the file path, so a file named like "unavailable-transport.log" kept retrying against a filer that answered. Retry without a bound only when the call failed with a gRPC Unavailable status: the dial, the connection or the mount's call deadline gave out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fd81a50c57 |
mount: keep retrying writeback chunk uploads through a volume outage (#12465)
* mount: keep retrying writeback chunk uploads through a volume outage With -writebackCache, close() returns before the data is uploaded. When the volume servers stay unreachable past the upload's own retry (~20 s), the chunk was dropped and the file never appeared, with no error to the application. Retry transient upload errors with the same bytes until they succeed, unless the dirty pages were discarded. Permanent errors and the synchronous mode keep failing as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test writeback upload retries and the cases that still fail Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * operation: keep the filer's read-only verdict on assign failures UploadWithRetry flattened AssignVolumeResponse errors into a string, so callers could not tell a read-only rule from an outage. Wrap the filer's coded error so errors.Is(err, filer_pb.ErrReadOnly) works; the message is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: retry writeback uploads the upload layer reassigns, never read-only A filer proxy that cannot reach the volume answers 500 with an empty body, which util.IsTransientError does not match, so that outage still dropped the chunk. Also retry what operation.ShouldReassignUpload takes. A read-only rule stays final even when its path or message contains a transient word such as "unavailable". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: stop a writeback upload once its dirty pages are discarded Destroy() was only seen after a failed attempt, so a truncate during the retry wait still started another upload, and a chunk that finished after its pages were replaced was attached to the new content. Check before each attempt, and drop the chunk instead of attaching it; volume.fsck reclaims it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: keep Destroy from slipping between the discard check and the append truncateEntry destroys the pages and then installs the new entry, so a Destroy landing after the check but before AddChunks put the old chunk into the replacing entry. Hold one lock across the check and the append, and take it in Destroy while setting the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: leave the Windows interrupt drain to the capped filesystem hook Interrupt hooks run in reverse registration order, so the Windows hook ran before the filesystem hook and waited on pending writeback flushes without a bound. With writeback uploads now retrying through an outage, Ctrl-C could wait until the volume servers came back. Unmount only, as on Linux, and let the filesystem hook drain for at most 30 s and keep the write cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: test a writeback upload whose assign keeps timing out With every volume server gone the assign RPC times out until the filer client gives up; that error must be retried like a refused upload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fd493f2547 |
mount: refuse to attach opens to a draining file handle (#12219)
* mount: refuse to attach opens to a draining file handle With the writeback cache, releasing the last open of a file leaves the shared FileHandle in the map at counter zero while an async flush drains it; the worker removes the map entries once the flush commits. AcquireHandle waits for a pending flush and then attaches, but the two steps are not atomic: a release can slip in between, drop the counter to zero, and queue the drain while the opener goes on to mint a new file-handle id on the draining handle. When the drain completes, RemoveFileHandle deletes every fh id for the inode -- including the one just minted. The kernel still holds that id, so its next FUSE_READ gets ENOENT from GetHandle; the failed read leaves the folio not uptodate and the kernel surfaces EIO to userspace. This was the flaky TestWritebackCacheConcurrentMixedOps failure. AcquireFileHandle now refuses to attach when the shared handle has reached a zero counter and reports it as draining. AcquireHandle and the Create path retry the whole wait-resolve-attach sequence; the next pass blocks on the pending flush (flag registration and the counter drop share pendingAsyncFlushMu) and builds a fresh handle from the post-flush entry. The DLM-failure release in AcquireHandle also goes through ReleaseHandle so it cannot strand a counter-zero handle outside the drain bookkeeping. Removes the refreshEntryForRead retry from #12206, which worked around the symptom by refetching the entry after the fh id was already gone. Test: TestAcquireFileHandleRefusesDrainingHandle covers the refusal and fresh-handle path; TestWritebackCacheConcurrentMixedOps and an amplified concurrent-overwrite repro run clean. * mount: keep refresh-on-error retry for stale-chunk reads |
||
|
|
3955e7218f |
mount: keep the shared directory build out of the requester's context (#12206)
* mount: keep the shared directory build out of the requester's context The shared directory build behind EnsureVisited is a singleflight call: the first requester for a path owns the build, and every later requester for the same path waits on that same build. The build ran on the owner's request context, so a FUSE request that returned -- or that the kernel interrupted -- canceled the build for everybody waiting on it. A waiter whose own context was still alive then received somebody else's cancellation. weed/mount/weedfs_dir_read.go classified a canceled read as EINTR only when the local context was done, so such a waiter fell through to fuse.EIO: the kernel handed EIO to readdirent, kubelet's applyFSGroup failed, and the volume never mounted. Build the shared directory on a context that keeps the request's values but not its cancellation, and report a canceled read as EINTR even when the local context is still alive. Waiters still abandon on their own context, so a canceled request stops waiting immediately. This follows up #11717, which made the wait abandonable and mapped the local cancellation to EINTR, but left the shared build itself on the owner's context. The surrounding build lifecycle calls already use context.Background() for the same reason. Test: TestEnsureVisitedSharedBuildSurvivesOwnerRequestCancel reproduces the cancellation with a fake filer and fails without this change. * mount: classify gRPC-canceled directory listings as EINTR * mount: log only real directory read failures, not interruptions * mount: keep shared section refresh out of the requester's context * mount: let section-refresh waiters leave on their own context The shared refresh flight now outlives the requester that started it, but callers still blocked in singleflight.Do until it finished — an interrupted directory read could not stop waiting, and the caller's own deadline never applied to the wait. DoChan + select on the caller's context restores early abandon while the detached refresh still completes for the remaining waiters. * ci: re-run FUSE integration after a flaky writeback-cache failure * mount: refresh a stale entry once before reporting a read error A read resolves chunk views from the handle's entry. A concurrent overwrite commits a new entry whose replaced file ids the filer queues for deletion; the open handle only learns the new chunk list when the metadata invalidation lands. A fetch that lands between the volume delete and the invalidation names data that is already gone and the read reports EIO. On a chunk read error, wait out any in-flight async flush, re-read the entry from the filer, install it when it outranks the handle, and retry once. An unchanged version means the failure is genuine. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * mount: fence the read-error entry refresh by file identity Two guards on refreshEntryForRead's install path: the unlocked dirtyMetadata read raced with Write under the handle lock — drop it, installAckedEntry already checks under that lock, and it now fences isDeleted handles the same way. And a saved path can name a different file after unlink/reuse, so refuse the refresh when the fetched inode disagrees with the one the handle holds. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: user.email <chrislusf@users.noreply.github.com> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> |