]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/operation/MetadataSetRequest.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/MetadataSetRequest.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::MetadataSetRequest: "
17 MetadataSetRequest
<I
>::MetadataSetRequest(I
&image_ctx
,
19 const std::string
&key
,
20 const std::string
&value
)
21 : Request
<I
>(image_ctx
, on_finish
), m_key(key
), m_value(value
) {
25 void MetadataSetRequest
<I
>::send_op() {
30 bool MetadataSetRequest
<I
>::should_complete(int r
) {
31 I
&image_ctx
= this->m_image_ctx
;
32 CephContext
*cct
= image_ctx
.cct
;
33 ldout(cct
, 20) << this << " " << __func__
<< " r=" << r
<< dendl
;
36 lderr(cct
) << "encountered error: " << cpp_strerror(r
) << dendl
;
42 void MetadataSetRequest
<I
>::send_metadata_set() {
43 I
&image_ctx
= this->m_image_ctx
;
44 ceph_assert(ceph_mutex_is_locked(image_ctx
.owner_lock
));
46 CephContext
*cct
= image_ctx
.cct
;
47 ldout(cct
, 20) << this << " " << __func__
<< dendl
;
49 m_data
[m_key
].append(m_value
);
50 librados::ObjectWriteOperation op
;
51 cls_client::metadata_set(&op
, m_data
);
53 librados::AioCompletion
*comp
= this->create_callback_completion();
54 int r
= image_ctx
.md_ctx
.aio_operate(image_ctx
.header_oid
, comp
, &op
);
59 } // namespace operation
62 template class librbd::operation::MetadataSetRequest
<librbd::ImageCtx
>;