RGWBucketInfo& bucket_info, rgw_bucket& bucket, map<string, bufferlist> *pattrs = nullptr)
{
if (!bucket_name.empty()) {
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r;
if (bucket_id.empty()) {
r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, nullptr, pattrs);
{
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL, &attrs);
if (r < 0) {
cerr << "could not get bucket info for bucket=" << bucket_name << ": " << cpp_strerror(-r) << std::endl;
{
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL, &attrs);
if (r < 0) {
#include "rgw_multi.h"
#include "services/svc_zone.h"
+#include "services/svc_sys_obj.h"
#include "include/rados/librados.hpp"
// until everything is moved from rgw_common
int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const string& bucket_name)
{
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: could not fetch bucket info: ret=" << ret << dendl;
new_bucket.creation_time = creation_time;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
if (update_entrypoint) {
ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, ep, &ot, NULL, &attrs);
RGWBucketEntryPoint ep;
RGWObjVersionTracker ot;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, ep, &ot, NULL, &attrs);
if (ret == -ENOENT)
return 0;
if (!bucket_info.has_instance_obj) {
/* an old bucket object, need to convert it */
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->convert_old_bucket_info(obj_ctx, bucket.tenant, bucket.name);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: failed converting old bucket info: " << ret << dendl;
RGWBucketInfo bucket_info;
real_time mtime;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, user_id.tenant, bucket.name, bucket_info, &mtime);
if (r < 0) {
ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket << dendl;
std::vector<rgw_bucket_dir_entry> objs;
map<string, bool> common_prefixes;
RGWBucketInfo info;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
string bucket_ver, master_ver;
map<string, bool> common_prefixes;
RGWBucketInfo info;
RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx sysobj_ctx = store->svc.sysobj->init_obj_ctx();
CephContext *cct = store->ctx();
string bucket_ver, master_ver;
- ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL);
+ ret = store->get_bucket_info(sysobj_ctx, bucket.tenant, bucket.name, info, NULL);
if (ret < 0)
return ret;
tenant = user_id.tenant;
bucket_name = op_state.get_bucket_name();
RGWUserBuckets user_buckets;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
if (bucket_name.empty() && user_id.empty())
return -EINVAL;
map<string, bufferlist> attrs;
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, &attrs);
if (r < 0) {
return r;
aclbl.clear();
policy.encode(aclbl);
- r = store->system_obj_set_attr(NULL, obj, RGW_ATTR_ACL, aclbl, &objv_tracker);
+ auto sysobj = obj_ctx.get_obj(obj);
+ r = sysobj.wop()
+ .set_objv_tracker(&objv_tracker)
+ .write_attr(RGW_ATTR_ACL, aclbl);
if (r < 0) {
return r;
}
rgw_raw_obj obj_bucket_instance;
store->get_bucket_instance_obj(bucket, obj_bucket_instance);
- r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker);
+ auto inst_sysobj = obj_ctx.get_obj(obj_bucket_instance);
+ r = inst_sysobj.wop()
+ .set_objv_tracker(&objv_tracker)
+ .write_attr(RGW_ATTR_ACL, aclbl);
if (r < 0) {
return r;
}
rgw_bucket bucket = op_state.get_bucket();
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, bucket_info, NULL, &attrs);
if (r < 0) {
set_err_msg(err_msg, "could not get bucket info for bucket=" + bucket.name + ": " + cpp_strerror(-r));
map<rgw_obj_index_key, string> all_objs;
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, nullptr, nullptr);
if (r < 0) {
ldout(store->ctx(), 0) << "ERROR: " << __func__ << "(): get_bucket_instance_info(bucket=" << bucket << ") returned r=" << r << dendl;
{
std::string object_name = op_state.get_object_name();
rgw_bucket bucket = op_state.get_bucket();
+ auto sysobj_ctx = store->svc.sysobj->init_obj_ctx();
RGWObjectCtx obj_ctx(store);
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
- int ret = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, bucket_info, NULL, &attrs);
+ int ret = store->get_bucket_info(sysobj_ctx, bucket.tenant, bucket.name, bucket_info, NULL, &attrs);
if (ret < 0) {
return ret;
}
map<RGWObjCategory, RGWStorageStats> stats;
real_time mtime;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, &mtime);
if (r < 0)
return r;
/* need info for num_shards */
RGWBucketInfo info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
marker = bucket.name; /* Casey's location for marker update,
* as we may now not reach the end of
real_time mtime;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
string tenant_name, bucket_name;
parse_bucket(entry, &tenant_name, &bucket_name);
map<string, bufferlist> attrs;
RGWObjVersionTracker old_ot;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
string tenant_name, bucket_name;
parse_bucket(entry, &tenant_name, &bucket_name);
int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override {
RGWBucketEntryPoint be;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
string tenant_name, bucket_name;
parse_bucket(entry, &tenant_name, &bucket_name);
RGWBucketCompleteInfo bci;
real_time mtime;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->get_bucket_instance_info(obj_ctx, oid, bci.info, &mtime, &bci.attrs);
if (ret < 0)
}
real_time orig_mtime;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->get_bucket_instance_info(obj_ctx, entry, old_bci.info,
&orig_mtime, &old_bci.attrs);
int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override {
RGWBucketInfo info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->get_bucket_instance_info(obj_ctx, entry, info, NULL, NULL);
if (ret < 0 && ret != -ENOENT)
};
WRITE_CLASS_ENCODER(RGWCacheNotifyInfo)
+class RGWChainedCache {
+public:
+ virtual ~RGWChainedCache() {}
+ virtual void chain_cb(const string& key, void *data) = 0;
+ virtual void invalidate(const string& key) = 0;
+ virtual void invalidate_all() = 0;
+
+ struct Entry {
+ RGWChainedCache *cache;
+ const string& key;
+ void *data;
+
+ Entry(RGWChainedCache *_c, const string& _k, void *_d) : cache(_c), key(_k), data(_d) {}
+ };
+};
+
+
struct ObjectCacheEntry {
ObjectCacheInfo info;
std::list<string>::iterator lru_iter;
#include "rgw_auth.h"
+class RGWObjectCtx;
+class RGWSysObjectCtx;
+
/** Store all the state necessary to complete and respond to an HTTP request*/
struct req_state : DoutPrefixProvider {
CephContext *cct;
Clock::duration time_elapsed() const { return Clock::now() - time; }
- void *obj_ctx{nullptr};
+ RGWObjectCtx *obj_ctx{nullptr};
+ RGWSysObjectCtx *sysobj_ctx{nullptr};
string dialect;
string req_id;
string trans_id;
#include "services/svc_zone.h"
#include "services/svc_zone_utils.h"
+#include "services/svc_sys_obj.h"
#include "cls/lock/cls_lock_client.h"
#include "cls/rgw/cls_rgw_client.h"
{
map<string, bufferlist> *pattrs = want_attrs ? &attrs : nullptr;
- return store->get_system_obj(obj_ctx, read_state, &objv_tracker,
- obj, bl, ofs, end, pattrs, nullptr);
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.rop()
+ .set_objv_tracker(&objv_tracker)
+ .set_attrs(pattrs)
+ .read(&bl);
}
-RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
- off_t _ofs, off_t _end, bool want_attrs)
- : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_store),
- obj(_obj), ofs(_ofs), end(_end), want_attrs(want_attrs)
+ bool want_attrs)
+ : RGWAsyncRadosRequest(caller, cn), obj_ctx(_svc),
+ obj(_obj), want_attrs(want_attrs)
{
if (_objv_tracker) {
objv_tracker = *_objv_tracker;
int RGWSimpleRadosReadAttrsCR::send_request()
{
req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(),
- store, nullptr, obj, 0, -1, true);
+ svc, nullptr, obj, true);
async_rados->queue(req);
return 0;
}
int RGWAsyncPutSystemObj::_send_request()
{
- return store->put_system_obj_data(NULL, obj, bl, -1, exclusive, &objv_tracker);
+ auto obj_ctx = svc->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.wop()
+ .set_objv_tracker(&objv_tracker)
+ .set_exclusive(exclusive)
+ .write_data(bl);
}
-RGWAsyncPutSystemObj::RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+RGWAsyncPutSystemObj::RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn,
+ RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
bool _exclusive, bufferlist _bl)
: RGWAsyncRadosRequest(caller, cn), store(_store),
int RGWAsyncPutSystemObjAttrs::_send_request()
{
- return store->system_obj_set_attrs(nullptr, obj, attrs, nullptr, &objv_tracker);
+ auto obj_ctx = svc->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.wop()
+ .set_objv_tracker(&objv_tracker)
+ .set_exclusive(false)
+ .set_attrs(attrs)
+ .write_attrs();
}
-RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn,
+ RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
map<string, bufferlist> _attrs)
- : RGWAsyncRadosRequest(caller, cn), store(_store),
+ : RGWAsyncRadosRequest(caller, cn), svc(_svc),
obj(_obj), attrs(std::move(_attrs))
{
+ if (_objv_tracker) {
+ objv_tracker = *_objv_tracker;
+ }
}
int RGWAsyncGetBucketInstanceInfo::_send_request()
{
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_from_oid(obj_ctx, oid, bucket_info, NULL, NULL);
if (r < 0) {
ldout(store->ctx(), 0) << "ERROR: failed to get bucket instance info for "
#include <atomic>
+#include "services/svc_sys_obj.h"
+
class RGWAsyncRadosRequest : public RefCountedObject {
RGWCoroutine *caller;
RGWAioCompletionNotifier *notifier;
class RGWAsyncGetSystemObj : public RGWAsyncRadosRequest {
- RGWRados *store;
- RGWObjectCtx obj_ctx;
- RGWRados::SystemObject::Read::GetObjState read_state;
+ RGWSysObjectCtx obj_ctx;
RGWObjVersionTracker objv_tracker;
rgw_raw_obj obj;
- off_t ofs;
- off_t end;
const bool want_attrs;
protected:
int _send_request() override;
public:
- RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+ RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
- off_t _ofs, off_t _end, bool want_attrs);
+ bool want_attrs);
bufferlist bl;
map<string, bufferlist> attrs;
};
class RGWAsyncPutSystemObj : public RGWAsyncRadosRequest {
- RGWRados *store;
+ RGWSI_SysObj *svc;
rgw_raw_obj obj;
bool exclusive;
bufferlist bl;
protected:
int _send_request() override;
public:
- RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+ RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
bool _exclusive, bufferlist _bl);
};
class RGWAsyncPutSystemObjAttrs : public RGWAsyncRadosRequest {
- RGWRados *store;
+ RGWSI_SysObj *svc;
rgw_raw_obj obj;
map<string, bufferlist> attrs;
protected:
int _send_request() override;
public:
- RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
+ RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWSI_SysObj *_svc,
RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
map<string, bufferlist> _attrs);
template <class T>
class RGWSimpleRadosReadCR : public RGWSimpleCoroutine {
RGWAsyncRadosProcessor *async_rados;
- RGWRados *store;
+ RGWSI_SysObj *svc;
+
rgw_raw_obj obj;
T *result;
/// on ENOENT, call handle_data() with an empty object instead of failing
RGWAsyncGetSystemObj *req{nullptr};
public:
- RGWSimpleRadosReadCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
+ RGWSimpleRadosReadCR(RGWAsyncRadosProcessor *_async_rados, RGWSI_SysObj *_svc,
const rgw_raw_obj& _obj,
T *_result, bool empty_on_enoent = true,
RGWObjVersionTracker *objv_tracker = nullptr)
- : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store),
+ : RGWSimpleCoroutine(_svc->ctx()), async_rados(_async_rados), svc(_svc),
obj(_obj), result(_result),
empty_on_enoent(empty_on_enoent), objv_tracker(objv_tracker) {}
~RGWSimpleRadosReadCR() override {
template <class T>
int RGWSimpleRadosReadCR<T>::send_request()
{
- req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(),
- store, objv_tracker, obj, 0, -1, false);
+ req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(), svc,
+ objv_tracker, obj, false);
async_rados->queue(req);
return 0;
}
class RGWSimpleRadosReadAttrsCR : public RGWSimpleCoroutine {
RGWAsyncRadosProcessor *async_rados;
- RGWRados *store;
+ RGWSI_SysObj *svc;
+
rgw_raw_obj obj;
map<string, bufferlist> *pattrs;
RGWAsyncGetSystemObj *req;
public:
- RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
+ RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWSI_SysObj *_svc,
const rgw_raw_obj& _obj,
- map<string, bufferlist> *_pattrs) : RGWSimpleCoroutine(_store->ctx()),
- async_rados(_async_rados), store(_store),
+ map<string, bufferlist> *_pattrs) : RGWSimpleCoroutine(_svc->ctx()),
+ async_rados(_async_rados), svc(_svc),
obj(_obj),
pattrs(_pattrs),
- req(NULL) { }
+ req(NULL) {}
~RGWSimpleRadosReadAttrsCR() override {
request_cleanup();
}
template <class T>
class RGWSimpleRadosWriteCR : public RGWSimpleCoroutine {
RGWAsyncRadosProcessor *async_rados;
- RGWRados *store;
+ RGWSI_SysObj *svc;
bufferlist bl;
rgw_raw_obj obj;
RGWObjVersionTracker *objv_tracker;
RGWAsyncPutSystemObj *req{nullptr};
public:
- RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
+ RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor *_async_rados, RGWSI_SysObj *_svc,
const rgw_raw_obj& _obj,
const T& _data, RGWObjVersionTracker *objv_tracker = nullptr)
- : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados),
- store(_store), obj(_obj), objv_tracker(objv_tracker) {
+ : RGWSimpleCoroutine(_svc->ctx()), async_rados(_async_rados),
+ svc(_svc), obj(_obj), objv_tracker(objv_tracker) {
encode(_data, bl);
}
int send_request() override {
req = new RGWAsyncPutSystemObj(this, stack->create_completion_notifier(),
- store, objv_tracker, obj, false, std::move(bl));
+ svc, objv_tracker, obj, false, std::move(bl));
async_rados->queue(req);
return 0;
}
class RGWSimpleRadosWriteAttrsCR : public RGWSimpleCoroutine {
RGWAsyncRadosProcessor *async_rados;
- RGWRados *store;
+ RGWSI_SysObj *svc;
RGWObjVersionTracker *objv_tracker;
+
rgw_raw_obj obj;
map<string, bufferlist> attrs;
RGWAsyncPutSystemObjAttrs *req = nullptr;
public:
RGWSimpleRadosWriteAttrsCR(RGWAsyncRadosProcessor *_async_rados,
- RGWRados *_store, const rgw_raw_obj& _obj,
+ RGWSI_SysObj *_svc, const rgw_raw_obj& _obj,
map<string, bufferlist> _attrs,
RGWObjVersionTracker *objv_tracker = nullptr)
- : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados),
- store(_store), objv_tracker(objv_tracker), obj(_obj),
+ : RGWSimpleCoroutine(_svc->ctx()), async_rados(_async_rados),
+ svc(_svc), objv_tracker(objv_tracker), obj(_obj),
attrs(std::move(_attrs)) {
}
~RGWSimpleRadosWriteAttrsCR() override {
int send_request() override {
req = new RGWAsyncPutSystemObjAttrs(this, stack->create_completion_notifier(),
- store, objv_tracker, obj, std::move(attrs));
+ svc, objv_tracker, obj, std::move(attrs));
async_rados->queue(req);
return 0;
}
return false;
}
using CR = RGWSimpleRadosReadCR<rgw_data_sync_marker>;
- spawn(new CR(env->async_rados, env->store,
+ spawn(new CR(env->async_rados, env->store->svc.sysobj,
rgw_raw_obj(env->store->svc.zone->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id)),
&markers[shard_id]),
false);
using ReadInfoCR = RGWSimpleRadosReadCR<rgw_data_sync_info>;
yield {
bool empty_on_enoent = false; // fail on ENOENT
- call(new ReadInfoCR(sync_env->async_rados, sync_env->store,
+ call(new ReadInfoCR(sync_env->async_rados, sync_env->store->svc.sysobj,
rgw_raw_obj(sync_env->store->svc.zone->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)),
&sync_status->sync_info, empty_on_enoent));
}
return set_cr_error(retcode);
}
using WriteInfoCR = RGWSimpleRadosWriteCR<rgw_data_sync_info>;
- yield call(new WriteInfoCR(sync_env->async_rados, store,
+ yield call(new WriteInfoCR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj{pool, sync_status_oid},
status->sync_info));
if (retcode < 0) {
marker.timestamp = info.last_update;
const auto& oid = RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, i);
using WriteMarkerCR = RGWSimpleRadosWriteCR<rgw_data_sync_marker>;
- spawn(new WriteMarkerCR(sync_env->async_rados, store,
+ spawn(new WriteMarkerCR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj{pool, oid}, marker), true);
}
}
}
status->sync_info.state = rgw_data_sync_info::StateBuildingFullSyncMaps;
- yield call(new WriteInfoCR(sync_env->async_rados, store,
+ yield call(new WriteInfoCR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj{pool, sync_status_oid},
status->sync_info));
if (retcode < 0) {
int shard_id = (int)iter->first;
rgw_data_sync_marker& marker = iter->second;
marker.total_entries = entries_index->get_total_entries(shard_id);
- spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)),
marker), true);
}
tn->log(20, SSTR("updating marker marker_oid=" << marker_oid << " marker=" << new_marker));
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ return new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, marker_oid),
sync_marker);
}
sync_marker.marker = sync_marker.next_step_marker;
sync_marker.next_step_marker.clear();
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ call(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, status_oid),
sync_marker));
}
RGWCoroutine *alloc_finisher_cr() override {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosReadCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ return new RGWSimpleRadosReadCR<rgw_data_sync_marker>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)),
&sync_marker);
}
RGWCoroutine *set_sync_info_cr() {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store,
+ return new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)),
sync_status.sync_info);
}
status.inc_marker.position = info.max_marker;
map<string, bufferlist> attrs;
status.encode_all_attrs(attrs);
- call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, obj, attrs));
+ call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store->svc.sysobj, obj, attrs));
}
}
if (info.syncstopped) {
int RGWReadBucketSyncStatusCoroutine::operate()
{
reenter(this) {
- yield call(new RGWSimpleRadosReadAttrsCR(sync_env->async_rados, sync_env->store,
+ yield call(new RGWSimpleRadosReadAttrsCR(sync_env->async_rados, sync_env->store->svc.sysobj,
rgw_raw_obj(sync_env->store->svc.zone->get_zone_params().log_pool, oid),
&attrs));
if (retcode == -ENOENT) {
reenter(this){
//read sync status marker
using CR = RGWSimpleRadosReadCR<rgw_data_sync_marker>;
- yield call(new CR(sync_env->async_rados, store,
+ yield call(new CR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, status_oid),
sync_marker));
if (retcode < 0) {
RGWRados *store = sync_env->store;
tn->log(20, SSTR("updating marker marker_oid=" << marker_oid << " marker=" << new_marker));
- return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store,
+ return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, marker_oid),
attrs);
}
tn->log(20, SSTR("updating marker marker_oid=" << marker_oid << " marker=" << new_marker));
return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados,
- store,
+ store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, marker_oid),
attrs);
}
map<string, bufferlist> attrs;
sync_info.encode_state_attr(attrs);
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store,
+ call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, status_oid),
attrs));
}
#include "rgw_bucket.h"
#include "rgw_lc.h"
+#include "services/svc_sys_obj.h"
+
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
string next_marker, no_ns, list_versions;
bool is_truncated;
vector<rgw_bucket_dir_entry> objs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
vector<std::string> result;
auto delay_ms = cct->_conf.get_val<int64_t>("rgw_lc_thread_delay");
boost::split(result, shard_id, boost::is_any_of(":"));
int read_history(RGWRados *store, RGWMetadataLogHistory *state,
RGWObjVersionTracker *objv_tracker)
{
- RGWObjectCtx ctx{store};
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
auto& pool = store->svc.zone->get_zone_params().log_pool;
const auto& oid = RGWMetadataLogHistory::oid;
bufferlist bl;
- int ret = rgw_get_system_obj(store, ctx, pool, oid, bl, objv_tracker, nullptr);
+ int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, objv_tracker, nullptr);
if (ret < 0) {
return ret;
}
if (bl.length() == 0) {
/* bad history object, remove it */
rgw_raw_obj obj(pool, oid);
- ret = store->delete_system_obj(obj);
+ auto sysobj = obj_ctx.get_obj(obj);
+ ret = sysobj.wop().remove();
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: meta history is empty, but cannot remove it (" << cpp_strerror(-ret) << ")" << dendl;
return ret;
constexpr bool empty_on_enoent = false;
using ReadCR = RGWSimpleRadosReadCR<RGWMetadataLogHistory>;
- call(new ReadCR(store->get_async_rados(), store, obj,
+ call(new ReadCR(store->get_async_rados(), store->svc.sysobj, obj,
&state, empty_on_enoent, objv_tracker));
}
if (retcode < 0) {
RGWMetadataLogHistory::oid};
using WriteCR = RGWSimpleRadosWriteCR<RGWMetadataLogHistory>;
- call(new WriteCR(store->get_async_rados(), store, obj, state, objv));
+ call(new WriteCR(store->get_async_rados(), store->svc.sysobj, obj, state, objv));
}
if (retcode < 0) {
ldout(cct, 1) << "failed to write mdlog history: "
{
bufferlist bl;
real_time orig_mtime;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = rgw_get_system_obj(store, obj_ctx, pool, oid,
bl, objv_tracker, &orig_mtime,
nullptr, nullptr);
string oid = heap_oid(handler, key, objv_tracker->write_version);
rgw_raw_obj obj(heap_pool, oid);
- int ret = store->delete_system_obj(obj);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ int ret = sysobj.wop().remove();
if (ret < 0) {
- ldout(store->ctx(), 0) << "ERROR: store->delete_system_obj() oid=" << oid << " returned ret=" << ret << dendl;
+ ldout(store->ctx(), 0) << "ERROR: sysobj.wop().remove() oid=" << oid << " returned ret=" << ret << dendl;
return ret;
}
rgw_raw_obj obj(pool, oid);
- ret = store->delete_system_obj(obj, objv_tracker);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ ret = sysobj.wop()
+ .set_objv_tracker(objv_tracker)
+ .remove();
/* cascading ret into post_modify() */
ret = post_modify(handler, section, key, log_data, objv_tracker, ret);
#include "rgw_usage.h"
#include "rgw_object_expirer_core.h"
+#include "services/svc_sys_obj.h"
+
#include "cls/lock/cls_lock_client.h"
#define dout_context g_ceph_context
const string& bucket_id,
RGWBucketInfo& bucket_info)
{
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
/*
* XXX Here's where it gets tricky. We went to all the trouble of
int ret = 0;
rgw_obj_key obj;
RGWUserInfo bucket_owner_info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
string bi = s->info.args.get(RGW_SYS_PARAM_PREFIX "bucket-instance");
if (!bi.empty()) {
if (bucket_name.compare(s->bucket.name) != 0) {
map<string, bufferlist> bucket_attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, s->user->user_id.tenant,
bucket_name, bucket_info, NULL,
&bucket_attrs);
RGWBucketInfo bucket_info;
map<string, bufferlist> bucket_attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_info(obj_ctx, s->user->user_id.tenant,
bucket_name, bucket_info, nullptr,
&bucket_attrs);
/* we need to make sure we read bucket info, it's not read before for this
* specific request */
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- op_ret = store->get_bucket_info(obj_ctx, s->bucket_tenant, s->bucket_name,
+ op_ret = store->get_bucket_info(*s->sysobj_ctx, s->bucket_tenant, s->bucket_name,
s->bucket_info, nullptr, &s->bucket_attrs);
if (op_ret < 0 && op_ret != -ENOENT)
return;
* changed in the meantime, we have to refresh. */
short tries = 0;
do {
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
RGWBucketInfo binfo;
map<string, bufferlist> battrs;
- op_ret = store->get_bucket_info(obj_ctx, s->bucket_tenant, s->bucket_name,
+ op_ret = store->get_bucket_info(*s->sysobj_ctx, s->bucket_tenant, s->bucket_name,
binfo, nullptr, &battrs);
if (op_ret < 0) {
return;
obj_ctx->obj.set_atomic(obj);
bool ver_restored = false;
- op_ret = store->swift_versioning_restore(*obj_ctx, s->bucket_owner.get_id(),
+ op_ret = store->swift_versioning_restore(*s->sysobj_ctx, *obj_ctx, s->bucket_owner.get_id(),
s->bucket_info, obj, ver_restored);
if (op_ret < 0) {
return;
}
map<string, bufferlist> src_attrs;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-
if (s->bucket_instance_id.empty()) {
- op_ret = store->get_bucket_info(obj_ctx, src_tenant_name, src_bucket_name, src_bucket_info, NULL, &src_attrs);
+ op_ret = store->get_bucket_info(*s->sysobj_ctx, src_tenant_name, src_bucket_name, src_bucket_info, NULL, &src_attrs);
} else {
/* will only happen in intra region sync where the source and dest bucket is the same */
- op_ret = store->get_bucket_instance_info(obj_ctx, s->bucket_instance_id, src_bucket_info, NULL, &src_attrs);
+ op_ret = store->get_bucket_instance_info(*s->sysobj_ctx, s->bucket_instance_id, src_bucket_info, NULL, &src_attrs);
}
if (op_ret < 0) {
if (op_ret == -ENOENT) {
dest_bucket_info = src_bucket_info;
dest_attrs = src_attrs;
} else {
- op_ret = store->get_bucket_info(obj_ctx, dest_tenant_name, dest_bucket_name,
+ op_ret = store->get_bucket_info(*s->sysobj_ctx, dest_tenant_name, dest_bucket_name,
dest_bucket_info, nullptr, &dest_attrs);
if (op_ret < 0) {
if (op_ret == -ENOENT) {
map<string, bufferlist> battrs;
ACLOwner bowner;
- int ret = store->get_bucket_info(obj_ctx, s->user->user_id.tenant,
+ int ret = store->get_bucket_info(*s->sysobj_ctx, s->user->user_id.tenant,
path.bucket_name, binfo, nullptr,
&battrs);
if (ret < 0) {
info.effective_uri = "/" + bucket_name;
}
+void RGWBulkUploadOp::init(RGWRados* const store,
+ struct req_state* const s,
+ RGWHandler* const h)
+{
+ RGWOp::init(store, s, h);
+ dir_ctx.emplace(store->svc.sysobj->init_obj_ctx());
+}
+
int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
{
ldpp_dout(this, 20) << "got directory=" << path << dendl;
RGWBucketInfo binfo;
std::map<std::string, ceph::bufferlist> battrs;
ACLOwner bowner;
- op_ret = store->get_bucket_info(obj_ctx, s->user->user_id.tenant,
+ op_ret = store->get_bucket_info(*s->sysobj_ctx, s->user->user_id.tenant,
bucket_name, binfo, nullptr, &battrs);
if (op_ret == -ENOENT) {
ldpp_dout(this, 20) << "non existent directory=" << bucket_name << dendl;
#include "cls/lock/cls_lock_client.h"
#include "cls/rgw/cls_rgw_client.h"
+#include "services/svc_sys_obj.h"
+
#include "include/ceph_assert.h"
using ceph::crypto::SHA1;
class RGWBulkUploadOp : public RGWOp {
- boost::optional<RGWObjectCtx> dir_ctx;
+ boost::optional<RGWSysObjectCtx> dir_ctx;
protected:
class fail_desc_t {
void init(RGWRados* const store,
struct req_state* const s,
- RGWHandler* const h) override {
- RGWOp::init(store, s, h);
- dir_ctx.emplace(store);
- }
+ RGWHandler* const h) override;
int verify_permission() override;
void pre_exec() override;
#include "rgw_orphan.h"
#include "services/svc_zone.h"
+#include "services/svc_sys_obj.h"
#define dout_subsys ceph_subsys_rgw
ldout(store->ctx(), 10) << "building linked oids for bucket instance: " << bucket_instance_id << dendl;
RGWBucketInfo bucket_info;
RGWObjectCtx obj_ctx(store);
- int ret = store->get_bucket_instance_info(obj_ctx, bucket_instance_id, bucket_info, NULL, NULL);
+ auto sysobj_ctx = store->svc.sysobj->init_obj_ctx();
+ int ret = store->get_bucket_instance_info(sysobj_ctx, bucket_instance_id, bucket_info, NULL, NULL);
if (ret < 0) {
if (ret == -ENOENT) {
/* probably raced with bucket removal */
RGWObjectCtx rados_ctx(store, s);
s->obj_ctx = &rados_ctx;
+ auto sysobj_ctx = store->svc.sysobj->init_obj_ctx();
+ s->sysobj_ctx = &sysobj_ctx;
+
if (ret < 0) {
s->cio = client_io;
abort_early(s, nullptr, ret, nullptr);
#include "rgw_bucket.h"
#include "rgw_user.h"
+#include "services/svc_sys_obj.h"
+
#include <atomic>
#define dout_context g_ceph_context
{
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL);
if (r < 0) {
{
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL);
if (r < 0) {
{
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
int r = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL);
if (r < 0) {
ldout(cct, 20) << __func__ << " bucket index max shards: " << bucket_index_max_shards << dendl;
binfo_cache = new RGWChainedCacheImpl<bucket_info_entry>;
- binfo_cache->init(this);
+ binfo_cache->init(svc.cache);
bool need_tombstone_cache = !svc.zone->get_zone_data_notify_to_map().empty(); /* have zones syncing from us */
rgw_bucket bucket = bucket_info.bucket;
bucket.update_bucket_id(new_bucket_id);
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = store->get_bucket_instance_info(obj_ctx, bucket, bucket_info, nullptr, nullptr);
if (ret < 0) {
/* we need to reread the info and return it, caller will have a use for it */
RGWObjVersionTracker instance_ver = info.objv_tracker;
info.objv_tracker.clear();
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
r = get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL, NULL);
if (r < 0) {
if (r == -ENOENT) {
{
bucket = _bucket;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
RGWBucketInfo bucket_info;
RGWBucketInfo* bucket_info_p =
bucket = _bucket;
shard_id = sid;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
RGWBucketInfo bucket_info;
RGWBucketInfo* bucket_info_p =
RGWBucketInfo dest_bucket_info;
- r = get_bucket_info(obj_ctx, bucket_info.bucket.tenant, bucket_info.swift_ver_location, dest_bucket_info, NULL, NULL);
+ auto sysobj_ctx = svc.sysobj->init_obj_ctx();
+
+ r = get_bucket_info(sysobj_ctx, bucket_info.bucket.tenant, bucket_info.swift_ver_location, dest_bucket_info, NULL, NULL);
if (r < 0) {
ldout(cct, 10) << "failed to read dest bucket info: r=" << r << dendl;
if (r == -ENOENT) {
return r;
}
-int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx,
+int RGWRados::swift_versioning_restore(RGWSysObjectCtx& sysobj_ctx,
+ RGWObjectCtx& obj_ctx,
const rgw_user& user,
RGWBucketInfo& bucket_info,
rgw_obj& obj,
/* Bucket info of the bucket that stores previous versions of our object. */
RGWBucketInfo archive_binfo;
- int ret = get_bucket_info(obj_ctx, bucket_info.bucket.tenant,
+ int ret = get_bucket_info(sysobj_ctx, bucket_info.bucket.tenant,
bucket_info.swift_ver_location, archive_binfo,
nullptr, nullptr);
if (ret < 0) {
return r;
}
-/** Write/overwrite a system object. */
-int RGWRados::put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, real_time *mtime,
- map<std::string, bufferlist>& attrs, int flags,
- const bufferlist& data,
- RGWObjVersionTracker *objv_tracker,
- real_time set_mtime /* 0 for don't set */)
-{
- rgw_rados_ref ref;
- int r = get_system_obj_ref(obj, &ref);
- if (r < 0)
- return r;
-
- ObjectWriteOperation op;
-
- if (flags & PUT_OBJ_EXCL) {
- if (!(flags & PUT_OBJ_CREATE))
- return -EINVAL;
- op.create(true); // exclusive create
- } else {
- op.remove();
- op.set_op_flags2(LIBRADOS_OP_FLAG_FAILOK);
- op.create(false);
- }
-
- if (objv_tracker) {
- objv_tracker->prepare_op_for_write(&op);
- }
-
- if (real_clock::is_zero(set_mtime)) {
- set_mtime = real_clock::now();
- }
-
- struct timespec mtime_ts = real_clock::to_timespec(set_mtime);
- op.mtime2(&mtime_ts);
- op.write_full(data);
-
- bufferlist acl_bl;
-
- for (map<string, bufferlist>::iterator iter = attrs.begin(); iter != attrs.end(); ++iter) {
- const string& name = iter->first;
- bufferlist& bl = iter->second;
-
- if (!bl.length())
- continue;
-
- op.setxattr(name.c_str(), bl);
- }
-
- r = ref.ioctx.operate(ref.oid, &op);
- if (r < 0) {
- return r;
- }
-
- if (objv_tracker) {
- objv_tracker->apply_write();
- }
-
- if (mtime) {
- *mtime = set_mtime;
- }
-
- return 0;
-}
-
-int RGWRados::put_system_obj_data(void *ctx, rgw_raw_obj& obj, const bufferlist& bl,
- off_t ofs, bool exclusive,
- RGWObjVersionTracker *objv_tracker)
-{
- rgw_rados_ref ref;
- int r = get_system_obj_ref(obj, &ref);
- if (r < 0) {
- return r;
- }
-
- ObjectWriteOperation op;
-
- if (exclusive)
- op.create(true);
-
- if (objv_tracker) {
- objv_tracker->prepare_op_for_write(&op);
- }
- if (ofs == -1) {
- op.write_full(bl);
- } else {
- op.write(ofs, bl);
- }
- r = ref.ioctx.operate(ref.oid, &op);
- if (r < 0)
- return r;
-
- if (objv_tracker) {
- objv_tracker->apply_write();
- }
- return 0;
-}
-
/**
* Write/overwrite an object to the bucket storage.
* bucket: the bucket to store the object in
{
RGWBucketInfo info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
int r;
if (bucket.bucket_id.empty()) {
r = get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL, &attrs);
RGWBucketInfo info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
int r = get_bucket_info(obj_ctx, bucket.tenant, bucket.name, info, NULL, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
int RGWRados::bucket_suspended(rgw_bucket& bucket, bool *suspended)
{
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
int ret = get_bucket_info(obj_ctx, bucket.tenant, bucket.name, bucket_info, NULL);
if (ret < 0) {
return ret;
return 0;
}
-int RGWRados::delete_system_obj(rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker)
-{
- if (obj.empty()) {
- ldout(cct, 1) << "delete_system_obj got empty object name "
- << obj << ", returning EINVAL" << dendl;
- return -EINVAL;
- }
- rgw_rados_ref ref;
- int r = get_raw_obj_ref(obj, &ref);
- if (r < 0) {
- return r;
- }
-
- ObjectWriteOperation op;
-
- if (objv_tracker) {
- objv_tracker->prepare_op_for_write(&op);
- }
-
- op.remove();
- r = ref.ioctx.operate(ref.oid, &op);
- if (r < 0)
- return r;
-
- return 0;
-}
-
int RGWRados::delete_obj_index(const rgw_obj& obj)
{
std::string oid, key;
get_obj_bucket_and_oid_loc(obj, oid, key);
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
RGWBucketInfo bucket_info;
int ret = get_bucket_instance_info(obj_ctx, obj.bucket, bucket_info, NULL, NULL);
return 0;
}
-/**
- * Get an attribute for a system object.
- * obj: the object to get attr
- * name: name of the attr to retrieve
- * dest: bufferlist to store the result in
- * Returns: 0 on success, -ERR# otherwise.
- */
-int RGWRados::system_obj_get_attr(rgw_raw_obj& obj, const char *name, bufferlist& dest)
-{
- rgw_rados_ref ref;
- int r = get_system_obj_ref(obj, &ref);
- if (r < 0) {
- return r;
- }
-
- ObjectReadOperation op;
-
- int rval;
- op.getxattr(name, &dest, &rval);
-
- r = ref.ioctx.operate(ref.oid, &op, NULL);
- if (r < 0)
- return r;
-
- return 0;
-}
-
int RGWRados::append_atomic_test(RGWObjectCtx *rctx,
const RGWBucketInfo& bucket_info, const rgw_obj& obj,
ObjectOperation& op, RGWObjState **pstate)
ctx.obj.invalidate(obj);
}
-void RGWRados::SystemObject::invalidate_state()
-{
- ctx.raw.invalidate(obj);
-}
-
int RGWRados::Object::prepare_atomic_modification(ObjectWriteOperation& op, bool reset_obj, const string *ptag,
const char *if_match, const char *if_nomatch, bool removal_op,
bool modify_tail)
return 0;
}
-int RGWRados::system_obj_set_attr(void *ctx, rgw_raw_obj& obj, const char *name, bufferlist& bl,
- RGWObjVersionTracker *objv_tracker)
-{
- map<string, bufferlist> attrs;
- attrs[name] = bl;
- return system_obj_set_attrs(ctx, obj, attrs, NULL, objv_tracker);
-}
-
-int RGWRados::system_obj_set_attrs(void *ctx, rgw_raw_obj& obj,
- map<string, bufferlist>& attrs,
- map<string, bufferlist>* rmattrs,
- RGWObjVersionTracker *objv_tracker)
-{
- rgw_rados_ref ref;
- int r = get_system_obj_ref(obj, &ref);
- if (r < 0) {
- return r;
- }
- ObjectWriteOperation op;
-
- if (objv_tracker) {
- objv_tracker->prepare_op_for_write(&op);
- }
-
- map<string, bufferlist>::iterator iter;
- if (rmattrs) {
- for (iter = rmattrs->begin(); iter != rmattrs->end(); ++iter) {
- const string& name = iter->first;
- op.rmxattr(name.c_str());
- }
- }
-
- for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
- const string& name = iter->first;
- bufferlist& bl = iter->second;
-
- if (!bl.length())
- continue;
-
- op.setxattr(name.c_str(), bl);
- }
-
- if (!op.size())
- return 0;
-
- bufferlist bl;
-
- r = ref.ioctx.operate(ref.oid, &op);
- if (r < 0)
- return r;
-
- return 0;
-}
-
/**
* Set an attr on an object.
* bucket: name of the bucket holding the object
return 0;
}
-int RGWRados::stat_system_obj(RGWObjectCtx& obj_ctx,
- RGWRados::SystemObject::Read::GetObjState& state,
- rgw_raw_obj& obj,
- map<string, bufferlist> *attrs,
- real_time *lastmod,
- uint64_t *obj_size,
- RGWObjVersionTracker *objv_tracker)
-{
- RGWRawObjState *astate = NULL;
-
- int r = get_system_obj_state(&obj_ctx, obj, &astate, objv_tracker);
- if (r < 0)
- return r;
-
- if (!astate->exists) {
- return -ENOENT;
- }
-
- if (attrs) {
- *attrs = astate->attrset;
- if (cct->_conf->subsys.should_gather<ceph_subsys_rgw, 20>()) {
- map<string, bufferlist>::iterator iter;
- for (iter = attrs->begin(); iter != attrs->end(); ++iter) {
- ldout(cct, 20) << "Read xattr: " << iter->first << dendl;
- }
- }
- }
-
- if (obj_size)
- *obj_size = astate->size;
- if (lastmod)
- *lastmod = astate->mtime;
-
- return 0;
-}
-
-
int RGWRados::Bucket::UpdateIndex::guard_reshard(BucketShard **pbs, std::function<int(BucketShard *)> call)
{
RGWRados *store = target->get_store();
return 0;
}
-int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker)
-{
- RGWRados *store = source->get_store();
- rgw_raw_obj& obj = source->get_obj();
-
- return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs,
- stat_params.lastmod, stat_params.obj_size, objv_tracker);
-}
-
int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op, const string *write_tag)
{
if (blind) {
return bl.length();
}
-int RGWRados::SystemObject::Read::GetObjState::get_ref(RGWRados *store, rgw_raw_obj& obj, rgw_rados_ref **pref)
-{
- if (!has_ref) {
- int r = store->get_raw_obj_ref(obj, &ref);
- if (r < 0) {
- return r;
- }
- has_ref = true;
- }
- *pref = &ref;
- return 0;
-
-}
-
-int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state,
- RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj,
- bufferlist& bl, off_t ofs, off_t end,
- map<string, bufferlist> *attrs,
- rgw_cache_entry_info *cache_info,
- boost::optional<obj_version>)
-{
- uint64_t len;
- ObjectReadOperation op;
-
- if (end < 0)
- len = 0;
- else
- len = end - ofs + 1;
-
- if (objv_tracker) {
- objv_tracker->prepare_op_for_read(&op);
- }
-
- ldout(cct, 20) << "rados->read ofs=" << ofs << " len=" << len << dendl;
- op.read(ofs, len, &bl, NULL);
-
- if (attrs) {
- op.getxattrs(attrs, NULL);
- }
-
- rgw_rados_ref *ref;
- int r = read_state.get_ref(this, obj, &ref);
- if (r < 0) {
- ldout(cct, 20) << "read_state.get_ref() on obj=" << obj << " returned " << r << dendl;
- return r;
- }
- r = ref->ioctx.operate(ref->oid, &op, NULL);
- if (r < 0) {
- ldout(cct, 20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl;
- return r;
- }
- ldout(cct, 20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl;
-
- uint64_t op_ver = ref->ioctx.get_last_version();
-
- if (read_state.last_ver > 0 &&
- read_state.last_ver != op_ver) {
- ldout(cct, 5) << "raced with an object write, abort" << dendl;
- return -ECANCELED;
- }
-
- read_state.last_ver = op_ver;
-
- return bl.length();
-}
-
-int RGWRados::SystemObject::Read::read(int64_t ofs, int64_t end, bufferlist& bl,
- RGWObjVersionTracker *objv_tracker,
- boost::optional<obj_version> refresh_version)
-{
- RGWRados *store = source->get_store();
- rgw_raw_obj& obj = source->get_obj();
-
- return store->get_system_obj(source->get_ctx(), state, objv_tracker, obj, bl,
- ofs, end, read_params.attrs,
- read_params.cache_info, refresh_version);
-}
-
-int RGWRados::SystemObject::Read::get_attr(const char *name, bufferlist& dest)
-{
- RGWRados *store = source->get_store();
- rgw_raw_obj& obj = source->get_obj();
-
- return store->system_obj_get_attr(obj, name, dest);
-}
-
struct get_obj_data;
struct get_obj_aio_data {
}
}
-int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info,
+int RGWRados::get_bucket_instance_info(RGWSysObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info,
real_time *pmtime, map<string, bufferlist> *pattrs)
{
size_t pos = meta_key.find(':');
return get_bucket_instance_from_oid(obj_ctx, oid, info, pmtime, pattrs);
}
-int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info,
+int RGWRados::get_bucket_instance_info(RGWSysObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info,
real_time *pmtime, map<string, bufferlist> *pattrs)
{
string oid;
return get_bucket_instance_from_oid(obj_ctx, oid, info, pmtime, pattrs);
}
-int RGWRados::get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, const string& oid, RGWBucketInfo& info,
+int RGWRados::get_bucket_instance_from_oid(RGWSysObjectCtx& obj_ctx, const string& oid, RGWBucketInfo& info,
real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info,
boost::optional<obj_version> refresh_version)
return 0;
}
-int RGWRados::get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx,
+int RGWRados::get_bucket_entrypoint_info(RGWSysObjectCtx& obj_ctx,
const string& tenant_name,
const string& bucket_name,
RGWBucketEntryPoint& entry_point,
return 0;
}
-int RGWRados::convert_old_bucket_info(RGWObjectCtx& obj_ctx,
+int RGWRados::convert_old_bucket_info(RGWSysObjectCtx& obj_ctx,
const string& tenant_name,
const string& bucket_name)
{
return 0;
}
-int RGWRados::_get_bucket_info(RGWObjectCtx& obj_ctx,
+int RGWRados::_get_bucket_info(RGWSysObjectCtx& obj_ctx,
const string& tenant,
const string& bucket_name,
RGWBucketInfo& info,
*pattrs = e.attrs;
/* chain to both bucket entry point and bucket instance */
- if (!binfo_cache->put(this, bucket_entry, &e, {&entry_cache_info, &cache_info})) {
+ if (!binfo_cache->put(svc.cache, bucket_entry, &e, {&entry_cache_info, &cache_info})) {
ldout(cct, 20) << "couldn't put binfo cache entry, might have raced with data changes" << dendl;
}
return 0;
}
-int RGWRados::get_bucket_info(RGWObjectCtx& obj_ctx,
+int RGWRados::get_bucket_info(RGWSysObjectCtx& obj_ctx,
const string& tenant, const string& bucket_name,
RGWBucketInfo& info,
real_time *pmtime, map<string, bufferlist> *pattrs)
ceph::real_time *pmtime,
map<string, bufferlist> *pattrs)
{
- RGWObjectCtx obj_ctx(this);
+ RGWSysObjectCtx obj_ctx = svc.sysobj->init_obj_ctx();
return _get_bucket_info(obj_ctx, info.bucket.tenant, info.bucket.name,
info, pmtime, pattrs, info.objv_tracker.read_version);
int RGWRados::update_containers_stats(map<string, RGWBucketEnt>& m)
{
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
map<string, RGWBucketEnt>::iterator iter;
for (iter = m.begin(); iter != m.end(); ++iter) {
{
vector<rgw_bucket_dir_header> headers;
RGWBucketInfo bucket_info;
- RGWObjectCtx obj_ctx(this);
+ auto obj_ctx = svc.sysobj->init_obj_ctx();
int ret = get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL);
if (ret < 0) {
return ret;
class RGWSI_SysObj;
class RGWSI_SysObj_Cache;
+class RGWSysObjectCtx;
+
/* flags for put_obj_meta() */
#define PUT_OBJ_CREATE 0x01
#define PUT_OBJ_EXCL 0x02
class RGWGetDirHeader_CB;
class RGWGetUserHeader_CB;
-class RGWChainedCache {
-public:
- virtual ~RGWChainedCache() {}
- virtual void chain_cb(const string& key, void *data) = 0;
- virtual void invalidate(const string& key) = 0;
- virtual void invalidate_all() = 0;
-
- struct Entry {
- RGWChainedCache *cache;
- const string& key;
- void *data;
-
- Entry(RGWChainedCache *_c, const string& _k, void *_d) : cache(_c), key(_k), data(_d) {}
- };
-};
-
template <class T, class S>
class RGWObjectCtxImpl {
RGWRados *store;
RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; }
- class SystemObject {
- RGWRados *store;
- RGWObjectCtx& ctx;
- rgw_raw_obj obj;
-
- public:
-
- SystemObject(RGWRados *_store, RGWObjectCtx& _ctx, rgw_raw_obj& _obj) :
- store(_store), ctx(_ctx), obj(_obj)
- {}
-
- void invalidate_state();
-
- RGWRados *get_store() { return store; }
- rgw_raw_obj& get_obj() { return obj; }
- RGWObjectCtx& get_ctx() { return ctx; }
-
- struct Read {
- RGWRados::SystemObject *source;
-
- struct GetObjState {
- rgw_rados_ref ref;
- bool has_ref{false};
- uint64_t last_ver{0};
-
- GetObjState() {}
-
- int get_ref(RGWRados *store, rgw_raw_obj& obj, rgw_rados_ref **pref);
- } state;
-
- struct StatParams {
- ceph::real_time *lastmod;
- uint64_t *obj_size;
- map<string, bufferlist> *attrs;
-
- StatParams() : lastmod(NULL), obj_size(NULL), attrs(NULL) {}
- } stat_params;
-
- struct ReadParams {
- rgw_cache_entry_info *cache_info{nullptr};
- map<string, bufferlist> *attrs;
-
- ReadParams() : attrs(NULL) {}
- } read_params;
-
- explicit Read(RGWRados::SystemObject *_source) : source(_source) {}
-
- int stat(RGWObjVersionTracker *objv_tracker);
- int read(int64_t ofs, int64_t end, bufferlist& bl, RGWObjVersionTracker *objv_tracker,
- boost::optional<obj_version> refresh_version = boost::none);
- int get_attr(const char *name, bufferlist& dest);
- };
- };
-
struct BucketShard {
RGWRados *store;
rgw_bucket bucket;
}; // class List
}; // class Bucket
- /** Write/overwrite an object to the bucket storage. */
- virtual int put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, ceph::real_time *mtime,
- map<std::string, bufferlist>& attrs, int flags,
- const bufferlist& data,
- RGWObjVersionTracker *objv_tracker,
- ceph::real_time set_mtime /* 0 for don't set */);
-
- virtual int put_system_obj_data(void *ctx, rgw_raw_obj& obj,
- const bufferlist& bl, off_t ofs, bool exclusive,
- RGWObjVersionTracker *objv_tracker = nullptr);
int aio_put_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl,
- off_t ofs, bool exclusive, void **handle);
-
- int put_system_obj(void *ctx, rgw_raw_obj& obj, const bufferlist& data, bool exclusive,
- ceph::real_time *mtime, map<std::string, bufferlist>& attrs, RGWObjVersionTracker *objv_tracker,
- ceph::real_time set_mtime) {
- int flags = PUT_OBJ_CREATE;
- if (exclusive)
- flags |= PUT_OBJ_EXCL;
-
- return put_system_obj_impl(obj, data.length(), mtime, attrs, flags, data, objv_tracker, set_mtime);
- }
+ off_t ofs, bool exclusive,
+ void **handle);
int aio_wait(void *handle);
bool aio_completed(void *handle);
const rgw_user& user, /* in */
RGWBucketInfo& bucket_info, /* in */
rgw_obj& obj); /* in */
- int swift_versioning_restore(RGWObjectCtx& obj_ctx, /* in/out */
+ int swift_versioning_restore(RGWSysObjectCtx& sysobj_ctx,
+ RGWObjectCtx& obj_ctx, /* in/out */
const rgw_user& user, /* in */
RGWBucketInfo& bucket_info, /* in */
rgw_obj& obj, /* in */
const ceph::real_time& expiration_time = ceph::real_time(),
rgw_zone_set *zones_trace = nullptr);
- /** Delete a raw object.*/
int delete_raw_obj(const rgw_raw_obj& obj);
- /* Delete a system object */
- virtual int delete_system_obj(rgw_raw_obj& src_obj, RGWObjVersionTracker *objv_tracker = NULL);
-
/** Remove an object from the bucket index */
int delete_obj_index(const rgw_obj& obj);
- /**
- * Get an attribute for a system object.
- * obj: the object to get attr
- * name: name of the attr to retrieve
- * dest: bufferlist to store the result in
- * Returns: 0 on success, -ERR# otherwise.
- */
- virtual int system_obj_get_attr(rgw_raw_obj& obj, const char *name, bufferlist& dest);
-
- int system_obj_set_attr(void *ctx, rgw_raw_obj& obj, const char *name, bufferlist& bl,
- RGWObjVersionTracker *objv_tracker);
- virtual int system_obj_set_attrs(void *ctx, rgw_raw_obj& obj,
- map<string, bufferlist>& attrs,
- map<string, bufferlist>* rmattrs,
- RGWObjVersionTracker *objv_tracker);
-
/**
* Set an attr on an object.
* bucket: name of the bucket holding the object
return get_obj_state(rctx, bucket_info, obj, state, true);
}
- virtual int stat_system_obj(RGWObjectCtx& obj_ctx,
- RGWRados::SystemObject::Read::GetObjState& state,
- rgw_raw_obj& obj,
- map<string, bufferlist> *attrs,
- ceph::real_time *lastmod,
- uint64_t *obj_size,
- RGWObjVersionTracker *objv_tracker);
-
- virtual int get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state,
- RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj,
- bufferlist& bl, off_t ofs, off_t end,
- map<string, bufferlist> *attrs,
- rgw_cache_entry_info *cache_info,
- boost::optional<obj_version> refresh_version =
- boost::none);
-
- virtual void register_chained_cache(RGWChainedCache *cache) {}
- virtual bool chain_cache_entry(std::initializer_list<rgw_cache_entry_info*> cache_info_entries,
- RGWChainedCache::Entry *chained_entry) { return false; }
-
int iterate_obj(RGWObjectCtx& ctx,
const RGWBucketInfo& bucket_info, const rgw_obj& obj,
off_t ofs, off_t end,
RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
rctx->obj.set_prefetch_data(obj);
}
- void set_prefetch_data(void *ctx, rgw_raw_obj& obj) {
- RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
- rctx->raw.set_prefetch_data(obj);
- }
-
int decode_policy(bufferlist& bl, ACLOwner *owner);
int get_bucket_stats(RGWBucketInfo& bucket_info, int shard_id, string *bucket_ver, string *master_ver,
map<RGWObjCategory, RGWStorageStats>& stats, string *max_marker, bool* syncstopped = NULL);
bool exclusive, RGWObjVersionTracker& objv_tracker, ceph::real_time mtime,
map<string, bufferlist> *pattrs);
int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, map<string, bufferlist> *pattrs);
- int get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name,
+ int get_bucket_entrypoint_info(RGWSysObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name,
RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker,
ceph::real_time *pmtime, map<string, bufferlist> *pattrs, rgw_cache_entry_info *cache_info = NULL,
boost::optional<obj_version> refresh_version = boost::none);
- int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
- int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
- int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, const string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs,
+ int get_bucket_instance_info(RGWSysObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
+ int get_bucket_instance_info(RGWSysObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
+ int get_bucket_instance_from_oid(RGWSysObjectCtx& obj_ctx, const string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info = NULL,
boost::optional<obj_version> refresh_version = boost::none);
- int convert_old_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name);
+ int convert_old_bucket_info(RGWSysObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name);
static void make_bucket_entry_name(const string& tenant_name, const string& bucket_name, string& bucket_entry);
private:
- int _get_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant,
+ int _get_bucket_info(RGWSysObjectCtx& obj_ctx, const string& tenant,
const string& bucket_name, RGWBucketInfo& info,
real_time *pmtime,
map<string, bufferlist> *pattrs,
virtual void call_zap();
public:
- int get_bucket_info(RGWObjectCtx& obj_ctx,
+ int get_bucket_info(RGWSysObjectCtx& obj_ctx,
const string& tenant_name, const string& bucket_name,
RGWBucketInfo& info,
ceph::real_time *pmtime, map<string, bufferlist> *pattrs = NULL);
};
-template <class T>
-class RGWChainedCacheImpl : public RGWChainedCache {
- ceph::timespan expiry;
- RWLock lock;
-
- std::unordered_map<std::string, std::pair<T, ceph::coarse_mono_time>> entries;
-
-public:
- RGWChainedCacheImpl() : lock("RGWChainedCacheImpl::lock") {}
-
- void init(RGWRados *store) {
- store->register_chained_cache(this);
- expiry = std::chrono::seconds(store->ctx()->_conf.get_val<uint64_t>(
- "rgw_cache_expiry_interval"));
- }
-
- boost::optional<T> find(const string& key) {
- RWLock::RLocker rl(lock);
- auto iter = entries.find(key);
- if (iter == entries.end()) {
- return boost::none;
- }
- if (expiry.count() &&
- (ceph::coarse_mono_clock::now() - iter->second.second) > expiry) {
- return boost::none;
- }
-
- return iter->second.first;
- }
-
- bool put(RGWRados *store, const string& key, T *entry,
- std::initializer_list<rgw_cache_entry_info *> cache_info_entries) {
- Entry chain_entry(this, key, entry);
-
- /* we need the store cache to call us under its lock to maintain lock ordering */
- return store->chain_cache_entry(cache_info_entries, &chain_entry);
- }
-
- void chain_cb(const string& key, void *data) override {
- T *entry = static_cast<T *>(data);
- RWLock::WLocker wl(lock);
- entries[key].first = *entry;
- if (expiry.count() > 0) {
- entries[key].second = ceph::coarse_mono_clock::now();
- }
- }
-
- void invalidate(const string& key) override {
- RWLock::WLocker wl(lock);
- entries.erase(key);
- }
-
- void invalidate_all() override {
- RWLock::WLocker wl(lock);
- entries.clear();
- }
-}; /* RGWChainedCacheImpl */
-
-
#define MP_META_SUFFIX ".meta"
class RGWMPObj {
#include "common/dout.h"
#include "services/svc_zone.h"
+#include "services/svc_sys_obj.h"
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
ldout(store->ctx(), 20) << __func__ << " resharding " <<
entry.bucket_name << dendl;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
rgw_bucket bucket;
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
#include "include/str_list.h"
+#include "services/svc_sys_obj.h"
+
#define dout_subsys ceph_subsys_rgw
class RGWOp_Bucket_Info : public RGWRESTOp {
if (use_http_params) {
RGWBucketInfo bucket_info;
map<string, bufferlist> attrs;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
http_ret = store->get_bucket_info(obj_ctx, uid.tenant, bucket, bucket_info, NULL, &attrs);
if (http_ret < 0) {
return;
RGWBucketInfo bucket_info;
unsigned max_entries;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-
if (bucket_name.empty() && bucket_instance.empty()) {
dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl;
http_ret = -EINVAL;
}
if (!bucket_instance.empty()) {
- http_ret = store->get_bucket_instance_info(obj_ctx, bucket_instance, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, bucket_instance, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
return;
}
} else { /* !bucket_name.empty() */
- http_ret = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_info(*s->sysobj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket info for bucket=" << bucket_name << dendl;
return;
bucket_instance = s->info.args.get("bucket-instance");
RGWBucketInfo bucket_info;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-
if (bucket_name.empty() && bucket_instance.empty()) {
dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl;
http_ret = -EINVAL;
}
if (!bucket_instance.empty()) {
- http_ret = store->get_bucket_instance_info(obj_ctx, bucket_instance, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, bucket_instance, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
return;
}
} else { /* !bucket_name.empty() */
- http_ret = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_info(*s->sysobj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket info for bucket=" << bucket_name << dendl;
return;
RGWBucketInfo bucket_info;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-
http_ret = 0;
if ((bucket_name.empty() && bucket_instance.empty()) ||
end_marker.empty()) {
}
if (!bucket_instance.empty()) {
- http_ret = store->get_bucket_instance_info(obj_ctx, bucket_instance, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_instance_info(*s->sysobj_ctx, bucket_instance, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance << dendl;
return;
}
} else { /* !bucket_name.empty() */
- http_ret = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
+ http_ret = store->get_bucket_info(*s->sysobj_ctx, tenant_name, bucket_name, bucket_info, NULL, NULL);
if (http_ret < 0) {
dout(5) << "could not get bucket info for bucket=" << bucket_name << dendl;
return;
}
// read the bucket instance info for num_shards
- RGWObjectCtx ctx(store);
+ auto ctx = store->svc.sysobj->init_obj_ctx();
RGWBucketInfo info;
http_ret = store->get_bucket_instance_info(ctx, bucket, info, nullptr, nullptr);
if (http_ret < 0) {
if (!s->length)
return -ERR_LENGTH_REQUIRED;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
map<string, bufferlist> src_attrs;
size_t pos;
int ret;
return ret;
}
}
- ret = store->get_bucket_info(obj_ctx,
+ ret = store->get_bucket_info(*s->sysobj_ctx,
copy_source_tenant_name,
copy_source_bucket_name,
copy_source_bucket_info,
if (!(s->prot_flags & RGW_REST_WEBSITE))
return 0;
- RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- int ret = store->get_bucket_info(obj_ctx, s->bucket_tenant,
+ int ret = store->get_bucket_info(*s->sysobj_ctx, s->bucket_tenant,
s->bucket_name, s->bucket_info, NULL,
&s->bucket_attrs);
if (ret < 0) {
/* Need to get user info of bucket owner. */
RGWBucketInfo bucket_info;
- int ret = store->get_bucket_info(*static_cast<RGWObjectCtx *>(s->obj_ctx),
+ int ret = store->get_bucket_info(*s->sysobj_ctx,
bucket_tenant, bucket_name,
bucket_info, nullptr);
if (ret < 0) {
#include "rgw_role.h"
#include "services/svc_zone.h"
+#include "services/svc_sys_obj.h"
#define dout_subsys ceph_subsys_rgw
auto& pool = store->svc.zone->get_zone_params().roles_pool;
string oid = tenant + get_names_oid_prefix() + role_name;
bufferlist bl;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
if (ret < 0) {
auto& pool = store->svc.zone->get_zone_params().roles_pool;
string oid = get_info_oid_prefix() + id;
bufferlist bl;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
if (ret < 0) {
auto& pool = store->svc.zone->get_zone_params().roles_pool;
string oid = tenant + get_names_oid_prefix() + name;
bufferlist bl;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL);
if (ret < 0) {
/* Need to get user info of bucket owner. */
RGWBucketInfo bucket_info;
- int ret = store->get_bucket_info(*static_cast<RGWObjectCtx *>(s->obj_ctx),
+ int ret = store->get_bucket_info(*s->sysobj_ctx,
bucket_tenant, bucket_name,
bucket_info, nullptr);
if (ret < 0) {
yield {
set_status("writing sync status");
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store,
+ call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sync_env->status_oid()),
status));
}
marker.timestamp = info.last_update;
RGWRados *store = sync_env->store;
spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados,
- store,
+ store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sync_env->shard_obj_name(i)),
marker), true);
}
set_status("changing sync state: build full sync maps");
status.state = rgw_meta_sync_info::StateBuildingFullSyncMaps;
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store,
+ call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sync_env->status_oid()),
status));
}
using CR = RGWSimpleRadosReadCR<rgw_meta_sync_marker>;
rgw_raw_obj obj{env->store->svc.zone->get_zone_params().log_pool,
env->shard_obj_name(shard_id)};
- spawn(new CR(env->async_rados, env->store, obj, &markers[shard_id]), false);
+ spawn(new CR(env->async_rados, env->store->svc.sysobj, obj, &markers[shard_id]), false);
shard_id++;
return true;
}
bool empty_on_enoent = false; // fail on ENOENT
rgw_raw_obj obj{sync_env->store->svc.zone->get_zone_params().log_pool,
sync_env->status_oid()};
- call(new ReadInfoCR(sync_env->async_rados, sync_env->store, obj,
+ call(new ReadInfoCR(sync_env->async_rados, sync_env->store->svc.sysobj, obj,
&sync_status->sync_info, empty_on_enoent));
}
if (retcode < 0) {
int shard_id = (int)iter->first;
rgw_meta_sync_marker& marker = iter->second;
marker.total_entries = entries_index->get_total_entries(shard_id);
- spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, sync_env->store,
+ spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, sync_env->store->svc.sysobj,
rgw_raw_obj(sync_env->store->svc.zone->get_zone_params().log_pool, sync_env->shard_obj_name(shard_id)),
marker), true);
}
tn->log(20, SSTR("new marker=" << new_marker));
RGWRados *store = sync_env->store;
return new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados,
- store,
+ store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, marker_oid),
sync_marker);
}
ldpp_dout(sync_env->dpp, 4) << *this << ": saving marker pos=" << temp_marker->marker << " realm_epoch=" << realm_epoch << dendl;
using WriteMarkerCR = RGWSimpleRadosWriteCR<rgw_meta_sync_marker>;
- yield call(new WriteMarkerCR(sync_env->async_rados, sync_env->store,
+ yield call(new WriteMarkerCR(sync_env->async_rados, sync_env->store->svc.sysobj,
rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
*temp_marker));
}
RGWCoroutine *alloc_finisher_cr() override {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store,
+ return new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store->svc.sysobj,
rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
&sync_marker);
}
sync_status.sync_info.period = cursor.get_period().get_id();
sync_status.sync_info.realm_epoch = cursor.get_epoch();
yield call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados,
- sync_env->store,
+ sync_env->store->svc.sysobj,
rgw_raw_obj(pool, sync_env->status_oid()),
sync_status.sync_info));
}
int RGWRemoteMetaLog::store_sync_info(const rgw_meta_sync_info& sync_info)
{
tn->log(20, "store sync info");
- return run(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(async_rados, store,
+ return run(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(async_rados, store->svc.sysobj,
rgw_raw_obj(store->svc.zone->get_zone_params().log_pool, sync_env.status_oid()),
sync_info));
}
// read BucketTrimStatus for marker position
set_status("reading trim status");
using ReadStatus = RGWSimpleRadosReadCR<BucketTrimStatus>;
- yield call(new ReadStatus(store->get_async_rados(), store, obj,
+ yield call(new ReadStatus(store->get_async_rados(), store->svc.sysobj, obj,
&status, true, &objv));
if (retcode < 0) {
ldout(cct, 10) << "failed to read bilog trim status: "
status.marker = std::move(last_cold_marker);
ldout(cct, 20) << "writing bucket trim marker=" << status.marker << dendl;
using WriteStatus = RGWSimpleRadosWriteCR<BucketTrimStatus>;
- yield call(new WriteStatus(store->get_async_rados(), store, obj,
+ yield call(new WriteStatus(store->get_async_rados(), store->svc.sysobj, obj,
status, &objv));
if (retcode < 0) {
ldout(cct, 4) << "failed to write updated trim status: "
int operate() override {
reenter(this) {
- yield call(new RGWSimpleRadosReadCR<rgw_sync_aws_multipart_upload_info>(sync_env->async_rados, sync_env->store,
+ yield call(new RGWSimpleRadosReadCR<rgw_sync_aws_multipart_upload_info>(sync_env->async_rados, sync_env->store->svc.sysobj,
status_obj, &status, false));
if (retcode < 0 && retcode != -ENOENT) {
return set_cr_error(ret_err);
}
- yield call(new RGWSimpleRadosWriteCR<rgw_sync_aws_multipart_upload_info>(sync_env->async_rados, sync_env->store, status_obj, status));
+ yield call(new RGWSimpleRadosWriteCR<rgw_sync_aws_multipart_upload_info>(sync_env->async_rados, sync_env->store->svc.sysobj, status_obj, status));
if (retcode < 0) {
ldout(sync_env->cct, 0) << "ERROR: failed to store multipart upload state, retcode=" << retcode << dendl;
/* continue with upload anyway */
#include "rgw_rados.h"
#include "rgw_tools.h"
+#include "services/svc_sys_obj.h"
+
#define dout_subsys ceph_subsys_rgw
#define READ_CHUNK_LEN (512 * 1024)
static std::map<std::string, std::string>* ext_mime_map;
-int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, const bufferlist& data, bool exclusive,
+int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs)
{
map<string,bufferlist> no_attrs;
- if (!pattrs)
+ if (!pattrs) {
pattrs = &no_attrs;
+ }
rgw_raw_obj obj(pool, oid);
- int ret = rgwstore->put_system_obj(NULL, obj, data, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
+ auto obj_ctx = rgwstore->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ int ret = sysobj.wop()
+ .set_objv_tracker(objv_tracker)
+ .set_exclusive(exclusive)
+ .set_mtime(set_mtime)
+ .set_attrs(*pattrs)
+ .write(data);
if (ret == -ENOENT) {
ret = rgwstore->create_pool(pool);
- if (ret >= 0)
- ret = rgwstore->put_system_obj(NULL, obj, data, exclusive, NULL, *pattrs, objv_tracker, set_mtime);
+ if (ret >= 0) {
+ ret = sysobj.wop()
+ .set_objv_tracker(objv_tracker)
+ .set_exclusive(exclusive)
+ .set_mtime(set_mtime)
+ .set_attrs(*pattrs)
+ .write(data);
+ }
}
return ret;
}
-int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
+int rgw_get_system_obj(RGWRados *rgwstore, RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info, boost::optional<obj_version> refresh_version)
{
}
do {
- RGWRados::SystemObject source(rgwstore, obj_ctx, obj);
- RGWRados::SystemObject::Read rop(&source);
+ auto sysobj = obj_ctx.get_obj(obj);
+ auto rop = sysobj.rop();
- rop.stat_params.attrs = pattrs;
- rop.stat_params.lastmod = pmtime;
-
- int ret = rop.stat(objv_tracker);
+ int ret = rop.set_attrs(pattrs)
+ .set_last_mod(pmtime)
+ .set_objv_tracker(objv_tracker)
+ .stat();
if (ret < 0)
return ret;
- rop.read_params.cache_info = cache_info;
-
- ret = rop.read(0, request_len - 1, bl, objv_tracker, refresh_version);
+ ret = rop.set_cache_info(cache_info)
+ .set_refresh_version(refresh_version)
+ .read(&bl);
if (ret == -ECANCELED) {
/* raced, restart */
if (!original_readv.empty()) {
if (objv_tracker) {
objv_tracker->read_version.clear();
}
- source.invalidate_state();
+ sysobj.invalidate();
continue;
}
if (ret < 0)
int rgw_delete_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid,
RGWObjVersionTracker *objv_tracker)
{
+ auto obj_ctx = rgwstore->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(rgw_raw_obj{pool, oid});
rgw_raw_obj obj(pool, oid);
- return rgwstore->delete_system_obj(obj, objv_tracker);
+ return sysobj.wop()
+ .set_objv_tracker(objv_tracker)
+ .remove();
}
void parse_mime_map_line(const char *start, const char *end)
#include "rgw_common.h"
class RGWRados;
-class RGWObjectCtx;
+class RGWSysObjectCtx;
struct RGWObjVersionTracker;
struct obj_version;
-int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, const bufferlist& data, bool exclusive,
+int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive,
RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs = NULL);
-int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
+int rgw_get_system_obj(RGWRados *rgwstore, RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, real_time *pmtime, map<string, bufferlist> *pattrs = NULL,
rgw_cache_entry_info *cache_info = NULL,
boost::optional<obj_version> refresh_version = boost::none);
#include "rgw_quota.h"
#include "services/svc_zone.h"
+#include "services/svc_sys_obj.h"
+#include "services/svc_sys_obj_cache.h"
#define dout_subsys ceph_subsys_rgw
bool is_truncated = false;
string marker;
int ret;
- RGWObjectCtx obj_ctx(store);
+ RGWSysObjectCtx obj_ctx = store->svc.sysobj->init_obj_ctx();
do {
RGWUserBuckets user_buckets;
user_info_entry e;
bufferlist bl;
RGWUID uid;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
int ret = rgw_get_system_obj(store, obj_ctx, pool, key, bl, NULL, &e.mtime);
if (ret < 0)
return -EIO;
}
- uinfo_cache.put(store, key, &e, { &cache_info });
+ uinfo_cache.put(store->svc.cache, key, &e, { &cache_info });
info = e.info;
if (objv_tracker)
bufferlist bl;
RGWUID user_id;
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
string oid = uid.to_str();
int ret = rgw_get_system_obj(store, obj_ctx, store->svc.zone->get_zone_params().user_uid_pool, oid, bl, objv_tracker, pmtime, pattrs, cache_info);
if (ret < 0) {
map<string, bufferlist>& attrs,
RGWObjVersionTracker *objv_tracker)
{
- RGWObjectCtx obj_ctx(store);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
rgw_raw_obj obj(store->svc.zone->get_zone_params().user_uid_pool, user_id.to_str());
- RGWRados::SystemObject src(store, obj_ctx, obj);
- RGWRados::SystemObject::Read rop(&src);
+ auto src = obj_ctx.get_obj(obj);
- rop.stat_params.attrs = &attrs;
- return rop.stat(objv_tracker);
+ return src.rop()
+ .set_attrs(&attrs)
+ .set_objv_tracker(objv_tracker)
+ .stat();
}
int rgw_remove_key_index(RGWRados *store, RGWAccessKey& access_key)
{
rgw_raw_obj obj(store->svc.zone->get_zone_params().user_keys_pool, access_key.id);
- int ret = store->delete_system_obj(obj);
- return ret;
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.wop().remove();
}
int rgw_remove_uid_index(RGWRados *store, rgw_user& uid)
return 0;
}
rgw_raw_obj obj(store->svc.zone->get_zone_params().user_email_pool, email);
- return store->delete_system_obj(obj);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.wop().remove();
}
int rgw_remove_swift_name_index(RGWRados *store, string& swift_name)
{
rgw_raw_obj obj(store->svc.zone->get_zone_params().user_swift_pool, swift_name);
- int ret = store->delete_system_obj(obj);
- return ret;
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(obj);
+ return sysobj.wop().remove();
}
/**
rgw_get_buckets_obj(info.user_id, buckets_obj_id);
rgw_raw_obj uid_bucks(store->svc.zone->get_zone_params().user_uid_pool, buckets_obj_id);
ldout(store->ctx(), 10) << "removing user buckets index" << dendl;
- ret = store->delete_system_obj(uid_bucks);
+ auto obj_ctx = store->svc.sysobj->init_obj_ctx();
+ auto sysobj = obj_ctx.get_obj(uid_bucks);
+ ret = sysobj.wop().remove();
if (ret < 0 && ret != -ENOENT) {
ldout(store->ctx(), 0) << "ERROR: could not remove " << info.user_id << ":" << uid_bucks << ", should be fixed (err=" << ret << ")" << dendl;
return ret;
void rgw_user_init(RGWRados *store)
{
- uinfo_cache.init(store);
+ uinfo_cache.init(store->svc.cache);
user_meta_handler = new RGWUserMetadataHandler;
store->meta_mgr->register_handler(user_meta_handler);
return 0;
}
-void RGWSI_SysObj::Obj::invalidate_state()
+void RGWSI_SysObj::Obj::invalidate()
{
ctx.invalidate(obj);
}
return svc->set_attrs(obj, attrs, nullptr, objv_tracker);
}
+int RGWSI_SysObj::Obj::WOp::write_attr(const char *name, bufferlist& bl)
+{
+ RGWSI_SysObj_Core *svc = source.core_svc;
+ rgw_raw_obj& obj = source.get_obj();
+
+ map<string, bufferlist> m;
+ m[name] = bl;
+
+ return svc->set_attrs(obj, m, nullptr, objv_tracker);
+}
+
int RGWSI_SysObj::Pool::Op::list_prefixed_objs(const string& prefix, list<string> *result)
{
bool is_truncated;
ctx(_ctx),
obj(_obj) {}
- void invalidate_state();
+ void invalidate();
RGWSysObjectCtx& get_ctx() {
return ctx;
uint64_t *obj_size{nullptr};
rgw_cache_entry_info *cache_info{nullptr};
+ ROp& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
+ objv_tracker = _objv_tracker;
+ return *this;
+ }
+
ROp& set_last_mod(ceph::real_time *_lastmod) {
lastmod = _lastmod;
return *this;
return *this;
}
- ROp& set_refresh_version(const obj_version& rf) {
+ ROp& set_refresh_version(boost::optional<obj_version>& rf) {
refresh_version = rf;
return *this;
}
ceph::real_time *pmtime{nullptr};
bool exclusive{false};
+ WOp& set_objv_tracker(RGWObjVersionTracker *_objv_tracker) {
+ objv_tracker = _objv_tracker;
+ return *this;
+ }
+
+ WOp& set_attrs(map<string, bufferlist>& _attrs) {
+ attrs = _attrs;
+ return *this;
+ }
+
WOp& set_attrs(map<string, bufferlist>&& _attrs) {
attrs = _attrs;
return *this;
int write_data(bufferlist& bl); /* write data only */
int write_attrs(); /* write attrs only */
+ int write_attr(const char *name, bufferlist& bl); /* write attrs only */
};
struct OmapOp {
int call_zap();
};
+template <class T>
+class RGWChainedCacheImpl : public RGWChainedCache {
+ RGWSI_SysObj_Cache *svc{nullptr};
+ ceph::timespan expiry;
+ RWLock lock;
+
+ std::unordered_map<std::string, std::pair<T, ceph::coarse_mono_time>> entries;
+
+public:
+ RGWChainedCacheImpl() : lock("RGWChainedCacheImpl::lock") {}
+
+ void init(RGWSI_SysObj_Cache *svc) {
+ svc->register_chained_cache(this);
+ expiry = std::chrono::seconds(svc->ctx()->_conf.get_val<uint64_t>(
+ "rgw_cache_expiry_interval"));
+ }
+
+ boost::optional<T> find(const string& key) {
+ RWLock::RLocker rl(lock);
+ auto iter = entries.find(key);
+ if (iter == entries.end()) {
+ return boost::none;
+ }
+ if (expiry.count() &&
+ (ceph::coarse_mono_clock::now() - iter->second.second) > expiry) {
+ return boost::none;
+ }
+
+ return iter->second.first;
+ }
+
+ bool put(RGWSI_SysObj_Cache *svc, const string& key, T *entry,
+ std::initializer_list<rgw_cache_entry_info *> cache_info_entries) {
+ Entry chain_entry(this, key, entry);
+
+ /* we need the svc cache to call us under its lock to maintain lock ordering */
+ return svc->chain_cache_entry(cache_info_entries, &chain_entry);
+ }
+
+ void chain_cb(const string& key, void *data) override {
+ T *entry = static_cast<T *>(data);
+ RWLock::WLocker wl(lock);
+ entries[key].first = *entry;
+ if (expiry.count() > 0) {
+ entries[key].second = ceph::coarse_mono_clock::now();
+ }
+ }
+
+ void invalidate(const string& key) override {
+ RWLock::WLocker wl(lock);
+ entries.erase(key);
+ }
+
+ void invalidate_all() override {
+ RWLock::WLocker wl(lock);
+ entries.clear();
+ }
+}; /* RGWChainedCacheImpl */
+
#endif