]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/deep_copy/MetadataCopyRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / deep_copy / MetadataCopyRequest.h
CommitLineData
11fdf7f2
TL
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_LIBRBD_DEEP_COPY_METADATA_COPY_REQUEST_H
5#define CEPH_LIBRBD_DEEP_COPY_METADATA_COPY_REQUEST_H
6
7#include "include/int_types.h"
8#include "include/buffer.h"
9#include "include/rados/librados.hpp"
10#include "librbd/ImageCtx.h"
11#include <map>
12#include <string>
13
14class Context;
15
16namespace librbd {
17namespace deep_copy {
18
19template <typename ImageCtxT = librbd::ImageCtx>
20class MetadataCopyRequest {
21public:
22 static MetadataCopyRequest* create(ImageCtxT *src_image_ctx,
23 ImageCtxT *dst_image_ctx,
24 Context *on_finish) {
25 return new MetadataCopyRequest(src_image_ctx, dst_image_ctx, on_finish);
26 }
27
28 MetadataCopyRequest(ImageCtxT *src_image_ctx, ImageCtxT *dst_image_ctx,
29 Context *on_finish);
30
31 void send();
32
33private:
34 /**
35 * @verbatim
36 *
37 * <start>
38 * |
39 * v
40 * LIST_SRC_METADATA <------\
41 * | | (repeat if additional
42 * v | metadata)
43 * SET_DST_METADATA --------/
44 * |
45 * v
46 * <finish>
47 *
48 * @endverbatim
49 */
50 typedef std::map<std::string, bufferlist> Metadata;
51
52 ImageCtxT *m_src_image_ctx;
53 ImageCtxT *m_dst_image_ctx;
54 Context *m_on_finish;
55
56 CephContext *m_cct;
57 bufferlist m_out_bl;
58
9f95a23c 59 std::map<std::string, bufferlist> m_metadata;
11fdf7f2
TL
60 std::string m_last_metadata_key;
61 bool m_more_metadata = false;
62
63 void list_src_metadata();
64 void handle_list_src_metadata(int r);
65
9f95a23c 66 void set_dst_metadata();
11fdf7f2
TL
67 void handle_set_dst_metadata(int r);
68
69 void finish(int r);
70
71};
72
73} // namespace deep_copy
74} // namespace librbd
75
76extern template class librbd::deep_copy::MetadataCopyRequest<librbd::ImageCtx>;
77
78#endif // CEPH_LIBRBD_DEEP_COPY_METADATA_COPY_REQUEST_H