Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / cephfs / cls_cephfs.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2015 Red Hat
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #include "include/encoding.h"
16
17 /**
18  * Value class for the xattr we'll use to accumulate
19  * the highest object seen for a given inode
20  */
21 class ObjCeiling {
22   public:
23     uint64_t id;
24     uint64_t size;
25
26     ObjCeiling()
27       : id(0), size(0)
28     {}
29
30     ObjCeiling(uint64_t id_, uint64_t size_)
31       : id(id_), size(size_)
32     {}
33
34     bool operator >(ObjCeiling const &rhs) const
35     {
36       return id > rhs.id;
37     }
38
39     void encode(bufferlist &bl) const
40     {
41       ENCODE_START(1, 1, bl);
42       ::encode(id, bl);
43       ::encode(size, bl);
44       ENCODE_FINISH(bl);
45     }
46
47     void decode(bufferlist::iterator &p)
48     {
49       DECODE_START(1, p);
50       ::decode(id, p);
51       ::decode(size, p);
52       DECODE_FINISH(p);
53     }
54 };
55 WRITE_CLASS_ENCODER(ObjCeiling)
56
57 class AccumulateArgs
58 {
59 public:
60   uint64_t obj_index;
61   uint64_t obj_size;
62   int64_t mtime;
63   std::string obj_xattr_name;
64   std::string mtime_xattr_name;
65   std::string obj_size_xattr_name;
66
67   AccumulateArgs(
68       uint64_t obj_index_,
69       uint64_t obj_size_,
70       time_t mtime_,
71       std::string obj_xattr_name_,
72       std::string mtime_xattr_name_,
73       std::string obj_size_xattr_name_)
74    : obj_index(obj_index_),
75      obj_size(obj_size_),
76      mtime(mtime_),
77      obj_xattr_name(obj_xattr_name_),
78      mtime_xattr_name(mtime_xattr_name_),
79      obj_size_xattr_name(obj_size_xattr_name_)
80   {}
81
82   AccumulateArgs()
83     : obj_index(0), obj_size(0), mtime(0)
84   {}
85
86   void encode(bufferlist &bl) const
87   {
88     ENCODE_START(1, 1, bl);
89     ::encode(obj_xattr_name, bl);
90     ::encode(mtime_xattr_name, bl);
91     ::encode(obj_size_xattr_name, bl);
92     ::encode(obj_index, bl);
93     ::encode(obj_size, bl);
94     ::encode(mtime, bl);
95     ENCODE_FINISH(bl);
96   }
97
98   void decode(bufferlist::iterator &bl)
99   {
100     DECODE_START(1, bl);
101     ::decode(obj_xattr_name, bl);
102     ::decode(mtime_xattr_name, bl);
103     ::decode(obj_size_xattr_name, bl);
104     ::decode(obj_index, bl);
105     ::decode(obj_size, bl);
106     ::decode(mtime, bl);
107     DECODE_FINISH(bl);
108   }
109 };
110
111 class InodeTagFilterArgs
112 {
113   public:
114     std::string scrub_tag;
115
116   void encode(bufferlist &bl) const
117   {
118     ENCODE_START(1, 1, bl);
119     ::encode(scrub_tag, bl);
120     ENCODE_FINISH(bl);
121   }
122
123   void decode(bufferlist::iterator &bl)
124   {
125     DECODE_START(1, bl);
126     ::decode(scrub_tag, bl);
127     DECODE_FINISH(bl);
128   }
129 };
130
131 class AccumulateResult
132 {
133 public:
134   // Index of the highest-indexed object seen
135   uint64_t ceiling_obj_index;
136   // Size of the highest-index object seen
137   uint64_t ceiling_obj_size;
138   // Largest object seen
139   uint64_t max_obj_size;
140   // Highest mtime seen
141   int64_t   max_mtime;
142
143   AccumulateResult()
144     : ceiling_obj_index(0), ceiling_obj_size(0), max_obj_size(0), max_mtime(0)
145   {}
146 };
147