Skip to content

fix filedescriptor leaks - #847

Merged
aduffeck merged 5 commits into
mainfrom
port-550
Oct 6, 2026
Merged

aduffeck merged 5 commits into
mainfrom
port-550

Conversation

@butonic

@butonic butonic commented Oct 5, 2026

Copy link
Copy Markdown
Member

fix a few fildescriptor leaks on errors

kobergj and others added 5 commits October 5, 2026 15:59
Ported from owncloud#550 (8935224). The upstream commit also patched
pkg/storage/fs/posix/blobstore, which we rewrote in f6ca1ec and f60de0e
to use rename plus periodic fdatasync, so that hunk does not apply here.
Upload only copies when renaming the source into the blobstore fails, so the
existing specs never ran the code path that leaked the blob file descriptor.
They now use a source on a second device to force the EXDEV rename failure,
and assert via /proc/self/fd that no descriptor is left pointing at the blob,
both for a successful copy and for a copy that breaks midway.
The decomposed driver has its own copy of the filesystem blobstore, which had
the same missing Close() and Sync() as the ocis one fixed in owncloud#550:
every upload that could not be renamed into place leaked the descriptor of the
blob file, and the blob was not flushed to disk before the node was updated.
The copy fallback of the posix blobstore only closed the temp file on the
success path, so a copy that broke midway leaked its descriptor. Also stop
swallowing the final Sync() error: a blob that could not be flushed to disk
should not look like a successful upload.
The deferred Close() added with owncloud#550 assigns the close error to
err, but Upload's result was unnamed, so that assignment was discarded and a
failing close returned success. On NFS, where close() is the point at which the
client flushes dirty pages, that means a truncated or missing blob gets
committed without anyone noticing. Naming the result makes the guard do what it
reads like: report a close failure only when nothing else failed.
@butonic
butonic requested a review from aduffeck October 5, 2026 14:40
@butonic butonic self-assigned this Oct 5, 2026
@butonic butonic changed the title Port 550 fix fildescriptor leaks Oct 5, 2026
@aduffeck
aduffeck merged commit 877c355 into main Oct 6, 2026
20 checks passed
@aduffeck
aduffeck deleted the port-550 branch October 6, 2026 06:05
@openclouders openclouders mentioned this pull request Oct 6, 2026
1 task
@butonic butonic changed the title fix fildescriptor leaks fix filedescriptor leaks Oct 6, 2026
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.

3 participants