Skip to content

Caveats with compression and fallocate #976

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

Merged
merged 2 commits into from
May 29, 2025

Conversation

jimis
Copy link
Contributor

@jimis jimis commented Apr 8, 2025

No description provided.

@jimis
Copy link
Contributor Author

jimis commented May 29, 2025

ping @adam900710

@adam900710 adam900710 merged commit 7d6f26b into kdave:devel May 29, 2025
5 checks passed
@adam900710
Copy link
Collaborator

Although I have merged the two patches, they all went through some modification.
If you want to contribute to btrfs in the future, it would be better to follow the next two points:

  • Write a commit message
    Even for simple doc update, please write a short description for the change.

  • Use a "Signed-off-by" line
    This can be generated by "-s" option of "git commit".

@kdave kdave added this to the v6.15 milestone May 30, 2025
@kdave
Copy link
Owner

kdave commented May 30, 2025

I'd like documentation updates to be easy and low barrier so I don't insist on formatting, changelog or Signed-off-by. This is also mentioned in README.md. Casual fixes or clarifications are more valuable than requiring the whole contribution process.

kdave pushed a commit that referenced this pull request May 30, 2025
Even with compress-force mount option, btrfs can still fallback to
uncompressed write if the block can not be compressed.

Add such clarification to avoid confusion.

Pull-request: #976
Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
kdave pushed a commit that referenced this pull request May 30, 2025
An inode with successful fallocated range will never be compressed in
the future, this is a limitation in btrfs' NOCOW fallback behavior.

Add a clarification to avoid confusion to end users.

Pull-request: #976
Signed-off-by: Qu Wenruo <[email protected]>
Signed-off-by: David Sterba <[email protected]>
@kdave
Copy link
Owner

kdave commented May 30, 2025

Also the Signed-off-by line should not be added by us unless it's part of the patch. I add Author: tag or link to the issue or pull-request, this keeps the credit. The signed-off-by line and DCO has a 'legal' meaning https://developercertificate.org/ and needs to be stated by the author.

@jimis
Copy link
Contributor Author

jimis commented May 30, 2025

Thank you! Would you consider adding a mount option for fallocate() to return EOPNOTSUPP and stop messing with compression?

Our discussion gives me the impression that is now a possibility:

Maybe the best tradeoff is to add a mount option fallocate=off.

That will be feasible.

I can try push that direction after you have updated the docs.

@jimis
Copy link
Contributor Author

jimis commented Jun 2, 2025

I also wonder, does the case I documented here for files extended with fallocate(), also apply for files extended with ftruncate()?

That is, such files will be excluded from future compression?

@adam900710
Copy link
Collaborator

adam900710 commented Jun 2, 2025

Only for falloc(), not ftruncate().

The PREALLOC inode flag is added for any preallocated file extent, meanwhile truncate only creates holes.

@jimis
Copy link
Contributor Author

jimis commented Jun 2, 2025

Thank you @adam900710. So it seems ftruncate() may be the most efficient way to extend a file. I'll transfer this info to the postgresql-hackers mailing list where this issue and potential workarounds are being discussed.

@adam900710
Copy link
Collaborator

truncate is fast but it's really different from fallocate by there is nothing really allocated.

This means the later writes will need to allocate their own data extents.
This is fine and even preferred for btrfs, but may lead to performance drop for more traditional fses.

We're in an era that fs features are not longer that generic, fallocate is just one example, in fact fallocate will cause more problems more than no compression.

It's really a deep rabbit hole, and is not something simple true or false questions.

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