Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / journal / StandardPolicy.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "librbd/journal/StandardPolicy.h"
5 #include "common/WorkQueue.h"
6 #include "librbd/ImageCtx.h"
7 #include "librbd/Journal.h"
8
9 #define dout_subsys ceph_subsys_rbd
10 #undef dout_prefix
11 #define dout_prefix *_dout << "librbd::journal::StandardPolicy: "
12
13 namespace librbd {
14 namespace journal {
15
16 template<typename I>
17 void StandardPolicy<I>::allocate_tag_on_lock(Context *on_finish) {
18   assert(m_image_ctx->journal != nullptr);
19
20   if (!m_image_ctx->journal->is_tag_owner()) {
21     lderr(m_image_ctx->cct) << "local image not promoted" << dendl;
22     m_image_ctx->op_work_queue->queue(on_finish, -EPERM);
23     return;
24   }
25
26   m_image_ctx->journal->allocate_local_tag(on_finish);
27 }
28
29 } // namespace journal
30 } // namespace librbd
31
32 template class librbd::journal::StandardPolicy<librbd::ImageCtx>;