{
static const char* KEYS[] = {
"bdev_async_discard_threads",
+ "bdev_enable_discard",
NULL
};
return KEYS;
void KernelDevice::handle_conf_change(const ConfigProxy& conf,
const std::set <std::string> &changed)
{
- if (changed.count("bdev_async_discard_threads")) {
+ if (changed.count("bdev_async_discard_threads") || changed.count("bdev_enable_discard")) {
std::unique_lock l(discard_lock);
uint64_t oldval = target_discard_threads;
uint64_t newval = cct->_conf.get_val<uint64_t>("bdev_async_discard_threads");
+ if (!cct->_conf.get_val<bool>("bdev_enable_discard")) {
+ // We don't want these threads running if discard has been disabled (this is consistent with
+ // KernelDevice::open())
+ newval = 0;
+ }
target_discard_threads = newval;
discard_threads.emplace_back(new DiscardThread(this, i));
discard_threads.back()->create("bstore_discard");
}
- } else {
- // Decrease? Signal threads after telling them to stop
+ // Decrease? Signal threads after telling them to stop
+ } else if (newval < oldval) {
dout(10) << __func__ << " stopping " << (oldval - newval) << " existing discard threads" << dendl;
// Decreasing to zero is exactly the same as disabling async discard.