Merge pull request #28569 from alimaredia/wip-rgw-ioctx-operate-replace

rgw: replace direct calls to ioctx.operate()
This commit is contained in:
Ali Maredia 2019-10-01 16:48:11 -04:00 committed by GitHub
commit bc8efa16d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 234 additions and 109 deletions

View File

@ -23,8 +23,13 @@ void cls_log_list(librados::ObjectReadOperation& op, utime_t& from, utime_t& to,
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);
// 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_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);

View File

@ -16,19 +16,23 @@ namespace rados {
static void create(librados::ObjectWriteOperation *op, const otp_info_t& config);
static void set(librados::ObjectWriteOperation *op, const list<otp_info_t>& entries);
static void remove(librados::ObjectWriteOperation *op, const string& id);
static int get(librados::ObjectReadOperation *op,
librados::IoCtx& ioctx, const string& oid,
const list<string> *ids, bool get_all, list<otp_info_t> *result);
static int get(librados::ObjectReadOperation *op,
librados::IoCtx& ioctx, const string& oid,
const string& id, otp_info_t *result);
static int get_all(librados::ObjectReadOperation *op,
librados::IoCtx& ioctx, const string& oid,
list<otp_info_t> *result);
// these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw.
// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
#ifndef CLS_CLIENT_HIDE_IOCTX
static int get(librados::ObjectReadOperation *op,
librados::IoCtx& ioctx, const string& oid,
const list<string> *ids, bool get_all, list<otp_info_t> *result);
static int check(CephContext *cct, librados::IoCtx& ioctx, const string& oid,
const string& id, const string& val, otp_check_t *result);
static int get_current_time(librados::IoCtx& ioctx, const string& oid,
ceph::real_time *result);
#endif
};
class TOTPConfig {

View File

@ -29,6 +29,10 @@
void cls_refcount_get(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref = false);
void cls_refcount_put(librados::ObjectWriteOperation& op, const string& tag, bool implicit_ref = false);
void cls_refcount_set(librados::ObjectWriteOperation& op, list<string>& refs);
// these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw.
// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_refcount_read(librados::IoCtx& io_ctx, string& oid, list<string> *refs, bool implicit_ref = false);
#endif
#endif

View File

@ -357,10 +357,24 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid,
return 0;
}
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace)
{
librados::ObjectWriteOperation op;
cls_rgw_bucket_link_olh(op, key, olh_tag, delete_marker, op_tag, meta,
olh_epoch, unmod_since, high_precision_time, log_op,
zones_trace);
return io_ctx.operate(oid, &op);
}
void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& key,
bufferlist& olh_tag, bool delete_marker,
const string& op_tag, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace)
{
bufferlist in, out;
rgw_cls_link_olh_op call;
@ -378,6 +392,14 @@ int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperat
call.zones_trace = zones_trace;
encode(call, in);
op.exec(RGW_CLASS, RGW_BUCKET_LINK_OLH, in);
}
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)
{
librados::ObjectWriteOperation op;
cls_rgw_bucket_unlink_instance(op, key, op_tag, olh_tag, olh_epoch, log_op, zones_trace);
int r = io_ctx.operate(oid, &op);
if (r < 0)
return r;
@ -385,8 +407,7 @@ int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperat
return 0;
}
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
const string& oid,
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)
{
@ -400,25 +421,26 @@ int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, librados::ObjectWrit
call.zones_trace = zones_trace;
encode(call, in);
op.exec(RGW_CLASS, RGW_BUCKET_UNLINK_INSTANCE, in);
int r = io_ctx.operate(oid, &op);
if (r < 0)
return r;
return 0;
}
int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,
const string& olh_tag,
map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated)
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, out;
bufferlist in;
rgw_cls_read_olh_log_op call;
call.olh = olh;
call.ver_marker = ver_marker;
call.olh_tag = olh_tag;
encode(call, in);
int op_ret;
op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, &out, &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, 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 = 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;
@ -427,21 +449,6 @@ int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, librados::ObjectReadOperatio
return op_ret;
}
rgw_cls_read_olh_log_ret ret;
try {
auto iter = out.cbegin();
decode(ret, iter);
} catch (buffer::error& err) {
return -EIO;
}
if (log) {
*log = ret.log;
}
if (is_truncated) {
*is_truncated = ret.is_truncated;
}
return r;
}
@ -456,20 +463,22 @@ void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_
op.exec(RGW_CLASS, RGW_BUCKET_TRIM_OLH_LOG, in);
}
int cls_rgw_clear_olh(IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag)
int cls_rgw_clear_olh(IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag)
{
bufferlist in, out;
librados::ObjectWriteOperation op;
cls_rgw_clear_olh(op, olh, olh_tag);
return io_ctx.operate(oid, &op);
}
void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const string& olh_tag)
{
bufferlist in;
rgw_cls_bucket_clear_olh_op call;
call.key = olh;
call.olh_tag = olh_tag;
encode(call, in);
int op_ret;
op.exec(RGW_CLASS, RGW_BUCKET_CLEAR_OLH, in, &out, &op_ret);
int r = io_ctx.operate(oid, &op);
if (r < 0) {
return r;
}
return op_ret;
op.exec(RGW_CLASS, RGW_BUCKET_CLEAR_OLH, in);
}
void cls_rgw_bilog_list(librados::ObjectReadOperation& op,
@ -698,6 +707,19 @@ int cls_rgw_usage_log_trim(IoCtx& io_ctx, const string& oid, const string& user,
return 0;
}
void cls_rgw_usage_log_trim(librados::ObjectWriteOperation& op, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch)
{
bufferlist in;
rgw_cls_usage_log_trim_op call;
call.start_epoch = start_epoch;
call.end_epoch = end_epoch;
call.user = user;
call.bucket = bucket;
encode(call, in);
op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_TRIM, in);
}
void cls_rgw_usage_log_clear(ObjectWriteOperation& op)
{
bufferlist in;

View File

@ -380,18 +380,34 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid,
list<rgw_cls_bi_entry> *entries, bool *is_truncated);
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
void cls_rgw_bucket_link_olh(librados::ObjectWriteOperation& op,
const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace);
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
const string& oid, const cls_rgw_obj_key& key, const string& op_tag,
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);
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,
map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated);
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);
int cls_rgw_clear_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag);
void cls_rgw_clear_olh(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, const string& olh_tag);
// 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_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid,
const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace);
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, 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);
#endif
/**
* List the bucket with the starting object and filter prefix.
@ -550,12 +566,15 @@ void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist
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
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_usage_log_trim(librados::ObjectWriteOperation& op, const string& user, const string& bucket, uint64_t start_epoch, uint64_t end_epoch);
void cls_rgw_usage_log_clear(librados::ObjectWriteOperation& op);
void cls_rgw_usage_log_add(librados::ObjectWriteOperation& op, rgw_usage_log_info& info);
@ -563,13 +582,19 @@ void cls_rgw_usage_log_add(librados::ObjectWriteOperation& op, rgw_usage_log_inf
/* 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);
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);
// 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);
#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);
@ -580,21 +605,29 @@ int cls_rgw_lc_list(librados::IoCtx& io_ctx, const string& oid,
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);
int cls_rgw_reshard_get_head(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

View File

@ -83,6 +83,9 @@ void cls_timeindex_trim(
const std::string& from_marker = std::string(),
const std::string& to_marker = std::string());
// 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_timeindex_trim(
librados::IoCtx& io_ctx,
const std::string& oid,
@ -91,3 +94,5 @@ int cls_timeindex_trim(
const std::string& from_marker = std::string(),
const std::string& to_marker = std::string());
#endif
#endif

View File

@ -18,7 +18,11 @@ void cls_version_inc(librados::ObjectWriteOperation& op, obj_version& ver, Versi
void cls_version_read(librados::ObjectReadOperation& op, obj_version *objv);
// these overloads which call io_ctx.operate() or io_ctx.exec() should not be called in the rgw.
// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
#ifndef CLS_CLIENT_HIDE_IOCTX
int cls_version_read(librados::IoCtx& io_ctx, string& oid, obj_version *ver);
#endif
void cls_version_check(librados::ObjectOperation& op, obj_version& ver, VersionCond cond);

View File

@ -201,6 +201,7 @@ add_library(rgw_a STATIC
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")

View File

@ -147,6 +147,27 @@ int RGWObjExpStore::objexp_hint_list(const string& oid,
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,
@ -160,7 +181,7 @@ int RGWObjExpStore::objexp_hint_trim(const string& oid,
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;

View File

@ -6156,7 +6156,7 @@ int RGWCompleteMultipart::MPSerializer::try_lock(
op.assert_exists();
lock.set_duration(dur);
lock.lock_exclusive(&op);
int ret = ioctx.operate(oid, &op);
int ret = rgw_rados_operate(ioctx, oid, &op, null_yield);
if (! ret) {
locked = true;
}

View File

@ -165,7 +165,7 @@ int RGWOrphanStore::store_entries(const string& oid, const map<string, bufferlis
for (map<string, bufferlist>::const_iterator iter = entries.begin(); iter != entries.end(); ++iter) {
ldout(store->ctx(), 20) << " > " << iter->first << dendl;
}
int ret = ioctx.operate(oid, &op);
int ret = rgw_rados_operate(ioctx, oid, &op, null_yield);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: " << __func__ << "(" << oid << ") returned ret=" << ret << dendl;
}

View File

@ -36,10 +36,6 @@
#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"
@ -2294,9 +2290,9 @@ int RGWRados::fix_head_obj_locator(const RGWBucketInfo& bucket_info, bool copy_o
#define HEAD_SIZE 512 * 1024
op.read(0, HEAD_SIZE, &data, NULL);
ret = ioctx.operate(oid, &op, NULL);
ret = rgw_rados_operate(ioctx, oid, &op, &data, null_yield);
if (ret < 0) {
lderr(cct) << "ERROR: ioctx.operate(oid=" << oid << ") returned ret=" << ret << dendl;
lderr(cct) << "ERROR: rgw_rados_operate(oid=" << oid << ") returned ret=" << ret << dendl;
return ret;
}
@ -2323,7 +2319,7 @@ int RGWRados::fix_head_obj_locator(const RGWBucketInfo& bucket_info, bool copy_o
wop.write(0, data);
ioctx.locator_set_key(locator);
ioctx.operate(oid, &wop);
rgw_rados_operate(ioctx, oid, &wop, null_yield);
}
if (remove_bad) {
@ -2371,7 +2367,7 @@ int RGWRados::move_rados_obj(librados::IoCtx& src_ioctx,
mtime = real_clock::from_timespec(mtime_ts);
}
rop.read(ofs, chunk_size, &data, NULL);
ret = src_ioctx.operate(src_oid, &rop, NULL);
ret = rgw_rados_operate(src_ioctx, src_oid, &rop, &data, null_yield);
if (ret < 0) {
goto done_err;
}
@ -2386,7 +2382,7 @@ int RGWRados::move_rados_obj(librados::IoCtx& src_ioctx,
mtime = real_clock::from_timespec(mtime_ts);
}
wop.write(ofs, data);
ret = dst_ioctx.operate(dst_oid, &wop);
ret = rgw_rados_operate(dst_ioctx, dst_oid, &wop, null_yield);
if (ret < 0) {
goto done_err;
}
@ -3009,7 +3005,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si
auto& ioctx = ref.pool.ioctx();
tracepoint(rgw_rados, operate_enter, req_id.c_str());
r = ioctx.operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
tracepoint(rgw_rados, operate_exit, req_id.c_str());
if (r < 0) { /* we can expect to get -ECANCELED if object was replaced under,
or -ENOENT if was removed, or -EEXIST if it did not exist
@ -4103,7 +4099,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
auto& ioctx = ref.pool.ioctx();
ioctx.locator_set_key(loc.loc);
ret = ioctx.operate(loc.oid, &op);
ret = rgw_rados_operate(ioctx, loc.oid, &op, null_yield);
if (ret < 0) {
goto done_ret;
}
@ -4159,7 +4155,7 @@ done_ret:
ref.pool.ioctx().locator_set_key(riter->loc);
int r = ref.pool.ioctx().operate(riter->oid, &op);
int r = rgw_rados_operate(ref.pool.ioctx(), riter->oid, &op, null_yield);
if (r < 0) {
ldpp_dout(dpp, 0) << "ERROR: cleanup after error failed to drop reference on obj=" << *riter << dendl;
}
@ -4818,7 +4814,7 @@ int RGWRados::Object::Delete::delete_obj(optional_yield y)
store->remove_rgw_head_obj(op);
auto& ioctx = ref.pool.ioctx();
r = ioctx.operate(ref.obj.oid, &op);
r = rgw_rados_operate(ioctx, ref.obj.oid, &op, null_yield);
/* raced with another operation, object state is indeterminate */
const bool need_invalidate = (r == -ECANCELED);
@ -4888,7 +4884,7 @@ int RGWRados::delete_raw_obj(const rgw_raw_obj& obj)
ObjectWriteOperation op;
op.remove();
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
if (r < 0)
return r;
@ -5511,7 +5507,7 @@ int RGWRados::set_attrs(void *ctx, const RGWBucketInfo& bucket_info, rgw_obj& sr
struct timespec mtime_ts = real_clock::to_timespec(mtime);
op.mtime2(&mtime_ts);
auto& ioctx = ref.pool.ioctx();
r = ioctx.operate(ref.obj.oid, &op);
r = rgw_rados_operate(ioctx, ref.obj.oid, &op, null_yield);
if (state) {
if (r >= 0) {
bufferlist acl_bl = attrs[RGW_ATTR_ACL];
@ -6199,7 +6195,7 @@ int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj,
return r;
}
return ref.pool.ioctx().operate(ref.obj.oid, op);
return rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, op, null_yield);
}
int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj, ObjectReadOperation *op)
@ -6212,7 +6208,7 @@ int RGWRados::obj_operate(const RGWBucketInfo& bucket_info, const rgw_obj& obj,
bufferlist outbl;
return ref.pool.ioctx().operate(ref.obj.oid, op, &outbl);
return rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, op, &outbl, null_yield);
}
int RGWRados::olh_init_modification_impl(const RGWBucketInfo& bucket_info, RGWObjState& state, const rgw_obj& olh_obj, string *op_tag)
@ -6493,13 +6489,14 @@ int RGWRados::bucket_index_link_olh(const RGWBucketInfo& bucket_info, RGWObjStat
auto& ref = bs->bucket_obj.get_ref();
librados::ObjectWriteOperation op;
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
return cls_rgw_bucket_link_olh(ref.pool.ioctx(), op,
ref.obj.oid, key, olh_state.olh_tag, delete_marker, op_tag, meta, olh_epoch,
unmod_since, high_precision_time,
svc.zone->get_zone().log_data, zones_trace);
cls_rgw_bucket_link_olh(op, key, olh_state.olh_tag,
delete_marker, op_tag, meta, olh_epoch,
unmod_since, high_precision_time,
svc.zone->get_zone().log_data, zones_trace);
return rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
});
if (r < 0) {
ldout(cct, 20) << "cls_rgw_bucket_link_olh() returned r=" << r << dendl;
ldout(cct, 20) << "rgw_rados_operate() after cls_rgw_bucket_link_olh() returned r=" << r << dendl;
return r;
}
@ -6539,11 +6536,12 @@ int RGWRados::bucket_index_unlink_instance(const RGWBucketInfo& bucket_info, con
auto& ref = bs->bucket_obj.get_ref();
librados::ObjectWriteOperation op;
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
return cls_rgw_bucket_unlink_instance(ref.pool.ioctx(), op, ref.obj.oid, key, op_tag,
olh_tag, olh_epoch, svc.zone->get_zone().log_data, zones_trace);
cls_rgw_bucket_unlink_instance(op, key, op_tag,
olh_tag, olh_epoch, svc.zone->get_zone().log_data, zones_trace);
return rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
});
if (r < 0) {
ldout(cct, 20) << "cls_rgw_bucket_link_olh() returned r=" << r << dendl;
ldout(cct, 20) << "rgw_rados_operate() after cls_rgw_bucket_link_instance() returned r=" << r << dendl;
return r;
}
@ -6578,8 +6576,22 @@ int RGWRados::bucket_index_read_olh_log(const RGWBucketInfo& bucket_info, RGWObj
auto& ref = bs->bucket_obj.get_ref();
ObjectReadOperation op;
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
return cls_rgw_get_olh_log(ref.pool.ioctx(), ref.obj.oid, op,
key, ver_marker, olh_tag, log, is_truncated);
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;
}
*log = std::move(log_ret.log);
*is_truncated = log_ret.is_truncated;
return r;
});
if (ret < 0) {
ldout(cct, 20) << "cls_rgw_get_olh_log() returned r=" << r << dendl;
@ -6635,7 +6647,7 @@ int RGWRados::repair_olh(RGWObjState* state, const RGWBucketInfo& bucket_info,
if (r < 0) {
return r;
}
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
if (r < 0) {
ldout(cct, 0) << "repair_olh failed to write olh attributes with "
<< cpp_strerror(r) << dendl;
@ -6669,7 +6681,7 @@ int RGWRados::bucket_index_trim_olh_log(const RGWBucketInfo& bucket_info, RGWObj
ObjectWriteOperation op;
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
cls_rgw_trim_olh_log(op, key, ver, olh_tag);
return pbs->bucket_obj.operate(&op, null_yield);
return pbs->bucket_obj.operate(&op, null_yield);
});
if (ret < 0) {
ldout(cct, 20) << "cls_rgw_trim_olh_log() returned r=" << ret << dendl;
@ -6698,10 +6710,11 @@ int RGWRados::bucket_index_clear_olh(const RGWBucketInfo& bucket_info, RGWObjSta
ObjectWriteOperation op;
auto& ref = pbs->bucket_obj.get_ref();
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
return cls_rgw_clear_olh(ref.pool.ioctx(), op, ref.obj.oid, key, olh_tag);
cls_rgw_clear_olh(op, key, olh_tag);
return rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
});
if (ret < 0) {
ldout(cct, 5) << "cls_rgw_clear_olh() returned ret=" << ret << dendl;
ldout(cct, 5) << "rgw_rados_operate() after cls_rgw_clear_olh() returned ret=" << ret << dendl;
return ret;
}
@ -6803,7 +6816,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, const RGW
}
/* update olh object */
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
if (r == -ECANCELED) {
r = 0;
}
@ -6826,7 +6839,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, const RGW
cls_obj_check_prefix_exist(rm_op, RGW_ATTR_OLH_PENDING_PREFIX, true); /* fail if found one of these, pending modification */
rm_op.remove();
r = ref.pool.ioctx().operate(ref.obj.oid, &rm_op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &rm_op, null_yield);
if (r == -ECANCELED) {
return 0; /* someone else won this race */
} else {
@ -7097,7 +7110,7 @@ int RGWRados::remove_olh_pending_entries(const RGWBucketInfo& bucket_info, RGWOb
op.rmxattr(i->first.c_str());
}
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
if (r == -ENOENT || r == -ECANCELED) {
/* raced with some other change, shouldn't sweat about it */
return 0;
@ -7182,8 +7195,7 @@ int RGWRados::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime,
op.read(0, cct->_conf->rgw_max_chunk_size, first_chunk, NULL);
}
bufferlist outbl;
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, &outbl, y);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, &outbl, null_yield);
if (epoch) {
*epoch = ref.pool.ioctx().get_last_version();
@ -7762,7 +7774,7 @@ int RGWRados::bi_list(rgw_bucket& bucket, int shard_id, const string& filter_obj
int RGWRados::gc_operate(string& oid, librados::ObjectWriteOperation *op)
{
return gc_pool_ctx.operate(oid, op);
return rgw_rados_operate(gc_pool_ctx, oid, op, null_yield);
}
int RGWRados::gc_aio_operate(string& oid, librados::ObjectWriteOperation *op, AioCompletion **pc)
@ -7779,7 +7791,7 @@ int RGWRados::gc_aio_operate(string& oid, librados::ObjectWriteOperation *op, Ai
int RGWRados::gc_operate(string& oid, librados::ObjectReadOperation *op, bufferlist *pbl)
{
return gc_pool_ctx.operate(oid, op, pbl);
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)
@ -8111,7 +8123,7 @@ int RGWRados::cls_bucket_list_unordered(RGWBucketInfo& bucket_info,
librados::ObjectReadOperation op;
cls_rgw_bucket_list_op(op, marker, prefix, num_entries,
list_versions, &result);
r = ioctx.operate(oid, &op, nullptr);
r = rgw_rados_operate(ioctx, oid, &op, nullptr, null_yield);
if (r < 0)
return r;
@ -8199,7 +8211,7 @@ int RGWRados::cls_obj_usage_log_add(const string& oid,
ObjectWriteOperation op;
cls_rgw_usage_log_add(op, info);
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
return r;
}
@ -8224,6 +8236,22 @@ int RGWRados::cls_obj_usage_log_read(const string& oid, const string& user, cons
return r;
}
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 {
librados::ObjectWriteOperation op;
cls_rgw_usage_log_trim(op, user, bucket, start_epoch, end_epoch);
int r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
if (r == -ENODATA)
done = true;
else if (r < 0)
return r;
} while (!done);
return 0;
}
int RGWRados::cls_obj_usage_log_trim(const string& oid, const string& user, const string& bucket,
uint64_t start_epoch, uint64_t end_epoch)
{
@ -8235,7 +8263,7 @@ int RGWRados::cls_obj_usage_log_trim(const string& oid, const string& user, cons
return r;
}
r = cls_rgw_usage_log_trim(ref.pool.ioctx(), ref.obj.oid, user, bucket, start_epoch, end_epoch);
r = cls_rgw_usage_log_trim_repeat(ref, user, bucket, start_epoch, end_epoch);
return r;
}
@ -8250,7 +8278,7 @@ int RGWRados::cls_obj_usage_log_clear(string& oid)
}
librados::ObjectWriteOperation op;
cls_rgw_usage_log_clear(op);
r = ref.pool.ioctx().operate(ref.obj.oid, &op);
r = rgw_rados_operate(ref.pool.ioctx(), ref.obj.oid, &op, null_yield);
return r;
}
@ -8612,4 +8640,3 @@ int RGWRados::delete_obj_aio(const rgw_obj& obj,
}
return ret;
}

View File

@ -794,7 +794,7 @@ int RGWReshard::add(cls_rgw_reshard_entry& entry)
librados::ObjectWriteOperation op;
cls_rgw_reshard_add(op, entry);
int ret = store->getRados()->reshard_pool_ctx.operate(logshard_oid, &op);
int ret = rgw_rados_operate(store->getRados()->reshard_pool_ctx, logshard_oid, &op, null_yield);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: failed to add entry to reshard log, oid=" << logshard_oid << " tenant=" << entry.tenant << " bucket=" << entry.bucket_name << dendl;
return ret;
@ -876,7 +876,7 @@ int RGWReshard::remove(cls_rgw_reshard_entry& entry)
librados::ObjectWriteOperation op;
cls_rgw_reshard_remove(op, entry);
int ret = store->getRados()->reshard_pool_ctx.operate(logshard_oid, &op);
int ret = rgw_rados_operate(store->getRados()->reshard_pool_ctx, logshard_oid, &op, null_yield);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: failed to remove entry from reshard log, oid=" << logshard_oid << " tenant=" << entry.tenant << " bucket=" << entry.bucket_name << dendl;
return ret;

View File

@ -94,9 +94,8 @@ void index_complete(librados::IoCtx& ioctx, string& oid, RGWModifyOp index_op,
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));
}