#include <list>
#include "acconfig.h"
-#include "os/fs/aio.h"
+#include "aio.h"
#define SPDK_PREFIX "spdk:"
/// track in-flight io
struct IOContext {
+private:
+ std::mutex lock;
+ std::condition_variable cond;
+ int r = 0;
+
+public:
CephContext* cct;
void *priv;
#ifdef HAVE_SPDK
void *nvme_task_last = nullptr;
#endif
- std::mutex lock;
- std::condition_variable cond;
std::list<aio_t> pending_aios; ///< not yet submitted
std::list<aio_t> running_aios; ///< submitting or submitted
std::atomic_int num_pending = {0};
std::atomic_int num_running = {0};
+ bool allow_eio;
- explicit IOContext(CephContext* cct, void *p)
- : cct(cct), priv(p)
+ explicit IOContext(CephContext* cct, void *p, bool allow_eio = false)
+ : cct(cct), priv(p), allow_eio(allow_eio)
{}
// no copying
void aio_wait();
- void aio_wake() {
- std::lock_guard<std::mutex> l(lock);
- cond.notify_all();
- --num_running;
- assert(num_running == 0);
+ void try_aio_wake() {
+ if (num_running == 1) {
+
+ // we might have some pending IOs submitted after the check
+ // as there is no lock protection for aio_submit.
+ // Hence we might have false conditional trigger.
+ // aio_wait has to handle that hence do not care here.
+ std::lock_guard<std::mutex> l(lock);
+ cond.notify_all();
+ --num_running;
+ assert(num_running >= 0);
+ } else {
+ --num_running;
+ }
+ }
+
+ void set_return_value(int _r) {
+ r = _r;
+ }
+
+ int get_return_value() const {
+ return r;
}
};