]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/operation/SnapshotLimitRequest.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / librbd / operation / SnapshotLimitRequest.cc
CommitLineData
7c673cae
FG
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/operation/SnapshotLimitRequest.h"
5#include "common/dout.h"
6#include "common/errno.h"
7#include "librbd/ImageCtx.h"
8
9#define dout_subsys ceph_subsys_rbd
10#undef dout_prefix
11#define dout_prefix *_dout << "librbd::SnapshotLimitRequest: "
12
13namespace librbd {
14namespace operation {
15
16template <typename I>
17SnapshotLimitRequest<I>::SnapshotLimitRequest(I &image_ctx,
18 Context *on_finish,
19 uint64_t limit)
20 : Request<I>(image_ctx, on_finish), m_snap_limit(limit) {
21}
22
23template <typename I>
24void SnapshotLimitRequest<I>::send_op() {
25 send_limit_snaps();
26}
27
28template <typename I>
29bool SnapshotLimitRequest<I>::should_complete(int r) {
30 I &image_ctx = this->m_image_ctx;
31 CephContext *cct = image_ctx.cct;
11fdf7f2 32 ldout(cct, 5) << this << " " << __func__ << " r=" << r << dendl;
7c673cae
FG
33
34 if (r < 0) {
35 lderr(cct) << "encountered error: " << cpp_strerror(r) << dendl;
36 }
37 return true;
38}
39
40template <typename I>
41void SnapshotLimitRequest<I>::send_limit_snaps() {
42 I &image_ctx = this->m_image_ctx;
11fdf7f2 43 ceph_assert(image_ctx.owner_lock.is_locked());
7c673cae
FG
44
45 CephContext *cct = image_ctx.cct;
46 ldout(cct, 5) << this << " " << __func__ << dendl;
47
48 {
49 RWLock::RLocker md_locker(image_ctx.md_lock);
50 RWLock::RLocker snap_locker(image_ctx.snap_lock);
51
52 librados::ObjectWriteOperation op;
53 cls_client::snapshot_set_limit(&op, m_snap_limit);
54
55 librados::AioCompletion *rados_completion =
56 this->create_callback_completion();
57 int r = image_ctx.md_ctx.aio_operate(image_ctx.header_oid, rados_completion,
58 &op);
11fdf7f2 59 ceph_assert(r == 0);
7c673cae
FG
60 rados_completion->release();
61 }
62}
63
64} // namespace operation
65} // namespace librbd
66
67template class librbd::operation::SnapshotLimitRequest<librbd::ImageCtx>;