Skip to content

os/bluestore: Re-introduce truncation in BlueRocksWritableFile.Close() - #71479

Merged
SrinivasaBharath merged 3 commits into
ceph:mainfrom
viliam-durina:fix-76256-squashed
Sep 11, 2026
Merged

SrinivasaBharath merged 3 commits into
ceph:mainfrom
viliam-durina:fix-76256-squashed

Conversation

@viliam-durina

@viliam-durina viliam-durina commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

rocksdb::WritableFile assumes that whatever was allocated using Allocate(), and was not actually written to, is released when the file is closed (cf. PosixWritableFile::Close()). This used to work up to PR #62224 (released in 20.1.0, a tentacle RC), which removed the truncation from close since it assumed that truncate is called (see comment to commit d1703dc), which is not the case.

This PR adds the truncation back to BlueRocksWritableFile::Close(). We cannot bring back the exact pre-62224 code, as it relies on h->pos. Instead we flush the file and use fnode.size, which contains the on-disk size, including the envelope.

I'm not sure why this issue excessively affected clusters with no sharding. From the logs attached to the issue, in the non-sharded case there are many files with only a few kB payload in a file with 70MB allocation; in the sharded case the unreleased file tails still exist, but are much smaller.

The PR adds two tests:

  • a unit-test for the new truncate_unused_allocations() method
  • an end-to-end regression test that checks that the file is correctly truncated when rocksdb uses bluefs. This is in a new file, since it depends on rocksdb.

I also deleted BlueStoreWritableFile::UseDirectIO(), as it is unused (it doesn't override superclass method), and can cause confusion.

Fixes: https://tracker.ceph.com/issues/76256

Includes: #71483

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@viliam-durina
viliam-durina requested a review from a team as a code owner September 2, 2026 08:07
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

@ifed01 ifed01 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great catch! Overall LGTM. May be some naming polishing. Plus need for integration with #71483 at some point..

Comment thread src/os/bluestore/BlueFS.h Resolved
Comment thread src/os/bluestore/BlueFS.h Resolved
@ifed01
ifed01 requested a review from aclamk September 2, 2026 09:51
Comment thread src/os/bluestore/BlueRocksEnv.cc Resolved
viliam-durina added a commit to viliam-durina/ceph that referenced this pull request Sep 2, 2026
viliam-durina and others added 3 commits September 2, 2026 22:15
`rocksdb::WritableFile` assumes that whatever was allocated using `Allocate()`, and was not actually written to, is released when the file is closed (cf. `PosixWritableFile::Close()`). This used to work up to PR ceph#62224 (released in 20.1.0, a tentacle RC), which removed the truncation from `close` and it assumed that `truncate` is called.

This PR adds the truncation back to `BlueRocksWritableFile::Close()`. We cannot bring back the exact pre-62224 code, as it relies on `h->pos`. Instead we flush the file and use `fnode.size`, which contains the on-disk size, including the envelope.

This should fix https://tracker.ceph.com/issues/76256.

I'm not sure why this issue excessively affected clusters with no sharding. From the logs attached to the issue, in the non-sharded case there are many files with only a few kB payload in a 70MB file; in the sharded case the unreleased file tails still exist, but are much smaller.

The new test case unit-tests the new `truncate_unused_allocations()` method, overall correctness of BlueFS operation is covered by other tests already. We also delete `BlueStoreWritableFile::UseDirectIO()`, as it is unused (it doesn't override superclass method).

Fixes: https://tracker.ceph.com/issues/76256
Signed-off-by: Viliam Durina <[email protected]>
@idryomov
idryomov removed the request for review from a team September 2, 2026 21:07
@idryomov idryomov removed the rbd label Sep 2, 2026
@ifed01
ifed01 removed request for a team September 3, 2026 19:54
@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath12-testing-20260907.061609-main.

@sseshasa

sseshasa commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I found one or more Fixes: tags in the commit messages in

git log aaf2a1792c7a2a4921e2405b7a57db6b49034f20^..aaf2a1792c7a2a4921e2405b7a57db6b49034f20

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

Update Log: https://github.com/ceph/ceph/actions/runs/34616346147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants