From: Jianpeng Ma Date: Thu, 20 Sep 2018 13:52:53 +0000 (+0800) Subject: common/Finisher: only queue empty only wake up waiter. X-Git-Tag: v14.0.1~236^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d7ca34e12fd9dd652fe12b5593bf2ccd4ce35b60;p=ceph.git common/Finisher: only queue empty only wake up waiter. Signed-off-by: Jianpeng Ma --- diff --git a/src/common/Finisher.h b/src/common/Finisher.h index d463680a8c8c..4b6d2d3c8a13 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -184,4 +184,43 @@ public: } }; +class ContextQueue { + list q; + std::mutex q_mutex; + Mutex& mutex; + Cond& cond; +public: + ContextQueue(Mutex& mut, Cond& con) : mutex(mut), cond(con) {} + + void queue(list& ls) { + { + std::scoped_lock l(q_mutex); + if (q.empty()) { + q.swap(ls); + } else { + q.insert(q.end(), ls.begin(), ls.end()); + } + } + + mutex.Lock(); + cond.SignalOne(); + mutex.Unlock(); + + ls.clear(); + } + + void swap(list& ls) { + ls.clear(); + std::scoped_lock l(q_mutex); + if (!q.empty()) { + q.swap(ls); + } + } + + bool empty() { + std::scoped_lock l(q_mutex); + return q.empty(); + } +}; + #endif diff --git a/src/common/legacy_config_opts.h b/src/common/legacy_config_opts.h index 2b3fb0d62c47..071c627f9852 100644 --- a/src/common/legacy_config_opts.h +++ b/src/common/legacy_config_opts.h @@ -1070,7 +1070,6 @@ OPTION(bluestore_debug_omit_block_device_write, OPT_BOOL) OPTION(bluestore_debug_fsck_abort, OPT_BOOL) OPTION(bluestore_debug_omit_kv_commit, OPT_BOOL) OPTION(bluestore_debug_permit_any_bdev_label, OPT_BOOL) -OPTION(bluestore_shard_finishers, OPT_BOOL) OPTION(bluestore_debug_random_read_err, OPT_DOUBLE) OPTION(bluestore_debug_inject_bug21040, OPT_BOOL) OPTION(bluestore_debug_inject_csum_err_probability, OPT_FLOAT) diff --git a/src/common/options.cc b/src/common/options.cc index d1c295d3fb3f..8d9bdcf54984 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -4340,10 +4340,6 @@ std::vector