]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/io/FlushTracker.h
import 15.2.5
[ceph.git] / ceph / src / librbd / io / FlushTracker.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_LIBRBD_IO_FLUSH_TRACKER_H
5 #define CEPH_LIBRBD_IO_FLUSH_TRACKER_H
6
7 #include "include/int_types.h"
8 #include "common/ceph_mutex.h"
9 #include <atomic>
10 #include <list>
11 #include <map>
12 #include <set>
13 #include <unordered_map>
14
15 struct Context;
16
17 namespace librbd {
18
19 struct ImageCtx;
20
21 namespace io {
22
23 struct AioCompletion;
24
25 template <typename ImageCtxT>
26 class FlushTracker {
27 public:
28 FlushTracker(ImageCtxT* image_ctx);
29 ~FlushTracker();
30
31 void shut_down();
32
33 uint64_t start_io(uint64_t tid);
34 void finish_io(uint64_t tid);
35
36 void flush(Context* on_finish);
37
38 private:
39 typedef std::list<Context*> Contexts;
40 typedef std::map<uint64_t, Contexts> FlushContexts;
41 typedef std::set<uint64_t> Tids;
42 typedef std::unordered_map<uint64_t, uint64_t> TidToFlushTid;
43
44 ImageCtxT* m_image_ctx;
45
46 std::atomic<uint32_t> m_next_flush_tid{0};
47
48 mutable ceph::shared_mutex m_lock;
49 TidToFlushTid m_tid_to_flush_tid;
50
51 Tids m_in_flight_flush_tids;
52 FlushContexts m_flush_contexts;
53
54 };
55
56 } // namespace io
57 } // namespace librbd
58
59 extern template class librbd::io::FlushTracker<librbd::ImageCtx>;
60
61 #endif // CEPH_LIBRBD_IO_FLUSH_TRACKER_H