diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/librbd/io/FlushTracker.h | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/librbd/io/FlushTracker.h')
-rw-r--r-- | src/librbd/io/FlushTracker.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/librbd/io/FlushTracker.h b/src/librbd/io/FlushTracker.h new file mode 100644 index 000000000..cc7fcd9ae --- /dev/null +++ b/src/librbd/io/FlushTracker.h @@ -0,0 +1,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 |