void cls_log_trim(librados::ObjectWriteOperation& op, const utime_t& from_time, const utime_t& to_time,
const string& from_marker, const string& to_marker);
+
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_log_trim(librados::IoCtx& io_ctx, const string& oid, const utime_t& from_time, const utime_t& to_time,
const string& from_marker, const string& to_marker);
+#endif
void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header);
op.exec(RGW_CLASS, RGW_BUCKET_UNLINK_INSTANCE, in);
}
-void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret *ret, int* op_ret)
+void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret)
{
bufferlist in;
rgw_cls_read_olh_log_op call;
call.ver_marker = ver_marker;
call.olh_tag = olh_tag;
encode(call, in);
- op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, new ClsBucketIndexOpCtx<rgw_cls_read_olh_log_ret>(ret, op_ret));
+ op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, new ClsBucketIndexOpCtx<rgw_cls_read_olh_log_ret>(&log_ret, &op_ret));
}
-int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,
+int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
const string& olh_tag,
- rgw_cls_read_olh_log_ret *ret)
+ rgw_cls_read_olh_log_ret& log_ret)
{
- int *op_ret;
- cls_rgw_get_olh_log(op, olh, ver_marker, olh_tag, ret, op_ret);
+ int op_ret = 0;
+ librados::ObjectReadOperation op;
+ cls_rgw_get_olh_log(op, olh, ver_marker, olh_tag, log_ret, op_ret);
int r = io_ctx.operate(oid, &op, NULL);
if (r < 0) {
return r;
}
if (op_ret < 0) {
- return *op_ret;
+ return op_ret;
}
return r;
void cls_rgw_bucket_unlink_instance(librados::ObjectWriteOperation& op,
const cls_rgw_obj_key& key, const string& op_tag,
const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace);
-void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret *ret, int* op_ret);
+void cls_rgw_get_olh_log(librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret, int& op_ret);
void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const string& olh_tag);
void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const string& olh_tag);
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_obj_key& key, const string& op_tag,
const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace);
-int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,
- const string& olh_tag, rgw_cls_read_olh_log_ret *ret);
+int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
+ const string& olh_tag, rgw_cls_read_olh_log_ret& log_ret);
int cls_rgw_clear_olh(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag);
int cls_rgw_usage_log_trim(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket,
uint64_t start_epoch, uint64_t end_epoch);
void cls_rgw_suggest_changes(librados::ObjectWriteOperation& o, bufferlist& updates);
/* usage logging */
+// these overloads which call io_ctx.operate() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_usage_log_read(librados::IoCtx& io_ctx, const string& oid, const string& user, const string& bucket,
uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, string& read_iter,
map<rgw_user_bucket, rgw_usage_log_entry>& usage, bool *is_truncated);
+#endif
void cls_rgw_usage_log_trim(librados::ObjectWriteOperation& op, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch);
/* garbage collection */
void cls_rgw_gc_set_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, cls_rgw_gc_obj_info& info);
void cls_rgw_gc_defer_entry(librados::ObjectWriteOperation& op, uint32_t expiration_secs, const string& tag);
+void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector<string>& tags);
+// these overloads which call io_ctx.operate() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_gc_list(librados::IoCtx& io_ctx, string& oid, string& marker, uint32_t max, bool expired_only,
list<cls_rgw_gc_obj_info>& entries, bool *truncated, string& next_marker);
-
-void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector<string>& tags);
+#endif
/* lifecycle */
+// these overloads which call io_ctx.operate() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head);
int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head);
int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const string& oid, string& marker, pair<string, int>& entry);
const string& marker,
uint32_t max_entries,
map<string, int>& entries);
+#endif
/* resharding */
void cls_rgw_reshard_add(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry);
+void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry);
+// these overloads which call io_ctx.operate() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& marker, uint32_t max,
list<cls_rgw_reshard_entry>& entries, bool* is_truncated);
int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry);
-void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry);
+#endif
/* resharding attribute on bucket index shard headers */
+void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err);
+// these overloads which call io_ctx.operate() should not be called in the rgw.
+// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_bucket_instance_entry& entry);
int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid);
-void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err);
int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
cls_rgw_bucket_instance_entry *entry);
+#endif
#endif
const std::string& from_marker = std::string(),
const std::string& to_marker = std::string());
+#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_timeindex_trim(
librados::IoCtx& io_ctx,
const std::string& oid,
const std::string& from_marker = std::string(),
const std::string& to_marker = std::string());
#endif
+
+#endif
add_dependencies(rgw_a civetweb_h)
+target_compile_definitions(rgw_a PUBLIC "-DCLS_CLIENT_HIDE_IOCTX")
target_include_directories(rgw_a PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src")
target_include_directories(rgw_a SYSTEM PUBLIC "../rapidjson/include")
target_link_libraries(radosgw_a
PRIVATE ${rgw_libs} rgw_schedulers
PUBLIC dmclock::dmclock)
-target_compile_definitions(radosgw_a PUBLIC "-DCLS_CLIENT_HIDE_IOCTX")
if(WITH_RADOSGW_BEAST_FRONTEND AND WITH_RADOSGW_BEAST_OPENSSL)
# used by rgw_asio_frontend.cc
target_link_libraries(radosgw_a PRIVATE OpenSSL::SSL)
return 0;
}
+static int cls_timeindex_trim_repeat(rgw_rados_ref ref,
+ const string& oid,
+ const utime_t& from_time,
+ const utime_t& to_time,
+ const string& from_marker,
+ const string& to_marker)
+{
+ bool done = false;
+ do {
+ librados::ObjectWriteOperation op;
+ cls_timeindex_trim(op, from_time, to_time, from_marker, to_marker);
+ int r = rgw_rados_operate(ref.pool.ioctx(), oid, &op, null_yield);
+ if (r == -ENODATA)
+ done = true;
+ else if (r < 0)
+ return r;
+ } while (!done);
+
+ return 0;
+}
+
int RGWObjExpStore::objexp_hint_trim(const string& oid,
const ceph::real_time& start_time,
const ceph::real_time& end_time,
return r;
}
auto& ref = obj.get_ref();
- int ret = cls_timeindex_trim(ref.pool.ioctx(), ref.obj.oid, utime_t(start_time), utime_t(end_time),
+ int ret = cls_timeindex_trim_repeat(ref, oid, utime_t(start_time), utime_t(end_time),
from_marker, to_marker);
if ((ret < 0 ) && (ret != -ENOENT)) {
return ret;
#include "cls/rgw/cls_rgw_const.h"
#include "cls/refcount/cls_refcount_client.h"
#include "cls/version/cls_version_client.h"
-#include "cls/log/cls_log_client.h"
-#include "cls/lock/cls_lock_client.h"
-#include "cls/user/cls_user_client.h"
-#include "cls/otp/cls_otp_client.h"
#include "osd/osd_types.h"
#include "rgw_tools.h"
const rgw_raw_obj& loc = miter.get_location().get_raw_obj(this);
auto& ioctx = ref.pool.ioctx();
+ ioctx.locator_set_key(loc.loc);
+
ret = rgw_rados_operate(ioctx, loc.oid, &op, null_yield);
if (ret < 0) {
goto done_ret;
ObjectReadOperation op;
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
- rgw_cls_read_olh_log_ret *ret;
- int *op_ret;
- cls_rgw_get_olh_log(op, key, ver_marker, olh_tag, ret, op_ret);
+ rgw_cls_read_olh_log_ret log_ret;
+ int op_ret = 0;
+ cls_rgw_get_olh_log(op, key, ver_marker, olh_tag, log_ret, op_ret);
bufferlist outbl;
int r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, &outbl, null_yield);
if (r < 0) {
return r;
}
if (op_ret < 0) {
- return *op_ret;
+ return op_ret;
}
+ *log = std::move(log_ret.log);
+ *is_truncated = log_ret.is_truncated;
return r;
});
if (ret < 0) {
return r;
}
-int RGWRados::cls_rgw_usage_log_trim_repeat(rgw_rados_ref ref, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch)
+static int cls_rgw_usage_log_trim_repeat(rgw_rados_ref ref, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch)
{
bool done = false;
do {
int cls_obj_usage_log_read(const string& oid, const string& user, const string& bucket, uint64_t start_epoch,
uint64_t end_epoch, uint32_t max_entries, string& read_iter, map<rgw_user_bucket,
rgw_usage_log_entry>& usage, bool *is_truncated);
- int cls_rgw_usage_log_trim_repeat(rgw_rados_ref ref, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch);
int cls_obj_usage_log_trim(const string& oid, const string& user, const string& bucket, uint64_t start_epoch,
uint64_t end_epoch);
int cls_obj_usage_log_clear(string& oid);
if (!key.instance.empty()) {
bufferlist olh_tag;
olh_tag.append(tag);
- ObjectWriteOperation op2;
rgw_zone_set zone_set;
- ASSERT_EQ(0, cls_rgw_bucket_link_olh(ioctx, op2, oid, key, olh_tag,
+ ASSERT_EQ(0, cls_rgw_bucket_link_olh(ioctx, oid, key, olh_tag,
false, tag, &meta, epoch,
ceph::real_time{}, true, true, zone_set));
}