From 5c10e57fec43db1bca3136b38a86f9319433645f Mon Sep 17 00:00:00 2001 From: skanta Date: Tue, 5 Nov 2024 16:18:57 +0530 Subject: [PATCH] Revert "style changes requested by Igor" This reverts commit c3dc1c4f1b3d048fd3409b0bbc69ee81638298be. The commit was merged prematurely without testing. Signed-off-by: Srinivasa Bharath Kanta --- src/blk/kernel/KernelDevice.cc | 2 +- src/os/bluestore/BlueStore.cc | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index b990f7d15372f..9270b3810f1f9 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 = 32; + constexpr unsigned MAX_LOCAL_DISCARD = 10; 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 4f088203e0f89..ba1872ee1cbe5 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8038,22 +8038,24 @@ void BlueStore::_close_db() db = nullptr; if (do_destage && fm && fm->is_null_manager()) { - if (cct->_conf->osd_fast_shutdown) { - interval_set discard_queued; - bdev->swap_discard_queued(discard_queued); + 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) { 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()); } } - - // 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 + // 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 bdev->discard_drain(); int ret = store_allocator(alloc); if (unlikely(ret != 0)) { -- 2.39.5