From b37080c654122041279d0d2d8a5f367da32169c3 Mon Sep 17 00:00:00 2001 From: Gabriel BenHanokh Date: Wed, 10 Apr 2024 06:57:52 +0000 Subject: [PATCH] style changes requested by Igor Signed-off-by: Gabriel BenHanokh --- src/blk/kernel/KernelDevice.cc | 2 +- src/os/bluestore/BlueStore.cc | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index f7980baddf2..18466648e8e 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -765,7 +765,7 @@ void KernelDevice::_discard_thread(uint64_t tid) // This will allow threads to work in parallel // instead of a single thread taking over the whole discard_queued. // It will also allow threads to finish in a timely manner. - constexpr unsigned MAX_LOCAL_DISCARD = 10; + constexpr unsigned MAX_LOCAL_DISCARD = 32; unsigned count = 0; for (auto p = discard_queued.begin(); p != discard_queued.end() && count < MAX_LOCAL_DISCARD; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5c8e8d8ec59..a03e1917ca5 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7762,24 +7762,22 @@ void BlueStore::_close_db() db = nullptr; if (do_destage && fm && fm->is_null_manager()) { - if (cct->_conf->osd_fast_shutdown == false) { - // graceful shutdown -> commit backgrounds discards before storing allocator - bdev->discard_drain(); - } - - interval_set discard_queued; - bdev->swap_discard_queued(discard_queued); - if (discard_queued.num_intervals() > 0) { + if (cct->_conf->osd_fast_shutdown) { + interval_set discard_queued; + bdev->swap_discard_queued(discard_queued); dout(10) << __func__ << "::discard_drain: size=" << discard_queued.size() << " num_intervals=" << discard_queued.num_intervals() << dendl; // copy discard_queued to the allocator before storing it for (auto p = discard_queued.begin(); p != discard_queued.end(); ++p) { - dout(20) << __func__ << "::discarded-extent=[" << p.get_start() << ", " << p.get_len() << "]" << dendl; + dout(20) << __func__ << "::discarded-extent=[" << p.get_start() + << ", " << p.get_len() << "]" << dendl; alloc->init_add_free(p.get_start(), p.get_len()); } } - // drain the items in the threads local discard_processing queues - // There are only a few items in those queues so it is fine to do so in fast shutdown + + // When we reach here it is either a graceful shutdown (so can drain the full discards-queue) + // or it was a fast shutdown, but we already moved the main discards-queue to the allocator + // and only need to wait for the threads local discard_processing queues to drain bdev->discard_drain(); int ret = store_allocator(alloc); if (unlikely(ret != 0)) { -- 2.39.5