Skip to content

fix(posix): keep a handle on the blob for the copy target - #807

Merged
aduffeck merged 1 commit into
opencloud-eu:mainfrom
NickWalters:fix/posix-blobstore-copy-target
Oct 13, 2026
Merged

aduffeck merged 1 commit into
opencloud-eu:mainfrom
NickWalters:fix/posix-blobstore-copy-target

Conversation

@NickWalters

@NickWalters NickWalters commented Sep 20, 2026 •

Copy link
Copy Markdown

Fixes opencloud-eu/opencloud#3462

Problem

With STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS=true, every upload with content stays in processing and answers 425 to every read, download and delete. It happens when the upload area and the blobstore are on the same device, which is the recommended layout. Affected since reva v2.46.8 (OpenCloud 7.2.4).

How to reproduce

  1. Use the posix driver with STORAGE_USERS_POSIX_ENABLE_FS_REVISIONS=true. Keep the upload area and the spaces on one filesystem.
  2. Upload a file of 1 byte or more.
  3. The log shows could not finalize upload ... could not open source file '.../uploads/<upload-id>' for reading: ... no such file or directory, and the file returns 425.

Cause

Upload renames source into the temp file. If copyTarget is set, the block after the final rename opens source again, and the rename has removed that path. #720 introduced this when it replaced a Seek(0, 0) on the open handle with a new os.Open(source).

tree.WriteBlob is the only caller that passes a copy target, and only when fs revisions are on. With the upload area on a second device, the rename fails with EXDEV, the copy fallback keeps the source, and uploads work.

Fix

Open the temp file before the rename and copy from that handle. The handle stays valid across the rename, so the copy needs neither the source file nor a second n.InternalPath(). That second lookup goes through the id cache and returns an empty string if the lookup fails. At that point the blob is already in place, so a failure there would report an error for an upload that worked.

Tests

The table in blobstore_copy_target_test.go uploads with a copy target on the rename path and the copy path, and checks the blob and the copy. The two rename entries fail on main with could not open source file ... no such file or directory and pass with this change. go test -race ./pkg/storage/fs/posix/... passes locally and golangci-lint is clean.

Files that are already stuck still need the manual repair described in the issue. This change stops new ones.

When the upload area and the blobstore are on the same filesystem,
Upload renames the source file into the temp file. The block that writes
the copy target then opened the source path again, which the rename had
removed. So with fs revisions enabled every upload failed, the node kept
its processing status and the file answered 425 from then on.

Open the temp file before it moves into place instead. The handle stays
valid across the rename, so the copy needs neither the source file nor a
second lookup of the final path. Installations on two filesystems never
saw this, because the EXDEV fallback copies the source and leaves it in
place.

Fixes opencloud-eu/opencloud#3462
@NickWalters

Copy link
Copy Markdown
Author

@rhafer @butonic could one of you approve the Woodpecker runs for #807, #808 and #809? They are fork PRs, so CI has been waiting on approval since 2026-09-20. All three are small posix fixes.

@aduffeck
aduffeck merged commit c637b42 into opencloud-eu:main Oct 13, 2026
19 checks passed
@openclouders openclouders mentioned this pull request Oct 13, 2026
1 task
Mortimer-RR added a commit to Mortimer-RR/reva that referenced this pull request Oct 14, 2026
canUseRenameForUpload was a plain bool. Upload reads it on every call
and writes it when a rename fails with EXDEV, so concurrent uploads
race on it. Make it an atomic.Bool and read it once per upload.

The copy-target part of the original change is dropped: opencloud-eu#807 already
fixed it on main.

Assisted-by: Claude:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

posixfs: every upload sticks in processing (425) when fs revisions are enabled — blobstore reads source after renaming it away

2 participants