summaryrefslogtreecommitdiffstats
path: root/src/librbd/exclusive_lock/AutomaticPolicy.cc
blob: bfaddc1b2ba3eadd469d97278a143cf30e9f4c5b (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
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "librbd/exclusive_lock/AutomaticPolicy.h"
#include "librbd/ImageCtx.h"
#include "librbd/ExclusiveLock.h"

#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
#define dout_prefix *_dout << "librbd::ExclusiveLock::AutomaticPolicy "

namespace librbd {
namespace exclusive_lock {

int AutomaticPolicy::lock_requested(bool force) {
  ceph_assert(ceph_mutex_is_locked(m_image_ctx->owner_lock));
  ceph_assert(m_image_ctx->exclusive_lock != nullptr);

  ldout(m_image_ctx->cct, 20) << this << " " << __func__ << ": force=" << force
			      << dendl;

  // release the lock upon request (ignore forced requests)
  m_image_ctx->exclusive_lock->release_lock(nullptr);
  return 0;
}

} // namespace exclusive_lock
} // namespace librbd