Skip to content

tools/bluestore: force discard when explicitly trimming free space - #72653

Merged
Jayaprakash-ibm merged 1 commit into
ceph:mainfrom
YiteGu:fix-bluestore-tool-trim-force-discard
Nov 25, 2026
Merged

Jayaprakash-ibm merged 1 commit into
ceph:mainfrom
YiteGu:fix-bluestore-tool-trim-force-discard

Conversation

@YiteGu

@YiteGu YiteGu commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

The trim command in ceph-bluestore-tool calls try_discard() with async=false when iterating over free extents in the BlueStore and BlueFS allocators. This selects synchronous discard, but does not bypass the bdev_enable_discard configuration setting.

Since bdev_enable_discard defaults to false, explicitly invoking trim on a discard-capable device can iterate over all free extents without issuing any discard requests. The command nevertheless reports "trim done". This defeats the intended use case of performing an offline trim while leaving discard disabled during normal OSD operation.

Pass force=true to try_discard() in both BlueStore::trim_free_space() and BlueFS::trim_free_space(). This allows explicit trim requests for the main block device and dedicated DB/WAL devices to bypass the online discard configuration setting while retaining synchronous execution and the device discard capability checks.

The change does not modify the process configuration, persistent configuration, or the behavior of normal online discard operations. Existing handling of underlying discard errors remains unchanged.

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.

@YiteGu
YiteGu requested a review from a team as a code owner October 14, 2026 02:11
@YiteGu
YiteGu requested a review from ifed01 October 14, 2026 02:12
@YiteGu

YiteGu commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

jenkins test make check

@ming1

ming1 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Fixes: 0441dfc ("tools/bluestore: Add command 'trim' to ceph-bluestore-tool")

@ming1
ming1 self-requested a review October 26, 2026 12:29
@ming1 ming1 added the bug-fix label Oct 26, 2026
@aclamk
aclamk requested a review from Naveenaidu October 27, 2026 13:31

@Naveenaidu Naveenaidu 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.

LGTM!

I have created a tracker for this issue here: https://tracker.ceph.com/issues/82224. Please reference that in the PR and commit messages.

Since this issue has been since, #57369 - I would also recommend to add the following line:

Fixes: 0441dfc ("tools/bluestore: Add command 'trim' to ceph-bluestore-tool")

If possible, can we please also have some tests that verifies that this path is now working correctly ?

The trim command in ceph-bluestore-tool calls try_discard() with
async=false when iterating over free extents in the BlueStore and BlueFS
allocators. This selects synchronous discard, but does not bypass the
bdev_enable_discard configuration setting.

Since bdev_enable_discard defaults to false, explicitly invoking trim on
a discard-capable device can iterate over all free extents without
issuing any discard requests. The command nevertheless reports "trim
done". This defeats the intended use case of performing an offline trim
while leaving discard disabled during normal OSD operation.

Pass force=true to try_discard() in both BlueStore::trim_free_space() and
BlueFS::trim_free_space(). This allows explicit trim requests for the
main block device and dedicated DB/WAL devices to bypass the online
discard configuration setting while retaining synchronous execution
and the device discard capability checks.

The change does not modify the process configuration, persistent
configuration, or the behavior of normal online discard operations.
Existing handling of underlying discard errors remains unchanged.

Fixes: https://tracker.ceph.com/issues/82224
Fixes: 0441dfc ("tools/bluestore: Add command 'trim' to ceph-bluestore-tool")
Signed-off-by: Yite Gu <[email protected]>
@YiteGu
YiteGu force-pushed the fix-bluestore-tool-trim-force-discard branch from a486635 to 4684e1b Compare October 28, 2026 13:06
@YiteGu

YiteGu commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

LGTM!

I have created a tracker for this issue here: https://tracker.ceph.com/issues/82224. Please reference that in the PR and commit messages.

Since this issue has been since, #57369 - I would also recommend to add the following line:

Fixes: 0441dfc ("tools/bluestore: Add command 'trim' to ceph-bluestore-tool")

If possible, can we please also have some tests that verifies that this path is now working correctly ?

thx, updated

@YiteGu

YiteGu commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath20-testing-20261109.055221-main.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

This PR has been added to wip-jaya-bs-testing-18-11-2026.

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

@Jayaprakash-ibm
Jayaprakash-ibm merged commit 3c2ad58 into ceph:main Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants