// 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;
db = nullptr;
if (do_destage && fm && fm->is_null_manager()) {
- if (cct->_conf->osd_fast_shutdown) {
- interval_set<uint64_t> 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<uint64_t> 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)) {