1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IO_FLUSH_TRACKER_H
5 #define CEPH_LIBRBD_IO_FLUSH_TRACKER_H
7 #include "include/int_types.h"
8 #include "common/ceph_mutex.h"
13 #include <unordered_map>
25 template <typename ImageCtxT
>
28 FlushTracker(ImageCtxT
* image_ctx
);
33 uint64_t start_io(uint64_t tid
);
34 void finish_io(uint64_t tid
);
36 void flush(Context
* on_finish
);
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
;
44 ImageCtxT
* m_image_ctx
;
46 std::atomic
<uint32_t> m_next_flush_tid
{0};
48 mutable ceph::shared_mutex m_lock
;
49 TidToFlushTid m_tid_to_flush_tid
;
51 Tids m_in_flight_flush_tids
;
52 FlushContexts m_flush_contexts
;
59 extern template class librbd::io::FlushTracker
<librbd::ImageCtx
>;
61 #endif // CEPH_LIBRBD_IO_FLUSH_TRACKER_H