GrepBoard/Manuals
605 manuals ·

bdev_async_discard ignored after upgrade, use _threads

·Tested on Ceph Reef 18.2 · Squid 19.2 · Tentacle 20.2 official docs, source and PRs · 2026-10·Test scope ↓·8 steps

Upgrading to Reef 18.2.5 or Squid 19.2.1+ ignores an old bdev_async_discard=true, so discard turns synchronous. Version table, check and set commands, rollback.

console
$ ceph config get osd bdev_async_discard_threads

If a cluster ran async discard through the boolean bdev_async_discard=true on Reef 18.2.4 or earlier or Squid 19.2.0 and is upgraded to Reef 18.2.5-18.2.7 or Squid 19.2.1-19.2.2, that setting is no longer read, the thread count becomes 0, and discards run synchronously. After the upgrade, set bdev_async_discard_threads to 1 yourself to keep the old behavior. Raising it to 2 or more is a separate matter and needs Reef 18.2.7 or Squid 19.2.3 or newer, where a defect that makes discard threads wake each other was fixed (tracker issue #67835). Everything below is limited to what the source, PRs and issues say.

[1] See what differs per release. This comes from opening the option definitions (global.yaml.in) and KernelDevice.cc at each tag.

Releasebdev_async_discard_threadsOld bdev_async_discardDoes the code read the old boolean2+ thread fix (need_notify)
Reef 18.2.4absentpresent (boolean, default false)yes ([KernelDevice.cc L284](https://github.com/ceph/ceph/blob/v18.2.4/src/blk/kernel/KernelDevice.cc#L284))n/a (no thread-count option)
Reef 18.2.5 · 18.2.6present, default 0absentnoabsent
Reef 18.2.7present, default 0absentno ([KernelDevice.cc L535-L543](https://github.com/ceph/ceph/blob/v18.2.7/src/blk/kernel/KernelDevice.cc#L535-L543))present
Squid 19.2.0absentpresent (boolean, default false)yes ([KernelDevice.cc L284](https://github.com/ceph/ceph/blob/v19.2.0/src/blk/kernel/KernelDevice.cc#L284))n/a
Squid 19.2.1 · 19.2.2present, default 0absentno ([KernelDevice.cc L535-L543](https://github.com/ceph/ceph/blob/v19.2.2/src/blk/kernel/KernelDevice.cc#L535-L543))absent
Squid 19.2.3present, default 0DEPRECATED aliasyes, only when the thread count is 0 ([KernelDevice.cc L557-L562](https://github.com/ceph/ceph/blob/v19.2.3/src/blk/kernel/KernelDevice.cc#L557-L562))present
Tentacle 20.2.0present, default 0absentnopresent

Option definitions: 18.2.4 L4035-L4044, 18.2.7 L4049-L4070, 19.2.0 L4017-L4026, 19.2.3 L4040-L4093, 20.2.0 L4133-L4160. The old name disappeared in 18.2.5-18.2.6 and 19.2.1-19.2.2 through the commit "common: remove lingering bdev_async_discard option" in PR #59048. Check your release with:

console
$ ceph versions

[2] Before the upgrade, check whether the old setting is on. These are read-only commands, run on a release that still defines the old option (18.2.4, 19.2.0). ceph config show reports values from local config files too, with their source, so it also catches a setting made in a file (config docs).

console
$ ceph config dump | grep -E 'bdev_(enable|async)_discard'$ ceph config show osd.0 bdev_async_discard$ ceph config show osd.0 bdev_enable_discard

If bdev_enable_discard and bdev_async_discard are both true, one async discard thread runs on those releases ([KernelDevice.cc L284](https://github.com/ceph/ceph/blob/v18.2.4/src/blk/kernel/KernelDevice.cc#L284)). Only in that case do you need [3].

[3] After the upgrade, carry the setting over to the new option. The newer code gets the thread count from bdev_async_discard_threads alone. At 0, with bdev_enable_discard on, discards run synchronously in the caller ([Reef 18.2.7 try_discard L818-L832](https://github.com/ceph/ceph/blob/v18.2.7/src/blk/kernel/KernelDevice.cc#L818-L832), Squid 19.2.3 L849-L862). The 19.2.3 definition says the old boolean worked like an alias for bdev_async_discard_threads = 1 ([global.yaml.in L4078-L4084](https://github.com/ceph/ceph/blob/v19.2.3/src/common/options/global.yaml.in#L4078-L4084)), so 1 is the same behavior. Use the osd level so all OSDs are covered; you can first try one OSD.

console
$ ceph config set osd bdev_async_discard_threads 1$ ceph config show osd.0 bdev_async_discard_threads$ ceph config get osd bdev_enable_discard

The option carries the runtime flag, so no restart is indicated (18.2.7 L4059-L4068). The second command should show 1. If the third shows false, no thread starts, so make sure that is intended. To undo, remove the entry. The value returns to the default 0, so discard is synchronous again.

console
$ ceph config rm osd bdev_async_discard_threads

On 19.2.3 a leftover old boolean is still read as 1 when the thread count is 0, but the same definition calls it DEPRECATED and "for Squid minor releases only", and Tentacle 20.2.0 does not have it. Carry it over with [3] on 19.2.3 too. How the monitors treat a leftover central-config entry for an option the release no longer defines was not checked; the code does not read it.

[4] Read the option text. In the Squid 19.2.3 definition bdev_async_discard_threads is "number of discard threads used to issue discards to the device", default 0, changeable at runtime, paired with bdev_enable_discard (default false). If bdev_enable_discard is off or the device does not support discard, the count is 0 whatever the value ([KernelDevice.cc L557-L565](https://github.com/ceph/ceph/blob/v19.2.3/src/blk/kernel/KernelDevice.cc#L557-L565)). In the same file bdev_async_discard_max_pending (default 1000000) says that once the queue is full, discards are not issued and the blocks go straight back to the allocator. On releases without the option (18.2.4, 19.2.0) ceph config get may return an error.

console
$ ceph config help bdev_async_discard_threads$ ceph config get osd bdev_async_discard_max_pending

[5] Read PR #59048 (reef, merged 2024-11-04). Its title is "a series of optimizations for kerneldevice discard" and its body lists three things:

  • multi-thread discard support (the change that introduced this option)
  • a fix for leaked free space when bdev_async_discard is enabled; the reef backport issue #67140 is titled "reef: Free space can be leaked in Quincy+ when bdev_async_discard is enabled", fixed in v18.2.5
  • reacting to bdev_enable_discard changes and fixing problems in the thread-stop path; the reef backport issue #67405 is titled "reef: Class-masked async discard configuration does not work in Reef+", fixed in v18.2.5

The commit list has matching commits (for example blk: add threaded discard support to kernel devices and os/BlueStore: NCB fix for leaked space when bdev_async_discard is enabled). The PR describes the feature and those fixes; it gives no performance numbers.

[6] Read PR #62151 (squid, merged 2025-04-15). Its title is "blk/kerneldevice: notify_all only required when discard_drain wait for condition" and the commit message says:

output
This will cause discard threads to wake up each otherif bdev_async_discard_threads >= 2.

Issue #67835 is titled "discard threads wake up each other if discard thread num >= 2", severity "3 - minor". The debug log pasted in an issue comment shows two threads repeating _discard_thread wake and sleep in turn. The source agrees. Before the fix, each thread called discard_cond.notify_all() every time it went to sleep on an empty queue ([19.2.2 KernelDevice.cc L755-L758](https://github.com/ceph/ceph/blob/v19.2.2/src/blk/kernel/KernelDevice.cc#L755-L758)). After it, discard_drain sets need_notify while it waits, and the notify happens only then (19.2.3 L610-L618, L778-L786). The issue does not say how much CPU the loop uses, so this article does not claim any.

[7] Confirm the fixed releases. The issue's backport items (reef #70147, squid #70148) list the fix versions as v18.2.7 and v19.2.3. In the source, need_notify exists in 18.2.7, 19.2.3 and 20.2.0, as in the last column of the table in [1], and not in 18.2.5, 18.2.6, 19.2.1 or 19.2.2.

[8] Decide whether to go to 2 or more. How many threads to use, and how much faster discards get, were not found in any source. If you do raise it, do it only on a fixed release, start with one OSD, and keep the undo with it.

console
$ ceph config set osd.0 bdev_async_discard_threads 2$ ceph config show osd.0 bdev_async_discard_threads$ ceph config rm osd.0 bdev_async_discard_threads

#ceph#bluestore#bdev_async_discard_threads#bdev_async_discard#discard