]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/image/GetMetadataRequest.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / librbd / image / GetMetadataRequest.h
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_IMAGE_GET_METADATA_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_GET_METADATA_REQUEST_H
6
7 #include "include/common_fwd.h"
8 #include "include/rados/librados.hpp"
9 #include "include/rbd/librbd.hpp"
10 #include <string>
11 #include <map>
12
13 class Context;
14
15 namespace librbd {
16
17 struct ImageCtx;
18
19 namespace image {
20
21 template <typename ImageCtxT = ImageCtx>
22 class GetMetadataRequest {
23 public:
24 typedef std::map<std::string, bufferlist> KeyValues;
25
26 static GetMetadataRequest* create(
27 IoCtx &io_ctx, const std::string &oid, bool filter_internal,
28 const std::string& filter_key_prefix, const std::string& last_key,
29 uint32_t max_results, KeyValues* key_values, Context *on_finish) {
30 return new GetMetadataRequest(io_ctx, oid, filter_internal,
31 filter_key_prefix, last_key, max_results,
32 key_values, on_finish);
33 }
34
35 GetMetadataRequest(
36 IoCtx &io_ctx, const std::string &oid, bool filter_internal,
37 const std::string& filter_key_prefix, const std::string& last_key,
38 uint32_t max_results, KeyValues* key_values, Context *on_finish);
39
40 void send();
41
42 private:
43 /**
44 * @verbatim
45 *
46 * <start>
47 * |
48 * | /-------\
49 * | | |
50 * v v |
51 * METADATA_LIST ---/
52 * |
53 * v
54 * <finish>
55 *
56 * @endverbatim
57 */
58 librados::IoCtx m_io_ctx;
59 std::string m_oid;
60 bool m_filter_internal;
61 std::string m_filter_key_prefix;
62 std::string m_last_key;
63 uint32_t m_max_results;
64 KeyValues* m_key_values;
65 Context* m_on_finish;
66
67 CephContext* m_cct;
68 bufferlist m_out_bl;
69 uint32_t m_expected_results = 0;
70
71 void metadata_list();
72 void handle_metadata_list(int r);
73
74 void finish(int r);
75
76 };
77
78 } //namespace image
79 } //namespace librbd
80
81 extern template class librbd::image::GetMetadataRequest<librbd::ImageCtx>;
82
83 #endif // CEPH_LIBRBD_IMAGE_GET_METADATA_REQUEST_H