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