Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformulate sparseWriter #21797

Merged
merged 2 commits into from
Feb 25, 2024
Merged

Reformulate sparseWriter #21797

merged 2 commits into from
Feb 25, 2024

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented Feb 23, 2024

Instead of using a state machine, use a more straight-line code; also document and enforce various invariants.

The net effect of this code is exactly the same as the previous implementation, except:

  • the operation after Write() returns an error might differ
  • If the file ends with zeroes, we don't Seek(-1), and we don't create a hole at all if it is too small, preferring to save a syscall.

But this formulation is hopefully easier to prove correct.

Also adds more tests, to see behavior in more cases, and to actually test that this does create holes.


Alternatively, see https://github.com/mtrmac/libpod/tree/sparse for a commit series that ends with exactly the same code, but justifies every step individually.

But in this case I think it’s easier to just read the end product with its comments than to follow the 33 steps one by one.

Does this PR introduce a user-facing change?

None

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 23, 2024
- Add more test cases
- Test that we create the expected (large) holes;
  don't enforce anything for the <zerosThresholt ones.

O)nly changes test code, should not change behavior.

Signed-off-by: Miloslav Trmač <[email protected]>
... instead of using a multi-variable state machine.

The net effect of this code is exactly the same as the previous implementation,
except:
- the operation after Write() returns an error might differ
- If the file ends with zeroes, we don't Seek(-1), and
  we don't create a hole at all if it is too small, preferring
  to save a syscall.

But this formulation is hopefully easier to prove correct.

Signed-off-by: Miloslav Trmač <[email protected]>
Copy link

Cockpit tests failed for commit 5d303ca. @martinpitt, @jelly, @mvollmer please check.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Feb 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, mtrmac

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@baude
Copy link
Member

baude commented Feb 25, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 1fc9d5a into containers:main Feb 25, 2024
92 of 93 checks passed
@mtrmac mtrmac deleted the sparse0 branch February 26, 2024 15:38
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 27, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants