When the last two IOs of the same Context return at the same time, their
num_running may be 2 at the same time, causing the thread to not be
woken up, eventually resulting in a timeout.
Signed-off-by: Wang Hongxu <wanghongxu@t2cloud.net>
uint64_t get_num_ios() const;
void try_aio_wake() {
- if (num_running == 1) {
+ assert(num_running >= 1);
+ if (num_running.fetch_sub(1) == 1) {
// we might have some pending IOs submitted after the check
// as there is no lock protection for aio_submit.
// aio_wait has to handle that hence do not care here.
std::lock_guard<std::mutex> l(lock);
cond.notify_all();
- --num_running;
- ceph_assert(num_running >= 0);
- } else {
- --num_running;
}
}