]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/object_map/RemoveRequest.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/RemoveRequest.h"
5 #include "common/dout.h"
6 #include "common/errno.h"
7 #include "cls/rbd/cls_rbd_client.h"
8 #include "librbd/ImageCtx.h"
9 #include "librbd/ObjectMap.h"
10 #include "librbd/Utils.h"
11 #include "include/ceph_assert.h"
13 #define dout_subsys ceph_subsys_rbd
15 #define dout_prefix *_dout << "librbd::object_map::RemoveRequest: "
18 namespace object_map
{
20 using util::create_rados_callback
;
23 RemoveRequest
<I
>::RemoveRequest(I
*image_ctx
, Context
*on_finish
)
24 : m_image_ctx(image_ctx
), m_on_finish(on_finish
) {
28 void RemoveRequest
<I
>::send() {
29 send_remove_object_map();
33 void RemoveRequest
<I
>::send_remove_object_map() {
34 CephContext
*cct
= m_image_ctx
->cct
;
35 ldout(cct
, 20) << __func__
<< dendl
;
37 std::unique_lock image_locker
{m_image_ctx
->image_lock
};
38 std::vector
<uint64_t> snap_ids
;
39 snap_ids
.push_back(CEPH_NOSNAP
);
40 for (auto it
: m_image_ctx
->snap_info
) {
41 snap_ids
.push_back(it
.first
);
44 std::lock_guard locker
{m_lock
};
45 ceph_assert(m_ref_counter
== 0);
47 for (auto snap_id
: snap_ids
) {
49 std::string
oid(ObjectMap
<>::object_map_name(m_image_ctx
->id
, snap_id
));
50 using klass
= RemoveRequest
<I
>;
51 librados::AioCompletion
*comp
=
52 create_rados_callback
<klass
, &klass::handle_remove_object_map
>(this);
54 int r
= m_image_ctx
->md_ctx
.aio_remove(oid
, comp
);
61 Context
*RemoveRequest
<I
>::handle_remove_object_map(int *result
) {
62 CephContext
*cct
= m_image_ctx
->cct
;
63 ldout(cct
, 20) << __func__
<< ": r=" << *result
<< dendl
;
66 std::lock_guard locker
{m_lock
};
67 ceph_assert(m_ref_counter
> 0);
70 if (*result
< 0 && *result
!= -ENOENT
) {
71 lderr(cct
) << "failed to remove object map: " << cpp_strerror(*result
)
73 m_error_result
= *result
;
75 if (m_ref_counter
> 0) {
79 if (m_error_result
< 0) {
80 *result
= m_error_result
;
85 } // namespace object_map
88 template class librbd::object_map::RemoveRequest
<librbd::ImageCtx
>;