overlay: Skip copying file data on copy-up for O_TRUNC opens by wikipika-modal · Pull Request #16073 · google/gvisor · GitHub
Skip to content

overlay: Skip copying file data on copy-up for O_TRUNC opens - #16073

Open
wikipika-modal wants to merge 2 commits into
google:masterfrom
wikipika-modal:jackie/upstream-otrunc-copyup
Open

wikipika-modal wants to merge 2 commits into
google:masterfrom
wikipika-modal:jackie/upstream-otrunc-copyup

Conversation

@wikipika-modal

@wikipika-modal wikipika-modal commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

copyUp is invoked for any lower-dir file opened with write bit, including O_TRUNC, which copies all metadata + data up to upper dir.

We should not copy data, since O_TRUNC will zero it out anyway.

Assisted-by: Claude Code

@google-cla

google-cla Bot commented Oct 20, 2026

Copy link
Copy Markdown

Opening a lower regular file with O_TRUNC copied all of its data to the
upper layer and then truncated the upper file to zero. Copy up metadata
only in that case, as Linux's ovl_copy_up_flags() does.

Assisted-by: Claude Code
@wikipika-modal
wikipika-modal force-pushed the jackie/upstream-otrunc-copyup branch from 821f067 to aeca713 Compare October 20, 2026 21:06

@ayushr2 ayushr2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is elegant.

@EtiennePerot

Copy link
Copy Markdown
Collaborator

Assisted-by: Claude Code
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.

3 participants