op.exec("log", "trim", in);
}
-int cls_log_trim(librados::IoCtx& io_ctx, string& oid, utime_t& from, utime_t& to)
+int cls_log_trim(librados::IoCtx& io_ctx, const string& oid, utime_t& from, utime_t& to)
{
bool done = false;
string *out_marker, bool *truncated);
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);
+int cls_log_trim(librados::IoCtx& io_ctx, const string& oid, utime_t& from, utime_t& to);
#endif
cerr << " metadata rm remove metadata info\n";
cerr << " metadata list list metadata info\n";
cerr << " mdlog list list metadata log\n";
+ cerr << " mdlog trim trim metadata log\n";
cerr << " bilog list list bucket index log\n";
cerr << " datalog list list data log\n";
cerr << "options:\n";
OPT_METADATA_RM,
OPT_METADATA_LIST,
OPT_MDLOG_LIST,
+ OPT_MDLOG_TRIM,
OPT_BILOG_LIST,
OPT_DATALOG_LIST,
};
} else if (strcmp(prev_cmd, "mdlog") == 0) {
if (strcmp(cmd, "list") == 0)
return OPT_MDLOG_LIST;
+ if (strcmp(cmd, "trim") == 0)
+ return OPT_MDLOG_TRIM;
} else if (strcmp(prev_cmd, "bilog") == 0) {
if (strcmp(cmd, "list") == 0)
return OPT_BILOG_LIST;
formatter->flush(cout);
}
+ if (opt_cmd == OPT_MDLOG_TRIM) {
+ utime_t start_time, end_time;
+
+ int ret = parse_date_str(start_date, start_time);
+ if (ret < 0)
+ return -ret;
+
+ ret = parse_date_str(end_date, end_time);
+ if (ret < 0)
+ return -ret;
+
+ RGWMetadataLog *meta_log = store->meta_mgr->get_log();
+
+ ret = meta_log->trim(store, start_time, end_time);
+ if (ret < 0) {
+ cerr << "ERROR: meta_log->trim(): " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ }
+
if (opt_cmd == OPT_BILOG_LIST) {
if (bucket_name.empty()) {
cerr << "ERROR: bucket not specified" << std::endl;
if (!is_truncated) {
++ctx->cur_shard;
- if (ctx->cur_shard <cct->_conf->rgw_md_log_max_shards) {
+ if (ctx->cur_shard < cct->_conf->rgw_md_log_max_shards) {
get_shard_oid(ctx->cur_shard, ctx->cur_oid);
ctx->marker.clear();
} else {
return 0;
}
+int RGWMetadataLog::trim(RGWRados *store, utime_t& from_time, utime_t& end_time)
+{
+ string oid;
+ for (int shard = 0; shard < cct->_conf->rgw_md_log_max_shards; shard++) {
+ get_shard_oid(shard, oid);
+
+ int ret;
+
+ ret = store->time_log_trim(oid, from_time, end_time);
+
+ if (ret == -ENOENT)
+ ret = 0;
+
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
obj_version& RGWMetadataObject::get_version()
{
return objv;
int max_entries,
list<cls_log_entry>& entries,
bool *truncated);
+
+ int trim(RGWRados *store, utime_t& from_time, utime_t& end_time);
};
class RGWMetadataManager {
return 0;
}
+int RGWRados::time_log_trim(const string& oid, utime_t& start_time, utime_t& end_time)
+{
+ librados::IoCtx io_ctx;
+
+ const char *log_pool = zone.log_pool.name.c_str();
+ int r = rados->ioctx_create(log_pool, io_ctx);
+ if (r < 0)
+ return r;
+
+ return cls_log_trim(io_ctx, oid, start_time, end_time);
+}
+
int RGWRados::decode_policy(bufferlist& bl, ACLOwner *owner)
{
bufferlist::iterator i = bl.begin();
int time_log_add(const string& oid, const utime_t& ut, string& section, string& key, bufferlist& bl);
int time_log_list(const string& oid, utime_t& start_time, utime_t& end_time,
int max_entries, list<cls_log_entry>& entries, string& marker, bool *truncated);
+ int time_log_trim(const string& oid, utime_t& start_time, utime_t& end_time);
/// clean up/process any temporary objects older than given date[/time]
int remove_temp_objects(string date, string time);