if (opt_cmd == OPT::GC_LIST) {
int index = 0;
bool truncated;
+ bool processing_queue = false;
formatter->open_array_section("entries");
do {
list<cls_rgw_gc_obj_info> result;
- int ret = store->getRados()->list_gc_objs(&index, marker, 1000, !include_all, result, &truncated);
+ int ret = store->getRados()->list_gc_objs(&index, marker, 1000, !include_all, result, &truncated, processing_queue);
if (ret < 0) {
cerr << "ERROR: failed to list objs: " << cpp_strerror(-ret) << std::endl;
return 1;
return store->gc_operate(obj_names[index], &op);
}
-int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated)
+int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue)
{
result.clear();
string next_marker;
std::list<cls_rgw_gc_obj_info> entries, queue_entries;
int ret = 0;
- if (! transitioned_objects_cache[*index] && ! check_queue) {
+ //processing_queue is set to true from previous iteration if the queue was under process and probably has more elements in it.
+ if (! transitioned_objects_cache[*index] && ! check_queue && ! processing_queue) {
ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[*index], marker, max - result.size(), expired_only, entries, truncated, next_marker);
if (ret != -ENOENT && ret < 0) {
return ret;
marker.clear();
}
}
- if (transitioned_objects_cache[*index] || check_queue) {
+ if (transitioned_objects_cache[*index] || check_queue || processing_queue) {
+ processing_queue = false;
ret = cls_rgw_gc_queue_list_entries(store->gc_pool_ctx, obj_names[*index], marker, (max - result.size()) - entries.size(), expired_only, queue_entries, truncated, next_marker);
if (ret < 0) {
return ret;
}
if (result.size() == max) {
+ if (queue_entries.size() > 0 && *truncated) {
+ processing_queue = true;
+ } else {
+ processing_queue = false;
+ *index += 1; //move to next gc object
+ }
+
/* close approximation, it might be that the next of the objects don't hold
* anything, in this case truncated should have been false, but we can find
* that out on the next iteration
}
}
*truncated = false;
+ processing_queue = false;
return 0;
}
void initialize(CephContext *_cct, RGWRados *_store);
void finalize();
- int list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated);
+ int list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue);
void list_init(int *index) { *index = 0; }
int process(int index, int process_max_secs, bool expired_only,
RGWGCIOManager& io_manager);
return rgw_rados_operate(gc_pool_ctx, oid, op, pbl, null_yield);
}
-int RGWRados::list_gc_objs(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated)
+int RGWRados::list_gc_objs(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue)
{
- return gc->list(index, marker, max, expired_only, result, truncated);
+ return gc->list(index, marker, max, expired_only, result, truncated, processing_queue);
}
int RGWRados::process_gc(bool expired_only)
librados::ObjectWriteOperation *op);
int gc_operate(string& oid, librados::ObjectReadOperation *op, bufferlist *pbl);
- int list_gc_objs(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated);
+ int list_gc_objs(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated, bool& processing_queue);
int process_gc(bool expired_only);
bool process_expire_objects();
int defer_gc(void *ctx, const RGWBucketInfo& bucket_info, const rgw_obj& obj, optional_yield y);