#include "include/scope_guard.h"
#include "include/rados/librados.hpp"
#include "cls/rgw/cls_rgw_client.h"
+#include "cls/queue/cls_queue_client.h"
#include "cls/refcount/cls_refcount_client.h"
#include "rgw_perf_counters.h"
#include "cls/lock/cls_lock_client.h"
snprintf(buf, 32, ".%d", i);
obj_names[i].append(buf);
}
+
+ // Create GC queues
+ for (int i = 0; i < max_objs; i++) {
+ ldpp_dout(this, 20) << "RGWGC::initialize initing gc queue with name = " << obj_names[i] << dendl;
+ librados::ObjectWriteOperation op;
+ op.assert_exists();
+ uint64_t queue_size = 1048576, num_urgent_data_entries = 50;
+ cls_rgw_gc_init_queue(op, obj_names[i], queue_size, num_urgent_data_entries);
+ int ret = store->gc_operate(obj_names[i], &op);
+ if (ret == -ENOENT) {
+ ldpp_dout(this, 20) << "RGWGC::initialize creating gc queue with name = " << obj_names[i] << dendl;
+ cls_rgw_gc_create_queue(op, obj_names[i], queue_size, num_urgent_data_entries);
+ store->gc_operate(obj_names[i], &op);
+ }
+ }
}
void RGWGC::finalize()
info.chain = chain;
info.tag = tag;
- cls_rgw_gc_set_entry(op, cct->_conf->rgw_gc_obj_min_wait, info);
+ //cls_rgw_gc_set_entry(op, cct->_conf->rgw_gc_obj_min_wait, info);
+ cls_rgw_gc_enqueue(op, cct->_conf->rgw_gc_obj_min_wait, info);
}
int RGWGC::send_chain(cls_rgw_obj_chain& chain, const string& tag, bool sync)
int i = tag_index(tag);
+ ldpp_dout(this, 20) << "RGWGC::send_chain - on object name: " << obj_names[i] << "tag is: " << tag << dendl;
if (sync)
return store->gc_operate(obj_names[i], &op);
return store->gc_aio_operate(obj_names[i], &op);
}
-int RGWGC::defer_chain(const string& tag, bool sync)
+int RGWGC::defer_chain(const string& tag, cls_rgw_obj_chain& chain, bool sync)
{
+ cls_rgw_gc_obj_info info;
+ info.chain = chain;
+ info.tag = tag;
+
ObjectWriteOperation op;
- cls_rgw_gc_defer_entry(op, cct->_conf->rgw_gc_obj_min_wait, tag);
+ //cls_rgw_gc_defer_entry(op, cct->_conf->rgw_gc_obj_min_wait, tag);
+ cls_rgw_gc_defer_entry_queue(op, cct->_conf->rgw_gc_obj_min_wait, info);
int i = tag_index(tag);
return store->gc_aio_operate(obj_names[index], &op, pc);
}
+int RGWGC::remove(int index, string& marker, int num_entries, librados::AioCompletion **pc)
+{
+ ObjectWriteOperation op;
+ cls_rgw_gc_remove_entries_queue(op, marker, num_entries);
+ return store->gc_aio_operate(obj_names[index], &op, pc);
+}
+
int RGWGC::list(int *index, string& marker, uint32_t max, bool expired_only, std::list<cls_rgw_gc_obj_info>& result, bool *truncated)
{
result.clear();
for (; *index < max_objs && result.size() < max; (*index)++, marker.clear()) {
std::list<cls_rgw_gc_obj_info> entries;
- int ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[*index], marker, max - result.size(), expired_only, entries, truncated, next_marker);
+ //int ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[*index], marker, max - result.size(), expired_only, entries, truncated, next_marker);
+ int ret = cls_rgw_gc_list_queue(store->gc_pool_ctx, obj_names[*index], marker, max - result.size(), expired_only, entries, truncated, next_marker);
if (ret == -ENOENT)
continue;
if (ret < 0)
if (ret == -ENOENT) {
ret = 0;
}
-
+#if 0
if (io.type == IO::IndexIO) {
if (ret < 0) {
ldpp_dout(dpp, 0) << "WARNING: gc cleanup of tags on gc shard index=" <<
}
goto done;
}
-
+#endif
if (ret < 0) {
ldpp_dout(dpp, 0) << "WARNING: gc could not remove oid=" << io.oid <<
", ret=" << ret << dendl;
goto done;
}
- schedule_tag_removal(io.index, io.tag);
+ //schedule_tag_removal(io.index, io.tag);
done:
ios.pop_front();
void drain() {
drain_ios();
- flush_remove_tags();
+ //flush_remove_tags();
/* the tags draining might have generated more ios, drain those too */
drain_ios();
}
++index;
}
}
+
+ int remove_queue_entries(int index, string& marker, int num_entries) {
+ IO index_io;
+ index_io.type = IO::IndexIO;
+ index_io.index = index;
+ int ret = gc->remove(index, marker, num_entries, &index_io.c);
+ if (ret < 0) {
+ ldpp_dout(dpp, 0) << "WARNING: failed to remove queue entries on index=" <<
+ index << " ret=" << ret << dendl;
+ return ret;
+ }
+ return 0;
+ }
}; // class RGWGCIOManger
int RGWGC::process(int index, int max_secs, bool expired_only,
int max = 100;
std::list<cls_rgw_gc_obj_info> entries;
- ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[index], marker, max,
- expired_only, entries, &truncated, next_marker);
+ //ret = cls_rgw_gc_list(store->gc_pool_ctx, obj_names[index], marker, max,
+ // expired_only, entries, &truncated, next_marker);
+
+ ret = cls_rgw_gc_list_queue(store->gc_pool_ctx, obj_names[index], marker, max, expired_only, entries, &truncated, next_marker);
ldpp_dout(this, 20) <<
- "RGWGC::process cls_rgw_gc_list returned with returned:" << ret <<
+ "RGWGC::process cls_rgw_gc_list_queue returned with returned:" << ret <<
", entries.size=" << entries.size() << ", truncated=" << truncated <<
", next_marker='" << next_marker << "'" << dendl;
if (ret < 0)
goto done;
- marker = next_marker;
+ //marker = next_marker;
string last_pool;
std::list<cls_rgw_gc_obj_info>::iterator iter;
if (now >= end) {
goto done;
}
-
+#if 0
if (chain.objs.empty()) {
io_manager.schedule_tag_removal(index, info.tag);
} else {
io_manager.add_tag_io_size(index, info.tag, chain.objs.size());
+ }
+#endif
+ if (! chain.objs.empty()) {
for (liter = chain.objs.begin(); liter != chain.objs.end(); ++liter) {
cls_rgw_obj& obj = *liter;
} // chains loop
} // else -- chains not empty
} // entries loop
+ if (entries.size() > 0) {
+ //Remove the entries from the queue
+ ldpp_dout(this, 5) << "RGWGC::process removing entries, marker: " << marker << dendl;
+ ret = io_manager.remove_queue_entries(index, marker, entries.size());
+ if (ret < 0) {
+ ldpp_dout(this, 0) <<
+ "WARNING: failed to remove queue entries" << dendl;
+ goto done;
+ }
+ marker = next_marker;
+ }
} while (truncated);
done: