]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/services/svc_sys_obj_cache.cc
import ceph 16.2.6
[ceph.git] / ceph / src / rgw / services / svc_sys_obj_cache.cc
CommitLineData
9f95a23c
TL
1
2// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
3// vim: ts=8 sw=2 smarttab ft=cpp
4
5#include "common/admin_socket.h"
6
11fdf7f2
TL
7#include "svc_sys_obj_cache.h"
8#include "svc_zone.h"
9#include "svc_notify.h"
10
11#include "rgw/rgw_zone.h"
12#include "rgw/rgw_tools.h"
13
14#define dout_subsys ceph_subsys_rgw
15
16class RGWSI_SysObj_Cache_CB : public RGWSI_Notify::CB
17{
18 RGWSI_SysObj_Cache *svc;
19public:
20 RGWSI_SysObj_Cache_CB(RGWSI_SysObj_Cache *_svc) : svc(_svc) {}
b3b6e05e
TL
21 int watch_cb(const DoutPrefixProvider *dpp,
22 uint64_t notify_id,
11fdf7f2
TL
23 uint64_t cookie,
24 uint64_t notifier_id,
25 bufferlist& bl) {
b3b6e05e 26 return svc->watch_cb(dpp, notify_id, cookie, notifier_id, bl);
11fdf7f2
TL
27 }
28
29 void set_enabled(bool status) {
30 svc->set_enabled(status);
31 }
32};
33
b3b6e05e 34int RGWSI_SysObj_Cache::do_start(optional_yield y, const DoutPrefixProvider *dpp)
11fdf7f2 35{
9f95a23c
TL
36 int r = asocket.start();
37 if (r < 0) {
38 return r;
39 }
40
b3b6e05e 41 r = RGWSI_SysObj_Core::do_start(y, dpp);
11fdf7f2
TL
42 if (r < 0) {
43 return r;
44 }
45
b3b6e05e 46 r = notify_svc->start(y, dpp);
11fdf7f2
TL
47 if (r < 0) {
48 return r;
49 }
50
51 assert(notify_svc->is_started());
52
53 cb.reset(new RGWSI_SysObj_Cache_CB(this));
54
55 notify_svc->register_watch_cb(cb.get());
56
57 return 0;
58}
59
9f95a23c
TL
60void RGWSI_SysObj_Cache::shutdown()
61{
62 asocket.shutdown();
63 RGWSI_SysObj_Core::shutdown();
64}
65
11fdf7f2
TL
66static string normal_name(rgw_pool& pool, const std::string& oid) {
67 std::string buf;
68 buf.reserve(pool.name.size() + pool.ns.size() + oid.size() + 2);
69 buf.append(pool.name).append("+").append(pool.ns).append("+").append(oid);
70 return buf;
71}
72
73void RGWSI_SysObj_Cache::normalize_pool_and_obj(const rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj)
74{
75 if (src_obj.size()) {
76 dst_pool = src_pool;
77 dst_obj = src_obj;
78 } else {
79 dst_pool = zone_svc->get_zone_params().domain_root;
80 dst_obj = src_pool.name;
81 }
82}
83
84
b3b6e05e
TL
85int RGWSI_SysObj_Cache::remove(const DoutPrefixProvider *dpp,
86 RGWSysObjectCtxBase& obj_ctx,
11fdf7f2 87 RGWObjVersionTracker *objv_tracker,
9f95a23c
TL
88 const rgw_raw_obj& obj,
89 optional_yield y)
11fdf7f2
TL
90
91{
92 rgw_pool pool;
93 string oid;
94 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
95
96 string name = normal_name(pool, oid);
b3b6e05e 97 cache.remove(dpp, name);
11fdf7f2
TL
98
99 ObjectCacheInfo info;
b3b6e05e 100 int r = distribute_cache(dpp, name, obj, info, REMOVE_OBJ, y);
11fdf7f2 101 if (r < 0) {
b3b6e05e 102 ldpp_dout(dpp, 0) << "ERROR: " << __func__ << "(): failed to distribute cache: r=" << r << dendl;
11fdf7f2
TL
103 }
104
b3b6e05e 105 return RGWSI_SysObj_Core::remove(dpp, obj_ctx, objv_tracker, obj, y);
11fdf7f2
TL
106}
107
b3b6e05e
TL
108int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
109 RGWSysObjectCtxBase& obj_ctx,
9f95a23c 110 RGWSI_SysObj_Obj_GetObjState& read_state,
11fdf7f2
TL
111 RGWObjVersionTracker *objv_tracker,
112 const rgw_raw_obj& obj,
113 bufferlist *obl, off_t ofs, off_t end,
114 map<string, bufferlist> *attrs,
115 bool raw_attrs,
116 rgw_cache_entry_info *cache_info,
9f95a23c
TL
117 boost::optional<obj_version> refresh_version,
118 optional_yield y)
11fdf7f2
TL
119{
120 rgw_pool pool;
121 string oid;
122 if (ofs != 0) {
b3b6e05e 123 return RGWSI_SysObj_Core::read(dpp, obj_ctx, read_state, objv_tracker,
9f95a23c
TL
124 obj, obl, ofs, end, attrs, raw_attrs,
125 cache_info, refresh_version, y);
11fdf7f2
TL
126 }
127
128 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
129 string name = normal_name(pool, oid);
130
131 ObjectCacheInfo info;
132
133 uint32_t flags = (end != 0 ? CACHE_FLAG_DATA : 0);
134 if (objv_tracker)
135 flags |= CACHE_FLAG_OBJV;
136 if (attrs)
137 flags |= CACHE_FLAG_XATTRS;
f6b5b4d7 138
b3b6e05e 139 int r = cache.get(dpp, name, info, flags, cache_info);
f6b5b4d7 140 if (r == 0 &&
11fdf7f2
TL
141 (!refresh_version || !info.version.compare(&(*refresh_version)))) {
142 if (info.status < 0)
143 return info.status;
144
145 bufferlist& bl = info.data;
146
147 bufferlist::iterator i = bl.begin();
148
149 obl->clear();
150
151 i.copy_all(*obl);
152 if (objv_tracker)
153 objv_tracker->read_version = info.version;
154 if (attrs) {
155 if (raw_attrs) {
156 *attrs = info.xattrs;
157 } else {
158 rgw_filter_attrset(info.xattrs, RGW_ATTR_PREFIX, attrs);
159 }
160 }
161 return obl->length();
162 }
f6b5b4d7
TL
163 if(r == -ENODATA)
164 return -ENOENT;
11fdf7f2
TL
165
166 map<string, bufferlist> unfiltered_attrset;
b3b6e05e 167 r = RGWSI_SysObj_Core::read(dpp, obj_ctx, read_state, objv_tracker,
11fdf7f2
TL
168 obj, obl, ofs, end,
169 (attrs ? &unfiltered_attrset : nullptr),
170 true, /* cache unfiltered attrs */
171 cache_info,
9f95a23c 172 refresh_version, y);
11fdf7f2
TL
173 if (r < 0) {
174 if (r == -ENOENT) { // only update ENOENT, we'd rather retry other errors
175 info.status = r;
b3b6e05e 176 cache.put(dpp, name, info, cache_info);
11fdf7f2
TL
177 }
178 return r;
179 }
180
181 if (obl->length() == end + 1) {
182 /* in this case, most likely object contains more data, we can't cache it */
183 flags &= ~CACHE_FLAG_DATA;
184 } else {
185 bufferptr p(r);
186 bufferlist& bl = info.data;
187 bl.clear();
188 bufferlist::iterator o = obl->begin();
189 o.copy_all(bl);
190 }
191
192 info.status = 0;
193 info.flags = flags;
194 if (objv_tracker) {
195 info.version = objv_tracker->read_version;
196 }
197 if (attrs) {
198 info.xattrs = std::move(unfiltered_attrset);
199 if (raw_attrs) {
200 *attrs = info.xattrs;
201 } else {
202 rgw_filter_attrset(info.xattrs, RGW_ATTR_PREFIX, attrs);
203 }
204 }
b3b6e05e 205 cache.put(dpp, name, info, cache_info);
11fdf7f2
TL
206 return r;
207}
208
b3b6e05e
TL
209int RGWSI_SysObj_Cache::get_attr(const DoutPrefixProvider *dpp,
210 const rgw_raw_obj& obj,
9f95a23c
TL
211 const char *attr_name,
212 bufferlist *dest,
213 optional_yield y)
11fdf7f2
TL
214{
215 rgw_pool pool;
216 string oid;
217
218 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
219 string name = normal_name(pool, oid);
220
221 ObjectCacheInfo info;
222
223 uint32_t flags = CACHE_FLAG_XATTRS;
224
b3b6e05e 225 int r = cache.get(dpp, name, info, flags, nullptr);
f6b5b4d7 226 if (r == 0) {
11fdf7f2
TL
227 if (info.status < 0)
228 return info.status;
229
230 auto iter = info.xattrs.find(attr_name);
231 if (iter == info.xattrs.end()) {
232 return -ENODATA;
233 }
234
235 *dest = iter->second;
236 return dest->length();
f6b5b4d7
TL
237 } else if (r == -ENODATA) {
238 return -ENOENT;
11fdf7f2
TL
239 }
240 /* don't try to cache this one */
b3b6e05e 241 return RGWSI_SysObj_Core::get_attr(dpp, obj, attr_name, dest, y);
11fdf7f2
TL
242}
243
b3b6e05e
TL
244int RGWSI_SysObj_Cache::set_attrs(const DoutPrefixProvider *dpp,
245 const rgw_raw_obj& obj,
11fdf7f2
TL
246 map<string, bufferlist>& attrs,
247 map<string, bufferlist> *rmattrs,
9f95a23c
TL
248 RGWObjVersionTracker *objv_tracker,
249 optional_yield y)
11fdf7f2
TL
250{
251 rgw_pool pool;
252 string oid;
253 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
254 ObjectCacheInfo info;
255 info.xattrs = attrs;
256 if (rmattrs) {
257 info.rm_xattrs = *rmattrs;
258 }
259 info.status = 0;
260 info.flags = CACHE_FLAG_MODIFY_XATTRS;
b3b6e05e 261 int ret = RGWSI_SysObj_Core::set_attrs(dpp, obj, attrs, rmattrs, objv_tracker, y);
11fdf7f2
TL
262 string name = normal_name(pool, oid);
263 if (ret >= 0) {
f91f0fd5
TL
264 if (objv_tracker && objv_tracker->read_version.ver) {
265 info.version = objv_tracker->read_version;
266 info.flags |= CACHE_FLAG_OBJV;
267 }
b3b6e05e
TL
268 cache.put(dpp, name, info, NULL);
269 int r = distribute_cache(dpp, name, obj, info, UPDATE_OBJ, y);
11fdf7f2 270 if (r < 0)
b3b6e05e 271 ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
11fdf7f2 272 } else {
b3b6e05e 273 cache.remove(dpp, name);
11fdf7f2
TL
274 }
275
276 return ret;
277}
278
b3b6e05e
TL
279int RGWSI_SysObj_Cache::write(const DoutPrefixProvider *dpp,
280 const rgw_raw_obj& obj,
11fdf7f2
TL
281 real_time *pmtime,
282 map<std::string, bufferlist>& attrs,
283 bool exclusive,
284 const bufferlist& data,
285 RGWObjVersionTracker *objv_tracker,
9f95a23c
TL
286 real_time set_mtime,
287 optional_yield y)
11fdf7f2
TL
288{
289 rgw_pool pool;
290 string oid;
291 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
292 ObjectCacheInfo info;
293 info.xattrs = attrs;
294 info.status = 0;
295 info.data = data;
296 info.flags = CACHE_FLAG_XATTRS | CACHE_FLAG_DATA | CACHE_FLAG_META;
11fdf7f2 297 ceph::real_time result_mtime;
b3b6e05e 298 int ret = RGWSI_SysObj_Core::write(dpp, obj, &result_mtime, attrs,
9f95a23c
TL
299 exclusive, data,
300 objv_tracker, set_mtime, y);
11fdf7f2
TL
301 if (pmtime) {
302 *pmtime = result_mtime;
303 }
f91f0fd5
TL
304 if (objv_tracker && objv_tracker->read_version.ver) {
305 info.version = objv_tracker->read_version;
306 info.flags |= CACHE_FLAG_OBJV;
307 }
11fdf7f2
TL
308 info.meta.mtime = result_mtime;
309 info.meta.size = data.length();
310 string name = normal_name(pool, oid);
311 if (ret >= 0) {
b3b6e05e
TL
312 cache.put(dpp, name, info, NULL);
313 int r = distribute_cache(dpp, name, obj, info, UPDATE_OBJ, y);
adb31ebb 314 if (r < 0)
b3b6e05e 315 ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
11fdf7f2 316 } else {
b3b6e05e 317 cache.remove(dpp, name);
11fdf7f2
TL
318 }
319
320 return ret;
321}
322
b3b6e05e
TL
323int RGWSI_SysObj_Cache::write_data(const DoutPrefixProvider *dpp,
324 const rgw_raw_obj& obj,
11fdf7f2
TL
325 const bufferlist& data,
326 bool exclusive,
9f95a23c
TL
327 RGWObjVersionTracker *objv_tracker,
328 optional_yield y)
11fdf7f2
TL
329{
330 rgw_pool pool;
331 string oid;
332 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
333
334 ObjectCacheInfo info;
335 info.data = data;
336 info.meta.size = data.length();
337 info.status = 0;
338 info.flags = CACHE_FLAG_DATA;
339
b3b6e05e 340 int ret = RGWSI_SysObj_Core::write_data(dpp, obj, data, exclusive, objv_tracker, y);
11fdf7f2
TL
341 string name = normal_name(pool, oid);
342 if (ret >= 0) {
f91f0fd5
TL
343 if (objv_tracker && objv_tracker->read_version.ver) {
344 info.version = objv_tracker->read_version;
345 info.flags |= CACHE_FLAG_OBJV;
346 }
b3b6e05e
TL
347 cache.put(dpp, name, info, NULL);
348 int r = distribute_cache(dpp, name, obj, info, UPDATE_OBJ, y);
11fdf7f2 349 if (r < 0)
b3b6e05e 350 ldpp_dout(dpp, 0) << "ERROR: failed to distribute cache for " << obj << dendl;
11fdf7f2 351 } else {
b3b6e05e 352 cache.remove(dpp, name);
11fdf7f2
TL
353 }
354
355 return ret;
356}
357
b3b6e05e 358int RGWSI_SysObj_Cache::raw_stat(const DoutPrefixProvider *dpp, const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *pepoch,
11fdf7f2 359 map<string, bufferlist> *attrs, bufferlist *first_chunk,
9f95a23c
TL
360 RGWObjVersionTracker *objv_tracker,
361 optional_yield y)
11fdf7f2
TL
362{
363 rgw_pool pool;
364 string oid;
365 normalize_pool_and_obj(obj.pool, obj.oid, pool, oid);
366
367 string name = normal_name(pool, oid);
368
369 uint64_t size;
370 real_time mtime;
371 uint64_t epoch;
372
373 ObjectCacheInfo info;
374 uint32_t flags = CACHE_FLAG_META | CACHE_FLAG_XATTRS;
375 if (objv_tracker)
376 flags |= CACHE_FLAG_OBJV;
b3b6e05e 377 int r = cache.get(dpp, name, info, flags, NULL);
11fdf7f2
TL
378 if (r == 0) {
379 if (info.status < 0)
380 return info.status;
381
382 size = info.meta.size;
383 mtime = info.meta.mtime;
384 epoch = info.epoch;
385 if (objv_tracker)
386 objv_tracker->read_version = info.version;
387 goto done;
388 }
f6b5b4d7
TL
389 if (r == -ENODATA) {
390 return -ENOENT;
391 }
b3b6e05e 392 r = RGWSI_SysObj_Core::raw_stat(dpp, obj, &size, &mtime, &epoch, &info.xattrs,
9f95a23c 393 first_chunk, objv_tracker, y);
11fdf7f2
TL
394 if (r < 0) {
395 if (r == -ENOENT) {
396 info.status = r;
b3b6e05e 397 cache.put(dpp, name, info, NULL);
11fdf7f2
TL
398 }
399 return r;
400 }
401 info.status = 0;
402 info.epoch = epoch;
403 info.meta.mtime = mtime;
404 info.meta.size = size;
405 info.flags = CACHE_FLAG_META | CACHE_FLAG_XATTRS;
406 if (objv_tracker) {
407 info.flags |= CACHE_FLAG_OBJV;
408 info.version = objv_tracker->read_version;
409 }
b3b6e05e 410 cache.put(dpp, name, info, NULL);
11fdf7f2
TL
411done:
412 if (psize)
413 *psize = size;
414 if (pmtime)
415 *pmtime = mtime;
416 if (pepoch)
417 *pepoch = epoch;
418 if (attrs)
419 *attrs = info.xattrs;
420 return 0;
421}
422
b3b6e05e
TL
423int RGWSI_SysObj_Cache::distribute_cache(const DoutPrefixProvider *dpp,
424 const string& normal_name,
9f95a23c
TL
425 const rgw_raw_obj& obj,
426 ObjectCacheInfo& obj_info, int op,
427 optional_yield y)
11fdf7f2
TL
428{
429 RGWCacheNotifyInfo info;
11fdf7f2 430 info.op = op;
11fdf7f2
TL
431 info.obj_info = obj_info;
432 info.obj = obj;
522d829b 433 return notify_svc->distribute(dpp, normal_name, info, y);
11fdf7f2
TL
434}
435
b3b6e05e
TL
436int RGWSI_SysObj_Cache::watch_cb(const DoutPrefixProvider *dpp,
437 uint64_t notify_id,
11fdf7f2
TL
438 uint64_t cookie,
439 uint64_t notifier_id,
440 bufferlist& bl)
441{
442 RGWCacheNotifyInfo info;
443
444 try {
445 auto iter = bl.cbegin();
446 decode(info, iter);
447 } catch (buffer::end_of_buffer& err) {
448 ldout(cct, 0) << "ERROR: got bad notification" << dendl;
449 return -EIO;
450 } catch (buffer::error& err) {
451 ldout(cct, 0) << "ERROR: buffer::error" << dendl;
452 return -EIO;
453 }
454
455 rgw_pool pool;
456 string oid;
457 normalize_pool_and_obj(info.obj.pool, info.obj.oid, pool, oid);
458 string name = normal_name(pool, oid);
459
460 switch (info.op) {
461 case UPDATE_OBJ:
b3b6e05e 462 cache.put(dpp, name, info.obj_info, NULL);
11fdf7f2
TL
463 break;
464 case REMOVE_OBJ:
b3b6e05e 465 cache.remove(dpp, name);
11fdf7f2
TL
466 break;
467 default:
468 ldout(cct, 0) << "WARNING: got unknown notification op: " << info.op << dendl;
469 return -EINVAL;
470 }
471
472 return 0;
473}
474
475void RGWSI_SysObj_Cache::set_enabled(bool status)
476{
477 cache.set_enabled(status);
478}
479
b3b6e05e
TL
480bool RGWSI_SysObj_Cache::chain_cache_entry(const DoutPrefixProvider *dpp,
481 std::initializer_list<rgw_cache_entry_info *> cache_info_entries,
11fdf7f2
TL
482 RGWChainedCache::Entry *chained_entry)
483{
b3b6e05e 484 return cache.chain_cache_entry(dpp, cache_info_entries, chained_entry);
11fdf7f2
TL
485}
486
487void RGWSI_SysObj_Cache::register_chained_cache(RGWChainedCache *cc)
488{
489 cache.chain_cache(cc);
490}
491
492void RGWSI_SysObj_Cache::unregister_chained_cache(RGWChainedCache *cc)
493{
494 cache.unchain_cache(cc);
495}
496
497static void cache_list_dump_helper(Formatter* f,
498 const std::string& name,
499 const ceph::real_time mtime,
500 const std::uint64_t size)
501{
502 f->dump_string("name", name);
503 f->dump_string("mtime", ceph::to_iso_8601(mtime));
504 f->dump_unsigned("size", size);
505}
506
9f95a23c
TL
507class RGWSI_SysObj_Cache_ASocketHook : public AdminSocketHook {
508 RGWSI_SysObj_Cache *svc;
509
f67539c2
TL
510 static constexpr std::string_view admin_commands[][2] = {
511 { "cache list name=filter,type=CephString,req=false",
9f95a23c
TL
512 "cache list [filter_str]: list object cache, possibly matching substrings" },
513 { "cache inspect name=target,type=CephString,req=true",
514 "cache inspect target: print cache element" },
515 { "cache erase name=target,type=CephString,req=true",
516 "cache erase target: erase element from cache" },
517 { "cache zap",
518 "cache zap: erase all elements from cache" }
519 };
520
521public:
522 RGWSI_SysObj_Cache_ASocketHook(RGWSI_SysObj_Cache *_svc) : svc(_svc) {}
523
524 int start();
525 void shutdown();
526
527 int call(std::string_view command, const cmdmap_t& cmdmap,
528 Formatter *f,
529 std::ostream& ss,
530 bufferlist& out) override;
531};
532
533int RGWSI_SysObj_Cache_ASocketHook::start()
534{
535 auto admin_socket = svc->ctx()->get_admin_socket();
536 for (auto cmd : admin_commands) {
537 int r = admin_socket->register_command(cmd[0], this, cmd[1]);
538 if (r < 0) {
539 ldout(svc->ctx(), 0) << "ERROR: fail to register admin socket command (r=" << r
540 << ")" << dendl;
541 return r;
542 }
543 }
544 return 0;
545}
546
547void RGWSI_SysObj_Cache_ASocketHook::shutdown()
548{
549 auto admin_socket = svc->ctx()->get_admin_socket();
550 admin_socket->unregister_commands(this);
551}
552
553int RGWSI_SysObj_Cache_ASocketHook::call(
554 std::string_view command, const cmdmap_t& cmdmap,
555 Formatter *f,
556 std::ostream& ss,
557 bufferlist& out)
558{
559 if (command == "cache list"sv) {
560 std::optional<std::string> filter;
561 if (auto i = cmdmap.find("filter"); i != cmdmap.cend()) {
562 filter = boost::get<std::string>(i->second);
563 }
564 f->open_array_section("cache_entries");
565 svc->asocket.call_list(filter, f);
566 f->close_section();
567 return 0;
568 } else if (command == "cache inspect"sv) {
569 const auto& target = boost::get<std::string>(cmdmap.at("target"));
570 if (svc->asocket.call_inspect(target, f)) {
571 return 0;
572 } else {
573 ss << "Unable to find entry "s + target + ".\n";
574 return -ENOENT;
575 }
576 } else if (command == "cache erase"sv) {
577 const auto& target = boost::get<std::string>(cmdmap.at("target"));
578 if (svc->asocket.call_erase(target)) {
579 return 0;
580 } else {
581 ss << "Unable to find entry "s + target + ".\n";
582 return -ENOENT;
583 }
584 } else if (command == "cache zap"sv) {
585 svc->asocket.call_zap();
586 return 0;
587 }
588 return -ENOSYS;
589}
590
b3b6e05e 591RGWSI_SysObj_Cache::ASocketHandler::ASocketHandler(const DoutPrefixProvider *_dpp, RGWSI_SysObj_Cache *_svc) : dpp(_dpp), svc(_svc)
9f95a23c
TL
592{
593 hook.reset(new RGWSI_SysObj_Cache_ASocketHook(_svc));
594}
595
596RGWSI_SysObj_Cache::ASocketHandler::~ASocketHandler()
597{
598}
599
600int RGWSI_SysObj_Cache::ASocketHandler::start()
601{
602 return hook->start();
603}
604
605void RGWSI_SysObj_Cache::ASocketHandler::shutdown()
606{
607 return hook->shutdown();
608}
609
610void RGWSI_SysObj_Cache::ASocketHandler::call_list(const std::optional<std::string>& filter, Formatter* f)
11fdf7f2 611{
9f95a23c
TL
612 svc->cache.for_each(
613 [&filter, f] (const string& name, const ObjectCacheEntry& entry) {
11fdf7f2
TL
614 if (!filter || name.find(*filter) != name.npos) {
615 cache_list_dump_helper(f, name, entry.info.meta.mtime,
616 entry.info.meta.size);
617 }
618 });
619}
620
9f95a23c 621int RGWSI_SysObj_Cache::ASocketHandler::call_inspect(const std::string& target, Formatter* f)
11fdf7f2 622{
b3b6e05e 623 if (const auto entry = svc->cache.get(dpp, target)) {
11fdf7f2
TL
624 f->open_object_section("cache_entry");
625 f->dump_string("name", target.c_str());
626 entry->dump(f);
627 f->close_section();
628 return true;
629 } else {
630 return false;
631 }
632}
633
9f95a23c 634int RGWSI_SysObj_Cache::ASocketHandler::call_erase(const std::string& target)
11fdf7f2 635{
b3b6e05e 636 return svc->cache.remove(dpp, target);
11fdf7f2
TL
637}
638
9f95a23c 639int RGWSI_SysObj_Cache::ASocketHandler::call_zap()
11fdf7f2 640{
9f95a23c 641 svc->cache.invalidate_all();
11fdf7f2
TL
642 return 0;
643}