@@ -7762,24 +7762,22 @@ void BlueStore::_close_db()
77627762 db = nullptr;
77637763
77647764 if (do_destage && fm && fm->is_null_manager()) {
7765- if (cct->_conf->osd_fast_shutdown == false) {
7766- // graceful shutdown -> commit backgrounds discards before storing allocator
7767- bdev->discard_drain();
7768- }
7769-
7770- interval_set<uint64_t> discard_queued;
7771- bdev->swap_discard_queued(discard_queued);
7772- if (discard_queued.num_intervals() > 0) {
7765+ if (cct->_conf->osd_fast_shutdown) {
7766+ interval_set<uint64_t> discard_queued;
7767+ bdev->swap_discard_queued(discard_queued);
77737768 dout(10) << __func__ << "::discard_drain: size=" << discard_queued.size()
77747769 << " num_intervals=" << discard_queued.num_intervals() << dendl;
77757770 // copy discard_queued to the allocator before storing it
77767771 for (auto p = discard_queued.begin(); p != discard_queued.end(); ++p) {
7777- dout(20) << __func__ << "::discarded-extent=[" << p.get_start() << ", " << p.get_len() << "]" << dendl;
7772+ dout(20) << __func__ << "::discarded-extent=[" << p.get_start()
7773+ << ", " << p.get_len() << "]" << dendl;
77787774 alloc->init_add_free(p.get_start(), p.get_len());
77797775 }
77807776 }
7781- // drain the items in the threads local discard_processing queues
7782- // There are only a few items in those queues so it is fine to do so in fast shutdown
7777+
7778+ // When we reach here it is either a graceful shutdown (so can drain the full discards-queue)
7779+ // or it was a fast shutdown, but we already moved the main discards-queue to the allocator
7780+ // and only need to wait for the threads local discard_processing queues to drain
77837781 bdev->discard_drain();
77847782 int ret = store_allocator(alloc);
77857783 if (unlikely(ret != 0)) {
0 commit comments