]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/operation/SnapshotLimitRequest.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "librbd/operation/SnapshotLimitRequest.h"
5 #include "common/dout.h"
6 #include "common/errno.h"
7 #include "librbd/ImageCtx.h"
9 #define dout_subsys ceph_subsys_rbd
11 #define dout_prefix *_dout << "librbd::SnapshotLimitRequest: "
17 SnapshotLimitRequest
<I
>::SnapshotLimitRequest(I
&image_ctx
,
20 : Request
<I
>(image_ctx
, on_finish
), m_snap_limit(limit
) {
24 void SnapshotLimitRequest
<I
>::send_op() {
29 bool SnapshotLimitRequest
<I
>::should_complete(int r
) {
30 I
&image_ctx
= this->m_image_ctx
;
31 CephContext
*cct
= image_ctx
.cct
;
32 ldout(cct
, 5) << this << " " << __func__
<< " r=" << r
<< dendl
;
35 lderr(cct
) << "encountered error: " << cpp_strerror(r
) << dendl
;
41 void SnapshotLimitRequest
<I
>::send_limit_snaps() {
42 I
&image_ctx
= this->m_image_ctx
;
43 ceph_assert(image_ctx
.owner_lock
.is_locked());
45 CephContext
*cct
= image_ctx
.cct
;
46 ldout(cct
, 5) << this << " " << __func__
<< dendl
;
49 RWLock::RLocker
md_locker(image_ctx
.md_lock
);
50 RWLock::RLocker
snap_locker(image_ctx
.snap_lock
);
52 librados::ObjectWriteOperation op
;
53 cls_client::snapshot_set_limit(&op
, m_snap_limit
);
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
,
60 rados_completion
->release();
64 } // namespace operation
67 template class librbd::operation::SnapshotLimitRequest
<librbd::ImageCtx
>;