Skip to content

posix: add --same-dir-tmp for atomic writes on filesystems without cross-dir rename#1

Open
riaarora-boop wants to merge 1 commit into
mainfrom
feat/posix-same-dir-tmp
Open

posix: add --same-dir-tmp for atomic writes on filesystems without cross-dir rename#1
riaarora-boop wants to merge 1 commit into
mainfrom
feat/posix-same-dir-tmp

Conversation

@riaarora-boop

Copy link
Copy Markdown

Summary:

Adds --same-dir-tmp flag to the posix backend. When set, the atomic-write temp file is created in the object's own directory instead of the per-bucket .sgwtmp/ staging dir, so the commit rename() is always same-directory.

Required for Rubrik SDFS, which returns EACCES on cross-directory rename. The temp file gets a hidden .sgwtmp.<hash>. prefix so it is excluded from object listings.

Adds tmpDir / tmpDirFor / tmpFilePrefix helpers and updates all six openTmpFile call sites to route through them. Also fixes without_otmpfile.go to use errors.Is(err, syscall.ENOENT) and properly surface MkdirAll errors.

Test Plan:

  • go build ./backend/... ./cmd/... passes
  • Existing posix tests pass unchanged (flag defaults to false, preserving stock behavior)
  • Manually validated on SDFS: single PUT and multipart complete without EACCES

JIRA Issues:

CDM-557242 (subtask of CDM-557238)

Revert Plan:

Revert this PR. No data migration needed — the flag defaults to false and existing deployments are unaffected.

…oss-dir rename

Some filesystems (e.g. Rubrik SDFS) reject rename() across directories with
EACCES. --same-dir-tmp places the atomic-write temp file in the object's own
directory so the commit rename is always same-directory. The temp file gets a
hidden ".sgwtmp." prefix to stay out of object listings.

Adds tmpDir/tmpDirFor/tmpFilePrefix helpers and updates all six openTmpFile
call sites to route through them. --disableotmp should be used alongside this
flag on SDFS (O_TMPFILE is not supported there).

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant