1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_RBD_GGATE_SERVER_H
5 #define CEPH_RBD_GGATE_SERVER_H
7 #include "include/rbd/librbd.hpp"
8 #include "include/xlist.h"
9 #include "common/Cond.h"
10 #include "common/Mutex.h"
11 #include "common/Thread.h"
21 Server(Driver *drv, librbd::Image& image);
27 xlist<IOContext*>::item item;
29 Request *req = nullptr;
31 IOContext(Server *server) : item(this), server(server) {
35 class ThreadHelper : public Thread {
37 typedef void (Server::*entry_func)();
39 ThreadHelper(Server *server, entry_func func)
40 : server(server), func(func) {
44 virtual void* entry() {
54 friend std::ostream &operator<<(std::ostream &os, const IOContext &ctx);
57 librbd::Image &m_image;
61 bool m_stopping = false;
62 ThreadHelper m_reader_thread, m_writer_thread;
63 xlist<IOContext*> m_io_pending;
64 xlist<IOContext*> m_io_finished;
66 static void aio_callback(librbd::completion_t cb, void *arg);
74 void io_start(IOContext *ctx);
75 void io_finish(IOContext *ctx);
77 IOContext *wait_io_finish();
80 void handle_aio(IOContext *ctx, int r);
83 std::ostream &operator<<(std::ostream &os, const Server::IOContext &ctx);
88 #endif // CEPH_RBD_GGATE_SERVER_H