Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / api / DiffIterate.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_API_DIFF_ITERATE_H
5 #define CEPH_LIBRBD_API_DIFF_ITERATE_H
6
7 #include "include/int_types.h"
8 #include "common/bit_vector.hpp"
9 #include "cls/rbd/cls_rbd_types.h"
10
11 namespace librbd {
12
13 class ImageCtx;
14
15 namespace api {
16
17 template <typename ImageCtxT = librbd::ImageCtx>
18 class DiffIterate {
19 public:
20   typedef int (*Callback)(uint64_t, size_t, int, void *);
21
22   static int diff_iterate(ImageCtxT *ictx,
23                           const cls::rbd::SnapshotNamespace& from_snap_namespace,
24                           const char *fromsnapname,
25                           uint64_t off, uint64_t len, bool include_parent,
26                           bool whole_object,
27                           int (*cb)(uint64_t, size_t, int, void *),
28                           void *arg);
29
30 private:
31   ImageCtxT &m_image_ctx;
32   cls::rbd::SnapshotNamespace m_from_snap_namespace;
33   const char* m_from_snap_name;
34   uint64_t m_offset;
35   uint64_t m_length;
36   bool m_include_parent;
37   bool m_whole_object;
38   Callback m_callback;
39   void *m_callback_arg;
40
41   DiffIterate(ImageCtxT &image_ctx, 
42               const cls::rbd::SnapshotNamespace& from_snap_namespace,
43               const char *from_snap_name, uint64_t off, uint64_t len,
44               bool include_parent, bool whole_object, Callback callback,
45               void *callback_arg)
46     : m_image_ctx(image_ctx), m_from_snap_namespace(from_snap_namespace),
47       m_from_snap_name(from_snap_name), m_offset(off),
48       m_length(len), m_include_parent(include_parent),
49       m_whole_object(whole_object), m_callback(callback),
50       m_callback_arg(callback_arg)
51   {
52   }
53
54   int execute();
55
56   int diff_object_map(uint64_t from_snap_id, uint64_t to_snap_id,
57                       BitVector<2>* object_diff_state);
58
59 };
60
61 } // namespace api
62 } // namespace librbd
63
64 extern template class librbd::api::DiffIterate<librbd::ImageCtx>;
65
66 #endif // CEPH_LIBRBD_API_DIFF_ITERATE_H