Skip to content

commit tmpfile prep#957

Closed
cgwalters wants to merge 5 commits intoostreedev:masterfrom
cgwalters:commit-tmpfile-prep
Closed

commit tmpfile prep#957
cgwalters wants to merge 5 commits intoostreedev:masterfrom
cgwalters:commit-tmpfile-prep

Conversation

@cgwalters
Copy link
Copy Markdown
Member

@cgwalters cgwalters commented Jun 23, 2017

A few patches in prep for #958.

The variables here were duplicative; we don't need two booleans to distinguish
between symlinks and regular files. What we do need to handle is the "physical"
state versus the "object" state. Symlinks objects are stored as regular files in
`bare-user` and `archive`.

Prep for more cleanup.
The pull code also could make use of this in both the metadata and content
paths. I changed it to own the tempfile malloc (just like `GLnxTmpFile`), since
there's no reason to have different lifetimes for the filename and the file, and
that way we only have one variable rather than two.

The content path turns out to be a special case though, where
at least for mirroring archives, we directly pass the file *path*
down into `_ostree_repo_commit_loose_final()`.

This is prep for `GLnxTmpFile` porting.
The `OstreeRepoContentBareCommit` struct was basically an `OtTmpFile`, so let's
make it one. I moved the "convert to `GOutputStream`" logic into the callers,
since that bit can't fail; it makes the implementation much simpler since we can
just return the result of `ot_open_tmpfile_linkable_at()`.

Prep for `GLnxTmpfile` porting.
@cgwalters cgwalters changed the title lib/commit: Clean up commit file type handling variables commit tmpfile prep Jun 24, 2017
@cgwalters cgwalters mentioned this pull request Jun 24, 2017

if (file_input != NULL)
g_object_unref (file_input);
/* Include the terminating zero so we can e.g. mmap this file */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One thing I just noticed here. We're creating a new stream that has just the target name + nul, but down there where we create the tmpfile for it, we're still using the size from the GFileInfo, so we don't actually end up writing the trailing zero, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We do write it actually, because we drop into the g_output_stream_splice() path. But our fallocate() is wrong.

I'm actually kind of dubious about the value of writing it, since it doesn't make sense to mmap small files. But let's keep it. Fixup and new commit ⬇️

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(Also, nice catch!)

goto out;
}

/* Now delete it, keeping the fd open as the last reference); see comment in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: unbalanced parenthesis.

@jlebon
Copy link
Copy Markdown
Member

jlebon commented Jun 26, 2017

@rh-atomic-bot r+ b2d8253

@rh-atomic-bot
Copy link
Copy Markdown

⌛ Testing commit b2d8253 with merge 5effcee...

@rh-atomic-bot
Copy link
Copy Markdown

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing 5effcee to master...

rh-atomic-bot pushed a commit that referenced this pull request Jun 26, 2017
The variables here were duplicative; we don't need two booleans to distinguish
between symlinks and regular files. What we do need to handle is the "physical"
state versus the "object" state. Symlinks objects are stored as regular files in
`bare-user` and `archive`.

Prep for more cleanup.

Closes: #957
Approved by: jlebon
rh-atomic-bot pushed a commit that referenced this pull request Jun 26, 2017
The pull code also could make use of this in both the metadata and content
paths. I changed it to own the tempfile malloc (just like `GLnxTmpFile`), since
there's no reason to have different lifetimes for the filename and the file, and
that way we only have one variable rather than two.

The content path turns out to be a special case though, where
at least for mirroring archives, we directly pass the file *path*
down into `_ostree_repo_commit_loose_final()`.

This is prep for `GLnxTmpFile` porting.

Closes: #957
Approved by: jlebon
rh-atomic-bot pushed a commit that referenced this pull request Jun 26, 2017
The `OstreeRepoContentBareCommit` struct was basically an `OtTmpFile`, so let's
make it one. I moved the "convert to `GOutputStream`" logic into the callers,
since that bit can't fail; it makes the implementation much simpler since we can
just return the result of `ot_open_tmpfile_linkable_at()`.

Prep for `GLnxTmpfile` porting.

Closes: #957
Approved by: jlebon
rh-atomic-bot pushed a commit that referenced this pull request Jun 26, 2017
We need to account for the trailing NUL.

Closes: #957
Approved by: jlebon
@cgwalters
Copy link
Copy Markdown
Member Author

Weird, github failed to close this.

@cgwalters cgwalters closed this Jun 26, 2017
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