]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/object_map/UnlockRequest.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/object_map/UnlockRequest.h"
5 #include "cls/lock/cls_lock_client.h"
6 #include "common/dout.h"
7 #include "common/errno.h"
8 #include "librbd/ImageCtx.h"
9 #include "librbd/ObjectMap.h"
10 #include "librbd/Utils.h"
12 #define dout_subsys ceph_subsys_rbd
14 #define dout_prefix *_dout << "librbd::object_map::UnlockRequest: "
17 namespace object_map
{
19 using util::create_rados_callback
;
22 UnlockRequest
<I
>::UnlockRequest(I
&image_ctx
, Context
*on_finish
)
23 : m_image_ctx(image_ctx
), m_on_finish(on_finish
) {
27 void UnlockRequest
<I
>::send() {
32 void UnlockRequest
<I
>::send_unlock() {
33 CephContext
*cct
= m_image_ctx
.cct
;
34 std::string
oid(ObjectMap
<>::object_map_name(m_image_ctx
.id
, CEPH_NOSNAP
));
35 ldout(cct
, 10) << this << " " << __func__
<< ": oid=" << oid
<< dendl
;
37 librados::ObjectWriteOperation op
;
38 rados::cls::lock::unlock(&op
, RBD_LOCK_NAME
, "");
40 using klass
= UnlockRequest
<I
>;
41 librados::AioCompletion
*rados_completion
=
42 create_rados_callback
<klass
, &klass::handle_unlock
>(this);
43 int r
= m_image_ctx
.md_ctx
.aio_operate(oid
, rados_completion
, &op
);
45 rados_completion
->release();
49 Context
*UnlockRequest
<I
>::handle_unlock(int *ret_val
) {
50 CephContext
*cct
= m_image_ctx
.cct
;
51 ldout(cct
, 10) << this << " " << __func__
<< ": r=" << *ret_val
<< dendl
;
53 if (*ret_val
< 0 && *ret_val
!= -ENOENT
) {
54 lderr(m_image_ctx
.cct
) << "failed to release object map lock: "
55 << cpp_strerror(*ret_val
) << dendl
;
63 } // namespace object_map
66 template class librbd::object_map::UnlockRequest
<librbd::ImageCtx
>;