]>
Commit | Line | Data |
---|---|---|
f64942e4 AA |
1 | // -*- mode:C; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
7c673cae FG |
4 | #ifndef CEPH_CLS_RGW_CLIENT_H |
5 | #define CEPH_CLS_RGW_CLIENT_H | |
6 | ||
7c673cae FG |
7 | #include "include/str_list.h" |
8 | #include "include/rados/librados.hpp" | |
7c673cae | 9 | #include "cls_rgw_ops.h" |
b32b8144 | 10 | #include "cls_rgw_const.h" |
7c673cae FG |
11 | #include "common/RefCountedObj.h" |
12 | #include "include/compat.h" | |
13 | #include "common/ceph_time.h" | |
11fdf7f2 TL |
14 | #include "common/Mutex.h" |
15 | #include "common/Cond.h" | |
7c673cae FG |
16 | |
17 | // Forward declaration | |
18 | class BucketIndexAioManager; | |
7c673cae FG |
19 | /* |
20 | * Bucket index AIO request argument, this is used to pass a argument | |
21 | * to callback. | |
22 | */ | |
23 | struct BucketIndexAioArg : public RefCountedObject { | |
24 | BucketIndexAioArg(int _id, BucketIndexAioManager* _manager) : | |
25 | id(_id), manager(_manager) {} | |
26 | int id; | |
27 | BucketIndexAioManager* manager; | |
28 | }; | |
29 | ||
30 | /* | |
31 | * This class manages AIO completions. This class is not completely thread-safe, | |
32 | * methods like *get_next* is not thread-safe and is expected to be called from | |
33 | * within one thread. | |
34 | */ | |
35 | class BucketIndexAioManager { | |
36 | private: | |
37 | map<int, librados::AioCompletion*> pendings; | |
38 | map<int, librados::AioCompletion*> completions; | |
39 | map<int, string> pending_objs; | |
40 | map<int, string> completion_objs; | |
41 | int next; | |
42 | Mutex lock; | |
43 | Cond cond; | |
44 | /* | |
45 | * Callback implementation for AIO request. | |
46 | */ | |
47 | static void bucket_index_op_completion_cb(void* cb, void* arg) { | |
48 | BucketIndexAioArg* cb_arg = (BucketIndexAioArg*) arg; | |
49 | cb_arg->manager->do_completion(cb_arg->id); | |
50 | cb_arg->put(); | |
51 | } | |
52 | ||
53 | /* | |
54 | * Get next request ID. This method is not thread-safe. | |
55 | * | |
56 | * Return next request ID. | |
57 | */ | |
58 | int get_next() { return next++; } | |
59 | ||
60 | /* | |
61 | * Add a new pending AIO completion instance. | |
62 | * | |
63 | * @param id - the request ID. | |
64 | * @param completion - the AIO completion instance. | |
65 | * @param oid - the object id associated with the object, if it is NULL, we don't | |
66 | * track the object id per callback. | |
67 | */ | |
68 | void add_pending(int id, librados::AioCompletion* completion, const string& oid) { | |
69 | pendings[id] = completion; | |
70 | pending_objs[id] = oid; | |
71 | } | |
72 | public: | |
73 | /* | |
74 | * Create a new instance. | |
75 | */ | |
76 | BucketIndexAioManager() : next(0), lock("BucketIndexAioManager::lock") {} | |
77 | ||
78 | ||
79 | /* | |
80 | * Do completion for the given AIO request. | |
81 | */ | |
82 | void do_completion(int id); | |
83 | ||
84 | /* | |
85 | * Wait for AIO completions. | |
86 | * | |
87 | * valid_ret_code - valid AIO return code. | |
88 | * num_completions - number of completions. | |
89 | * ret_code - return code of failed AIO. | |
90 | * objs - a list of objects that has been finished the AIO. | |
91 | * | |
92 | * Return false if there is no pending AIO, true otherwise. | |
93 | */ | |
94 | bool wait_for_completions(int valid_ret_code, int *num_completions, int *ret_code, | |
95 | map<int, string> *objs); | |
96 | ||
97 | /** | |
98 | * Do aio read operation. | |
99 | */ | |
100 | bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectReadOperation *op) { | |
101 | Mutex::Locker l(lock); | |
102 | BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); | |
103 | librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb); | |
104 | int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL); | |
105 | if (r >= 0) { | |
106 | add_pending(arg->id, c, oid); | |
107 | } else { | |
108 | c->release(); | |
109 | } | |
110 | return r; | |
111 | } | |
112 | ||
113 | /** | |
114 | * Do aio write operation. | |
115 | */ | |
116 | bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectWriteOperation *op) { | |
117 | Mutex::Locker l(lock); | |
118 | BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this); | |
119 | librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb); | |
120 | int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op); | |
121 | if (r >= 0) { | |
122 | add_pending(arg->id, c, oid); | |
123 | } else { | |
124 | c->release(); | |
125 | } | |
126 | return r; | |
127 | } | |
128 | }; | |
129 | ||
130 | class RGWGetDirHeader_CB : public RefCountedObject { | |
131 | public: | |
132 | ~RGWGetDirHeader_CB() override {} | |
133 | virtual void handle_response(int r, rgw_bucket_dir_header& header) = 0; | |
134 | }; | |
135 | ||
136 | class BucketIndexShardsManager { | |
137 | private: | |
138 | // Per shard setting manager, for example, marker. | |
139 | map<int, string> value_by_shards; | |
140 | public: | |
141 | const static string KEY_VALUE_SEPARATOR; | |
142 | const static string SHARDS_SEPARATOR; | |
143 | ||
144 | void add(int shard, const string& value) { | |
145 | value_by_shards[shard] = value; | |
146 | } | |
147 | ||
148 | const string& get(int shard, const string& default_value) { | |
149 | map<int, string>::iterator iter = value_by_shards.find(shard); | |
150 | return (iter == value_by_shards.end() ? default_value : iter->second); | |
151 | } | |
152 | ||
153 | map<int, string>& get() { | |
154 | return value_by_shards; | |
155 | } | |
156 | ||
157 | bool empty() { | |
158 | return value_by_shards.empty(); | |
159 | } | |
160 | ||
161 | void to_string(string *out) const { | |
162 | if (!out) { | |
163 | return; | |
164 | } | |
165 | out->clear(); | |
166 | map<int, string>::const_iterator iter = value_by_shards.begin(); | |
167 | for (; iter != value_by_shards.end(); ++iter) { | |
168 | if (out->length()) { | |
169 | // Not the first item, append a separator first | |
170 | out->append(SHARDS_SEPARATOR); | |
171 | } | |
172 | char buf[16]; | |
173 | snprintf(buf, sizeof(buf), "%d", iter->first); | |
174 | out->append(buf); | |
175 | out->append(KEY_VALUE_SEPARATOR); | |
176 | out->append(iter->second); | |
177 | } | |
178 | } | |
179 | ||
180 | static bool is_shards_marker(const string& marker) { | |
181 | return marker.find(KEY_VALUE_SEPARATOR) != string::npos; | |
182 | } | |
183 | ||
184 | /* | |
185 | * convert from string. There are two options of how the string looks like: | |
186 | * | |
187 | * 1. Single shard, no shard id specified, e.g. 000001.23.1 | |
188 | * | |
189 | * for this case, if passed shard_id >= 0, use this shard id, otherwise assume that it's a | |
190 | * bucket with no shards. | |
191 | * | |
192 | * 2. One or more shards, shard id specified for each shard, e.g., 0#00002.12,1#00003.23.2 | |
193 | * | |
194 | */ | |
195 | int from_string(const string& composed_marker, int shard_id) { | |
196 | value_by_shards.clear(); | |
197 | vector<string> shards; | |
198 | get_str_vec(composed_marker, SHARDS_SEPARATOR.c_str(), shards); | |
199 | if (shards.size() > 1 && shard_id >= 0) { | |
200 | return -EINVAL; | |
201 | } | |
202 | vector<string>::const_iterator iter = shards.begin(); | |
203 | for (; iter != shards.end(); ++iter) { | |
204 | size_t pos = iter->find(KEY_VALUE_SEPARATOR); | |
205 | if (pos == string::npos) { | |
206 | if (!value_by_shards.empty()) { | |
207 | return -EINVAL; | |
208 | } | |
209 | if (shard_id < 0) { | |
210 | add(0, *iter); | |
211 | } else { | |
212 | add(shard_id, *iter); | |
213 | } | |
214 | return 0; | |
215 | } | |
216 | string shard_str = iter->substr(0, pos); | |
217 | string err; | |
218 | int shard = (int)strict_strtol(shard_str.c_str(), 10, &err); | |
219 | if (!err.empty()) { | |
220 | return -EINVAL; | |
221 | } | |
222 | add(shard, iter->substr(pos + 1)); | |
223 | } | |
224 | return 0; | |
225 | } | |
b32b8144 FG |
226 | |
227 | // trim the '<shard-id>#' prefix from a single shard marker if present | |
228 | static std::string get_shard_marker(const std::string& marker) { | |
229 | auto p = marker.find(KEY_VALUE_SEPARATOR); | |
230 | if (p == marker.npos) { | |
231 | return marker; | |
232 | } | |
233 | return marker.substr(p + 1); | |
234 | } | |
7c673cae FG |
235 | }; |
236 | ||
237 | /* bucket index */ | |
f64942e4 | 238 | void cls_rgw_bucket_init_index(librados::ObjectWriteOperation& o); |
7c673cae FG |
239 | |
240 | class CLSRGWConcurrentIO { | |
241 | protected: | |
242 | librados::IoCtx& io_ctx; | |
243 | map<int, string>& objs_container; | |
244 | map<int, string>::iterator iter; | |
245 | uint32_t max_aio; | |
246 | BucketIndexAioManager manager; | |
247 | ||
248 | virtual int issue_op(int shard_id, const string& oid) = 0; | |
249 | ||
250 | virtual void cleanup() {} | |
251 | virtual int valid_ret_code() { return 0; } | |
252 | // Return true if multiple rounds of OPs might be needed, this happens when | |
253 | // OP needs to be re-send until a certain code is returned. | |
254 | virtual bool need_multiple_rounds() { return false; } | |
255 | // Add a new object to the end of the container. | |
256 | virtual void add_object(int shard, const string& oid) {} | |
257 | virtual void reset_container(map<int, string>& objs) {} | |
258 | ||
259 | public: | |
f64942e4 AA |
260 | |
261 | CLSRGWConcurrentIO(librados::IoCtx& ioc, | |
262 | map<int, string>& _objs_container, | |
263 | uint32_t _max_aio) : | |
264 | io_ctx(ioc), objs_container(_objs_container), max_aio(_max_aio) | |
265 | {} | |
266 | ||
267 | virtual ~CLSRGWConcurrentIO() | |
268 | {} | |
7c673cae FG |
269 | |
270 | int operator()() { | |
271 | int ret = 0; | |
272 | iter = objs_container.begin(); | |
273 | for (; iter != objs_container.end() && max_aio-- > 0; ++iter) { | |
274 | ret = issue_op(iter->first, iter->second); | |
275 | if (ret < 0) | |
276 | break; | |
277 | } | |
278 | ||
494da23a | 279 | int num_completions = 0, r = 0; |
7c673cae FG |
280 | map<int, string> objs; |
281 | map<int, string> *pobjs = (need_multiple_rounds() ? &objs : NULL); | |
282 | while (manager.wait_for_completions(valid_ret_code(), &num_completions, &r, pobjs)) { | |
283 | if (r >= 0 && ret >= 0) { | |
494da23a | 284 | for (; num_completions && iter != objs_container.end(); --num_completions, ++iter) { |
7c673cae | 285 | int issue_ret = issue_op(iter->first, iter->second); |
494da23a | 286 | if (issue_ret < 0) { |
7c673cae FG |
287 | ret = issue_ret; |
288 | break; | |
289 | } | |
290 | } | |
291 | } else if (ret >= 0) { | |
292 | ret = r; | |
293 | } | |
294 | if (need_multiple_rounds() && iter == objs_container.end() && !objs.empty()) { | |
295 | // For those objects which need another round, use them to reset | |
296 | // the container | |
297 | reset_container(objs); | |
494da23a TL |
298 | iter = objs_container.begin(); |
299 | for (; num_completions && iter != objs_container.end(); --num_completions, ++iter) { | |
300 | int issue_ret = issue_op(iter->first, iter->second); | |
301 | if (issue_ret < 0) { | |
302 | ret = issue_ret; | |
303 | break; | |
304 | } | |
305 | } | |
7c673cae FG |
306 | } |
307 | } | |
308 | ||
309 | if (ret < 0) { | |
310 | cleanup(); | |
311 | } | |
312 | return ret; | |
313 | } | |
314 | }; | |
315 | ||
316 | class CLSRGWIssueBucketIndexInit : public CLSRGWConcurrentIO { | |
317 | protected: | |
318 | int issue_op(int shard_id, const string& oid) override; | |
319 | int valid_ret_code() override { return -EEXIST; } | |
320 | void cleanup() override; | |
321 | public: | |
322 | CLSRGWIssueBucketIndexInit(librados::IoCtx& ioc, map<int, string>& _bucket_objs, | |
323 | uint32_t _max_aio) : | |
324 | CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio) {} | |
325 | }; | |
326 | ||
f64942e4 AA |
327 | |
328 | class CLSRGWIssueBucketIndexClean : public CLSRGWConcurrentIO { | |
329 | protected: | |
330 | int issue_op(int shard_id, const string& oid) override; | |
331 | int valid_ret_code() override { | |
332 | return -ENOENT; | |
333 | } | |
334 | ||
335 | public: | |
336 | CLSRGWIssueBucketIndexClean(librados::IoCtx& ioc, | |
337 | map<int, string>& _bucket_objs, | |
338 | uint32_t _max_aio) : | |
339 | CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio) | |
340 | {} | |
341 | }; | |
342 | ||
343 | ||
7c673cae FG |
344 | class CLSRGWIssueSetTagTimeout : public CLSRGWConcurrentIO { |
345 | uint64_t tag_timeout; | |
346 | protected: | |
347 | int issue_op(int shard_id, const string& oid) override; | |
348 | public: | |
349 | CLSRGWIssueSetTagTimeout(librados::IoCtx& ioc, map<int, string>& _bucket_objs, | |
350 | uint32_t _max_aio, uint64_t _tag_timeout) : | |
351 | CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), tag_timeout(_tag_timeout) {} | |
352 | }; | |
353 | ||
11fdf7f2 TL |
354 | void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, |
355 | bool absolute, | |
356 | const map<RGWObjCategory, rgw_bucket_category_stats>& stats); | |
7c673cae FG |
357 | |
358 | void cls_rgw_bucket_prepare_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag, | |
359 | const cls_rgw_obj_key& key, const string& locator, bool log_op, | |
31f18b77 | 360 | uint16_t bilog_op, rgw_zone_set& zones_trace); |
7c673cae FG |
361 | |
362 | void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag, | |
363 | rgw_bucket_entry_ver& ver, | |
364 | const cls_rgw_obj_key& key, | |
365 | rgw_bucket_dir_entry_meta& dir_meta, | |
366 | list<cls_rgw_obj_key> *remove_objs, bool log_op, | |
31f18b77 | 367 | uint16_t bilog_op, rgw_zone_set *zones_trace); |
7c673cae FG |
368 | |
369 | void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_attr_prefixes); | |
370 | void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr); | |
371 | void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist); | |
372 | void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const ceph::real_time& mtime, bool high_precision_time, RGWCheckMTimeType type); | |
373 | ||
374 | int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid, | |
375 | BIIndexType index_type, cls_rgw_obj_key& key, | |
376 | rgw_cls_bi_entry *entry); | |
377 | int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, rgw_cls_bi_entry& entry); | |
378 | void cls_rgw_bi_put(librados::ObjectWriteOperation& op, const string oid, rgw_cls_bi_entry& entry); | |
379 | int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid, | |
380 | const string& name, const string& marker, uint32_t max, | |
381 | list<rgw_cls_bi_entry> *entries, bool *is_truncated); | |
382 | ||
383 | ||
31f18b77 FG |
384 | int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, |
385 | const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag, | |
11fdf7f2 | 386 | bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta, |
31f18b77 FG |
387 | uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace); |
388 | int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, | |
389 | const string& oid, const cls_rgw_obj_key& key, const string& op_tag, | |
390 | const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace); | |
7c673cae FG |
391 | int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, |
392 | const string& olh_tag, | |
11fdf7f2 | 393 | map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated); |
7c673cae | 394 | void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const string& olh_tag); |
31f18b77 | 395 | int cls_rgw_clear_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag); |
7c673cae FG |
396 | |
397 | /** | |
398 | * List the bucket with the starting object and filter prefix. | |
399 | * NOTE: this method do listing requests for each bucket index shards identified by | |
400 | * the keys of the *list_results* map, which means the map should be popludated | |
401 | * by the caller to fill with each bucket index object id. | |
402 | * | |
403 | * io_ctx - IO context for rados. | |
404 | * start_obj - marker for the listing. | |
405 | * filter_prefix - filter prefix. | |
406 | * num_entries - number of entries to request for each object (note the total | |
407 | * amount of entries returned depends on the number of shardings). | |
408 | * list_results - the list results keyed by bucket index object id. | |
409 | * max_aio - the maximum number of AIO (for throttling). | |
410 | * | |
411 | * Return 0 on success, a failure code otherwise. | |
412 | */ | |
413 | ||
414 | class CLSRGWIssueBucketList : public CLSRGWConcurrentIO { | |
415 | cls_rgw_obj_key start_obj; | |
416 | string filter_prefix; | |
417 | uint32_t num_entries; | |
418 | bool list_versions; | |
419 | map<int, rgw_cls_list_ret>& result; | |
420 | protected: | |
421 | int issue_op(int shard_id, const string& oid) override; | |
422 | public: | |
423 | CLSRGWIssueBucketList(librados::IoCtx& io_ctx, const cls_rgw_obj_key& _start_obj, | |
424 | const string& _filter_prefix, uint32_t _num_entries, | |
425 | bool _list_versions, | |
426 | map<int, string>& oids, | |
11fdf7f2 | 427 | map<int, rgw_cls_list_ret>& list_results, |
7c673cae FG |
428 | uint32_t max_aio) : |
429 | CLSRGWConcurrentIO(io_ctx, oids, max_aio), | |
430 | start_obj(_start_obj), filter_prefix(_filter_prefix), num_entries(_num_entries), list_versions(_list_versions), result(list_results) {} | |
431 | }; | |
432 | ||
81eedcae TL |
433 | void cls_rgw_bucket_list_op(librados::ObjectReadOperation& op, |
434 | const cls_rgw_obj_key& start_obj, | |
435 | const std::string& filter_prefix, | |
436 | uint32_t num_entries, | |
437 | bool list_versions, | |
438 | rgw_cls_list_ret* result); | |
439 | ||
7c673cae | 440 | class CLSRGWIssueBILogList : public CLSRGWConcurrentIO { |
11fdf7f2 | 441 | map<int, cls_rgw_bi_log_list_ret>& result; |
7c673cae FG |
442 | BucketIndexShardsManager& marker_mgr; |
443 | uint32_t max; | |
444 | protected: | |
445 | int issue_op(int shard_id, const string& oid) override; | |
446 | public: | |
447 | CLSRGWIssueBILogList(librados::IoCtx& io_ctx, BucketIndexShardsManager& _marker_mgr, uint32_t _max, | |
448 | map<int, string>& oids, | |
11fdf7f2 | 449 | map<int, cls_rgw_bi_log_list_ret>& bi_log_lists, uint32_t max_aio) : |
7c673cae FG |
450 | CLSRGWConcurrentIO(io_ctx, oids, max_aio), result(bi_log_lists), |
451 | marker_mgr(_marker_mgr), max(_max) {} | |
452 | }; | |
453 | ||
454 | class CLSRGWIssueBILogTrim : public CLSRGWConcurrentIO { | |
455 | BucketIndexShardsManager& start_marker_mgr; | |
456 | BucketIndexShardsManager& end_marker_mgr; | |
457 | protected: | |
458 | int issue_op(int shard_id, const string& oid) override; | |
459 | // Trim until -ENODATA is returned. | |
460 | int valid_ret_code() override { return -ENODATA; } | |
461 | bool need_multiple_rounds() override { return true; } | |
462 | void add_object(int shard, const string& oid) override { objs_container[shard] = oid; } | |
463 | void reset_container(map<int, string>& objs) override { | |
464 | objs_container.swap(objs); | |
465 | iter = objs_container.begin(); | |
466 | objs.clear(); | |
467 | } | |
468 | public: | |
469 | CLSRGWIssueBILogTrim(librados::IoCtx& io_ctx, BucketIndexShardsManager& _start_marker_mgr, | |
470 | BucketIndexShardsManager& _end_marker_mgr, map<int, string>& _bucket_objs, uint32_t max_aio) : | |
471 | CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio), | |
472 | start_marker_mgr(_start_marker_mgr), end_marker_mgr(_end_marker_mgr) {} | |
473 | }; | |
474 | ||
475 | /** | |
476 | * Check the bucket index. | |
477 | * | |
478 | * io_ctx - IO context for rados. | |
479 | * bucket_objs_ret - check result for all shards. | |
480 | * max_aio - the maximum number of AIO (for throttling). | |
481 | * | |
482 | * Return 0 on success, a failure code otherwise. | |
483 | */ | |
11fdf7f2 TL |
484 | class CLSRGWIssueBucketCheck : public CLSRGWConcurrentIO /*<map<string, rgw_cls_check_index_ret> >*/ { |
485 | map<int, rgw_cls_check_index_ret>& result; | |
7c673cae FG |
486 | protected: |
487 | int issue_op(int shard_id, const string& oid) override; | |
488 | public: | |
11fdf7f2 TL |
489 | CLSRGWIssueBucketCheck(librados::IoCtx& ioc, map<int, string>& oids, |
490 | map<int, rgw_cls_check_index_ret>& bucket_objs_ret, | |
491 | uint32_t _max_aio) : | |
7c673cae FG |
492 | CLSRGWConcurrentIO(ioc, oids, _max_aio), result(bucket_objs_ret) {} |
493 | }; | |
494 | ||
495 | class CLSRGWIssueBucketRebuild : public CLSRGWConcurrentIO { | |
496 | protected: | |
497 | int issue_op(int shard_id, const string& oid) override; | |
498 | public: | |
499 | CLSRGWIssueBucketRebuild(librados::IoCtx& io_ctx, map<int, string>& bucket_objs, | |
500 | uint32_t max_aio) : CLSRGWConcurrentIO(io_ctx, bucket_objs, max_aio) {} | |
501 | }; | |
502 | ||
503 | class CLSRGWIssueGetDirHeader : public CLSRGWConcurrentIO { | |
504 | map<int, rgw_cls_list_ret>& result; | |
505 | protected: | |
506 | int issue_op(int shard_id, const string& oid) override; | |
507 | public: | |
508 | CLSRGWIssueGetDirHeader(librados::IoCtx& io_ctx, map<int, string>& oids, map<int, rgw_cls_list_ret>& dir_headers, | |
509 | uint32_t max_aio) : | |
510 | CLSRGWConcurrentIO(io_ctx, oids, max_aio), result(dir_headers) {} | |
511 | }; | |
512 | ||
31f18b77 FG |
513 | class CLSRGWIssueSetBucketResharding : public CLSRGWConcurrentIO { |
514 | cls_rgw_bucket_instance_entry entry; | |
515 | protected: | |
516 | int issue_op(int shard_id, const string& oid) override; | |
517 | public: | |
518 | CLSRGWIssueSetBucketResharding(librados::IoCtx& ioc, map<int, string>& _bucket_objs, | |
519 | const cls_rgw_bucket_instance_entry& _entry, | |
520 | uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), entry(_entry) {} | |
521 | }; | |
522 | ||
c07f9fc5 FG |
523 | class CLSRGWIssueResyncBucketBILog : public CLSRGWConcurrentIO { |
524 | protected: | |
525 | int issue_op(int shard_id, const string& oid); | |
526 | public: | |
527 | CLSRGWIssueResyncBucketBILog(librados::IoCtx& io_ctx, map<int, string>& _bucket_objs, uint32_t max_aio) : | |
528 | CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio) {} | |
529 | }; | |
530 | ||
531 | class CLSRGWIssueBucketBILogStop : public CLSRGWConcurrentIO { | |
532 | protected: | |
533 | int issue_op(int shard_id, const string& oid); | |
534 | public: | |
535 | CLSRGWIssueBucketBILogStop(librados::IoCtx& io_ctx, map<int, string>& _bucket_objs, uint32_t max_aio) : | |
536 | CLSRGWConcurrentIO(io_ctx, _bucket_objs, max_aio) {} | |
537 | }; | |
538 | ||
7c673cae FG |
539 | int cls_rgw_get_dir_header_async(librados::IoCtx& io_ctx, string& oid, RGWGetDirHeader_CB *ctx); |
540 | ||
541 | void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates); | |
542 | ||
543 | void cls_rgw_suggest_changes(librados::ObjectWriteOperation& o, bufferlist& updates); | |
544 | ||
545 | /* usage logging */ | |
11fdf7f2 TL |
546 | int cls_rgw_usage_log_read(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket, |
547 | uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, string& read_iter, | |
548 | map<rgw_user_bucket, rgw_usage_log_entry>& usage, bool *is_truncated); | |
7c673cae | 549 | |
11fdf7f2 | 550 | int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket, |
7c673cae FG |
551 | uint64_t start_epoch, uint64_t end_epoch); |
552 | ||
11fdf7f2 | 553 | void cls_rgw_usage_log_clear(librados::ObjectWriteOperation& op); |
7c673cae FG |
554 | void cls_rgw_usage_log_add(librados::ObjectWriteOperation& op, rgw_usage_log_info& info); |
555 | ||
556 | /* garbage collection */ | |
557 | void cls_rgw_gc_set_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, cls_rgw_gc_obj_info& info); | |
558 | void cls_rgw_gc_defer_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const string& tag); | |
559 | ||
560 | int cls_rgw_gc_list(librados::IoCtx& io_ctx, string& oid, string& marker, uint32_t max, bool expired_only, | |
31f18b77 | 561 | list<cls_rgw_gc_obj_info>& entries, bool *truncated, string& next_marker); |
7c673cae | 562 | |
11fdf7f2 | 563 | void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector<string>& tags); |
7c673cae FG |
564 | |
565 | /* lifecycle */ | |
11fdf7f2 TL |
566 | int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head); |
567 | int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head); | |
568 | int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const string& oid, string& marker, pair<string, int>& entry); | |
569 | int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const string& oid, const pair<string, int>& entry); | |
570 | int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const string& oid, const pair<string, int>& entry); | |
571 | int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const string& oid, const std::string& marker, rgw_lc_entry_t& entry); | |
572 | int cls_rgw_lc_list(librados::IoCtx& io_ctx, const string& oid, | |
7c673cae FG |
573 | const string& marker, |
574 | uint32_t max_entries, | |
575 | map<string, int>& entries); | |
576 | ||
31f18b77 FG |
577 | /* resharding */ |
578 | void cls_rgw_reshard_add(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry); | |
579 | int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& marker, uint32_t max, | |
580 | list<cls_rgw_reshard_entry>& entries, bool* is_truncated); | |
581 | int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry); | |
582 | int cls_rgw_reshard_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry); | |
583 | void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry); | |
584 | ||
f64942e4 | 585 | /* resharding attribute on bucket index shard headers */ |
31f18b77 FG |
586 | int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid, |
587 | const cls_rgw_bucket_instance_entry& entry); | |
588 | int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid); | |
589 | void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err); | |
590 | int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid, | |
591 | cls_rgw_bucket_instance_entry *entry); | |
7c673cae FG |
592 | |
593 | #endif |