#define MAX_TRIM_ENTRIES 1000
size_t max_entries = MAX_TRIM_ENTRIES;
- int rc = cls_cxx_map_get_vals(hctx, index, log_index_prefix, max_entries, &keys);
+ int rc = cls_cxx_map_get_vals(hctx, from_index, log_index_prefix, max_entries, &keys);
if (rc < 0)
return rc;
map<string, bufferlist>::iterator iter = keys.begin();
size_t i;
+ bool removed = false;
for (i = 0; i < max_entries && iter != keys.end(); ++i, ++iter) {
const string& index = iter->first;
CLS_LOG(1, "ERROR: cls_log_trim_op(): failed to decode entry\n");
return -EINVAL;
}
+ removed = true;
}
+ if (!removed)
+ return -ENODATA;
+
return 0;
}
op.exec("log", "trim", in);
}
+int cls_log_trim(librados::IoCtx& io_ctx, string& oid, utime_t& from, utime_t& to)
+{
+ bool done = false;
+
+ do {
+ ObjectWriteOperation op;
+
+ cls_log_trim(op, from, to);
+
+ int r = io_ctx.operate(oid, &op);
+ if (r == -ENODATA)
+ done = true;
+ else if (r < 0)
+ return r;
+
+ } while (!done);
+
+
+ return 0;
+}
+
class LogListCtx : public ObjectOperationCompletion {
list<cls_log_entry> *entries;
bool *truncated;
void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, int max, list<cls_log_entry>& entries);
void cls_log_trim(librados::ObjectWriteOperation& op, utime_t& from, utime_t& to);
+int cls_log_trim(librados::IoCtx& io_ctx, string& oid, utime_t& from, utime_t& to);
#endif