]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
f67539c2 | 39 | void encode(ceph::buffer::list &bl) const |
7c673cae FG |
40 | { |
41 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
42 | encode(id, bl); |
43 | encode(size, bl); | |
7c673cae FG |
44 | ENCODE_FINISH(bl); |
45 | } | |
46 | ||
f67539c2 | 47 | void decode(ceph::buffer::list::const_iterator &p) |
7c673cae FG |
48 | { |
49 | DECODE_START(1, p); | |
11fdf7f2 TL |
50 | decode(id, p); |
51 | decode(size, p); | |
7c673cae FG |
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_, | |
11fdf7f2 TL |
71 | const std::string &obj_xattr_name_, |
72 | const std::string &mtime_xattr_name_, | |
73 | const std::string &obj_size_xattr_name_) | |
7c673cae FG |
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 | ||
f67539c2 | 86 | void encode(ceph::buffer::list &bl) const |
7c673cae FG |
87 | { |
88 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
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); | |
7c673cae FG |
95 | ENCODE_FINISH(bl); |
96 | } | |
97 | ||
f67539c2 | 98 | void decode(ceph::buffer::list::const_iterator &bl) |
7c673cae FG |
99 | { |
100 | DECODE_START(1, bl); | |
11fdf7f2 TL |
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); | |
7c673cae FG |
107 | DECODE_FINISH(bl); |
108 | } | |
109 | }; | |
110 | ||
111 | class InodeTagFilterArgs | |
112 | { | |
113 | public: | |
114 | std::string scrub_tag; | |
115 | ||
f67539c2 | 116 | void encode(ceph::buffer::list &bl) const |
7c673cae FG |
117 | { |
118 | ENCODE_START(1, 1, bl); | |
11fdf7f2 | 119 | encode(scrub_tag, bl); |
7c673cae FG |
120 | ENCODE_FINISH(bl); |
121 | } | |
122 | ||
f67539c2 | 123 | void decode(ceph::buffer::list::const_iterator &bl) |
7c673cae FG |
124 | { |
125 | DECODE_START(1, bl); | |
11fdf7f2 | 126 | decode(scrub_tag, bl); |
7c673cae FG |
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; | |
1e59de90 TL |
140 | // Non-default object pool id seen |
141 | int64_t obj_pool_id; | |
7c673cae FG |
142 | // Highest mtime seen |
143 | int64_t max_mtime; | |
144 | ||
145 | AccumulateResult() | |
1e59de90 TL |
146 | : ceiling_obj_index(0), ceiling_obj_size(0), max_obj_size(0), |
147 | obj_pool_id(-1), max_mtime(0) | |
7c673cae FG |
148 | {} |
149 | }; | |
150 |