#include "librbd/Journal.h"
#include "include/rados/librados.hpp"
+#include "common/AsyncOpTracker.h"
#include "common/errno.h"
#include "common/Timer.h"
#include "common/WorkQueue.h"
std::lock_guard locker{m_lock};
m_journaler->shut_down(ctx);
});
- m_async_journal_op_tracker.wait(m_image_ctx, ctx);
+ ctx = create_async_context_callback(m_image_ctx, ctx);
+ m_async_journal_op_tracker.wait_for_ops(ctx);
}
template <typename I>
}
struct C_RefreshTags : public Context {
- util::AsyncOpTracker &async_op_tracker;
+ AsyncOpTracker &async_op_tracker;
Context *on_finish = nullptr;
ceph::mutex lock =
uint64_t tag_tid = 0;
journal::TagData tag_data;
- explicit C_RefreshTags(util::AsyncOpTracker &async_op_tracker)
+ explicit C_RefreshTags(AsyncOpTracker &async_op_tracker)
: async_op_tracker(async_op_tracker) {
async_op_tracker.start_op();
}
#include "include/Context.h"
#include "include/interval_set.h"
#include "include/rados/librados_fwd.hpp"
+#include "common/AsyncOpTracker.h"
#include "common/Cond.h"
#include "common/WorkQueue.h"
#include "journal/Future.h"
journal::Replay<ImageCtxT> *m_journal_replay;
- util::AsyncOpTracker m_async_journal_op_tracker;
+ AsyncOpTracker m_async_journal_op_tracker;
struct MetadataListener : public ::journal::JournalMetadataListener {
Journal<ImageCtxT> *journal;
return image_ctx;
}
-/// helper for tracking in-flight async ops when coordinating
-/// a shut down of the invoking class instance
-class AsyncOpTracker {
-public:
- void start_op() {
- m_refs++;
- }
-
- void finish_op() {
- if (--m_refs == 0 && m_on_finish != nullptr) {
- Context *on_finish = nullptr;
- std::swap(on_finish, m_on_finish);
- on_finish->complete(0);
- }
- }
-
- template <typename I>
- void wait(I &image_ctx, Context *on_finish) {
- ceph_assert(m_on_finish == nullptr);
-
- on_finish = create_async_context_callback(image_ctx, on_finish);
- if (m_refs == 0) {
- on_finish->complete(0);
- return;
- }
- m_on_finish = on_finish;
- }
-
-private:
- std::atomic<uint64_t> m_refs = { 0 };
- Context *m_on_finish = nullptr;
-};
-
uint64_t get_rbd_default_features(CephContext* cct);
bool calc_sparse_extent(const bufferptr &bp,