Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / rbd_replay / PendingIO.hpp
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2014 Adam Crume <adamcrume@gmail.com>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #ifndef _INCLUDED_RBD_REPLAY_PENDINGIO_HPP
16 #define _INCLUDED_RBD_REPLAY_PENDINGIO_HPP
17
18 #include <boost/enable_shared_from_this.hpp>
19 #include "actions.hpp"
20
21 /// Do not call outside of rbd_replay::PendingIO.
22 extern "C"
23 void rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg);
24
25 namespace rbd_replay {
26
27 /**
28    A PendingIO is an I/O operation that has been started but not completed.
29 */
30 class PendingIO : public boost::enable_shared_from_this<PendingIO> {
31 public:
32   typedef boost::shared_ptr<PendingIO> ptr;
33
34   PendingIO(action_id_t id,
35             ActionCtx &worker);
36
37   ~PendingIO();
38
39   action_id_t id() const {
40     return m_id;
41   }
42
43   ceph::bufferlist &bufferlist() {
44     return m_bl;
45   }
46
47   librbd::RBD::AioCompletion &completion() {
48     return *m_completion;
49   }
50
51 private:
52   void completed(librbd::completion_t cb);
53
54   friend void ::rbd_replay_pending_io_callback(librbd::completion_t cb, void *arg);
55
56   const action_id_t m_id;
57   ceph::bufferlist m_bl;
58   librbd::RBD::AioCompletion *m_completion;
59   ActionCtx &m_worker;
60 };
61
62 }
63
64 #endif