Repository navigation
fix(posix): write the fs-revisions copy from the stored file - #841
Open
Mortimer-RR wants to merge 1 commit into
Open
Mortimer-RR wants to merge 1 commit into
Mortimer-RR wants to merge 1 commit into
Conversation
With enable_fs_revisions, Tree.WriteBlob passes a copy target to Blobstore.Upload to keep the "current" version of the file. On the default code path Upload renames the upload source into place first and then tried to open the source again to write that copy. The open fails, so WriteBlob returned an error after the blob was already stored, and finalizing the upload failed, leaving the file stuck in processing. Read the copy from the node's file instead, and fsync and close it with error checks. canUseRenameForUpload was a plain bool written by concurrent uploads when a rename failed with EXDEV. Make it an atomic.Bool and use one value per upload. Assisted-by: Claude:claude-opus-5-5
Mortimer-RR
force-pushed
the
fix/fs-revisions-copy
branch
from
October 9, 2026 04:05
9f10bb6 to
9b09e83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #840
Changes
pkg/storage/fs/posix/tree/revisions.goRestoreRevision: copies the revision into atemp file in the space's
.oc-tmpdirectory, fsyncs it, carries over the target'suser.oc.*xattrs, mode and owner (a failed chown is logged, not fatal), applies therevision's checksum, blob id, blob size and type attributes and the mtime, and
rename()s it over the target, likeblobstore.Uploaddoes for uploads. The mtime is thenset through the metadata backend so its cache picks up the new attributes. The "current"
copy for
EnableFSRevisionsis unchanged.pkg/storage/pkg/decomposedfs/upload/upload.goCleanup(versionIDbranch): takes thenode's metadata lock and re-reads the status through the metadata backend (bypassing the
node's attribute cache). It only restores when the node is still
processing:<this session>. Otherwise it logs, keeps the node, and leaves the revision as an ordinaryversion. The lock is released before the rest of
Cleanup, whoseUnmarkProcessinglocks again through a different node object.
Tests
pkg/storage/fs/posix/tree/revisions_test.go:main: target truncated to 0 bytes);main: 3831 of3841 reads saw partial content).
pkg/storage/pkg/decomposedfs/upload_async_test.go, "two uploads overwrite an existingfile in parallel": the older upload fails after the newer one succeeded; the newer content
and the original version must survive (fails on
main: the file is rolled back from 20to 10 bytes).
go test -raceclean onpkg/storage/fs/posix/tree,pkg/storage/pkg/decomposedfsandits
uploadpackage.pkg/storage/...passes.(upstream: 50 of 50 bad); aborting the older upload keeps the newer content (upstream:
rolled back).
Note: downloads still don't take the node lock; with the atomic rename they don't need it
for consistent bytes (an open file descriptor keeps the old inode).
🤖 Generated with Claude Code