From 5fff6371d8e1701f33c2789f329255829d13cf1b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 10 Oct 2016 15:09:35 -0700 Subject: [PATCH] rgw: more fixes and adjustments following rgw_pool, rgw_raw_obj Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_admin.cc | 5 +- src/rgw/rgw_bucket.cc | 9 +- src/rgw/rgw_common.h | 21 +++- src/rgw/rgw_cr_rados.cc | 106 ++++++++--------- src/rgw/rgw_cr_rados.h | 103 +++++++--------- src/rgw/rgw_data_sync.cc | 127 ++++++++++---------- src/rgw/rgw_data_sync.h | 9 +- src/rgw/rgw_dencoder.cc | 27 ++++- src/rgw/rgw_json_enc.cc | 107 +++++++++++------ src/rgw/rgw_log.cc | 2 +- src/rgw/rgw_metadata.cc | 24 ++-- src/rgw/rgw_op.cc | 189 ++++++++++++++---------------- src/rgw/rgw_rados.cc | 105 +++++++++-------- src/rgw/rgw_rados.h | 79 +++++++------ src/rgw/rgw_replica_log.cc | 2 +- src/rgw/rgw_rest_swift.cc | 6 +- src/rgw/rgw_sync.cc | 83 +++++++------ src/rgw/rgw_sync.h | 2 +- src/rgw/rgw_torrent.cc | 8 +- src/rgw/rgw_user.cc | 20 ++-- src/test/rgw/test_rgw_manifest.cc | 12 +- src/test/rgw/test_rgw_obj.cc | 12 +- 22 files changed, 569 insertions(+), 489 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 0612cfc691c5c..0961543ce2f31 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1023,8 +1023,7 @@ int bucket_stats(rgw_bucket& bucket, int shard_id, Formatter *formatter) } formatter->open_object_section("stats"); formatter->dump_string("bucket", bucket.name); - formatter->dump_string("pool", bucket.data_pool); - formatter->dump_string("index_pool", bucket.index_pool); + ::encode_json("placement", bucket.placement, formatter); formatter->dump_string("id", bucket.bucket_id); formatter->dump_string("marker", bucket.marker); @@ -1362,7 +1361,7 @@ int check_obj_locator_underscore(RGWBucketInfo& bucket_info, rgw_obj& obj, rgw_o string oid; string locator; - get_obj_bucket_and_oid_loc(obj, obj.bucket, oid, locator); + get_obj_bucket_and_oid_loc(obj, oid, locator); f->dump_string("oid", oid); f->dump_string("locator", locator); diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index f7f36c9383045..88478207ec906 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -819,12 +819,11 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) return -EINVAL; } - std::string no_oid; - std::string display_name = op_state.get_user_display_name(); rgw_bucket bucket = op_state.get_bucket(); - rgw_obj obj(bucket, no_oid); + const rgw_pool& root_pool = store->get_zone_params().domain_root; + rgw_raw_obj obj(root_pool, bucket.name); RGWObjVersionTracker objv_tracker; map attrs; @@ -886,9 +885,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg) policy_instance.encode(aclbl); string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key; - rgw_bucket bucket_instance; - bucket_instance.name = oid_bucket_instance; - rgw_obj obj_bucket_instance(bucket_instance, no_oid); + rgw_raw_obj obj_bucket_instance(root_pool, oid_bucket_instance); r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker); r = rgw_link_bucket(store, user_info.user_id, bucket_info.bucket, real_time()); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index bb677c1e3f67b..e54bd1b10dbcd 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -766,15 +766,22 @@ struct rgw_pool { void decode_from_bucket(bufferlist::iterator& bl); void decode(bufferlist::iterator& bl) { - uint64_t start_off = bl.get_off(); DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl); + + ::decode(name, bl); + if (struct_v < 10) { - bl.seek(start_off); - decode_from_bucket(bl); - return; + + /* + * note that rgw_pool can be used where rgw_bucket was used before + * therefore we inherit rgw_bucket's old versions. However, we only + * need the first field from rgw_bucket. unless we add more fields + * in which case we'll need to look at struct_v, and check the actual + * version. Anything older than 10 needs to be treated as old rgw_bucket + */ + } - ::decode(name, bl); DECODE_FINISH(bl); } @@ -817,6 +824,7 @@ struct rgw_data_placement_target { }; void dump(Formatter *f) const; + void decode_json(JSONObj *obj); }; inline ostream& operator<<(ostream& out, const rgw_pool& p) { @@ -872,6 +880,9 @@ struct rgw_raw_obj { } return (r < 0); } + + void dump(Formatter *f) const; + void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_raw_obj) diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 5d7e19de87c5f..68d0c64ab2742 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -89,7 +89,7 @@ int RGWAsyncGetSystemObj::_send_request() } RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, bufferlist *_pbl, off_t _ofs, off_t _end) : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_obj_ctx), objv_tracker(_objv_tracker), obj(_obj), pbl(_pbl), pattrs(NULL), ofs(_ofs), end(_end) @@ -98,7 +98,6 @@ RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletio int RGWSimpleRadosReadAttrsCR::send_request() { - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(), store, &obj_ctx, NULL, obj, @@ -121,7 +120,7 @@ int RGWAsyncPutSystemObj::_send_request() } RGWAsyncPutSystemObj::RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - rgw_obj& _obj, bool _exclusive, + const rgw_raw_obj& _obj, bool _exclusive, bufferlist& _bl) : RGWAsyncRadosRequest(caller, cn), store(_store), obj(_obj), exclusive(_exclusive), bl(_bl) @@ -134,7 +133,7 @@ int RGWAsyncPutSystemObjAttrs::_send_request() } RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, map *_attrs) : RGWAsyncRadosRequest(caller, cn), store(_store), objv_tracker(_objv_tracker), obj(_obj), attrs(_attrs) @@ -142,20 +141,19 @@ RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAi } -RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid, +RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, const rgw_raw_obj& _obj, uint64_t _window_size) : RGWConsumerCR(_store->ctx()), async_rados(_async_rados), - store(_store), pool(_pool), oid(_oid), going_down(false), num_pending_entries(0), window_size(_window_size), total_entries(0) + store(_store), obj(_obj), going_down(false), num_pending_entries(0), window_size(_window_size), total_entries(0) { } int RGWAsyncLockSystemObj::_send_request() { - librados::IoCtx ioctx; - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(obj.bucket.name.c_str(), ioctx); /* system object only! */ + rgw_rados_ref ref; + int r = store->get_raw_obj_ref(obj, &ref); if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open pool (" << obj.bucket.name << ") ret=" << r << dendl; + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; return r; } @@ -165,11 +163,11 @@ int RGWAsyncLockSystemObj::_send_request() l.set_cookie(cookie); l.set_renew(true); - return l.lock_exclusive(&ioctx, obj.get_object()); + return l.lock_exclusive(&ref.ioctx, ref.oid); } RGWAsyncLockSystemObj::RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, const string& _name, const string& _cookie, uint32_t _duration_secs) : RGWAsyncRadosRequest(caller, cn), store(_store), obj(_obj), lock_name(_name), @@ -180,11 +178,10 @@ RGWAsyncLockSystemObj::RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioComplet int RGWAsyncUnlockSystemObj::_send_request() { - librados::IoCtx ioctx; - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(obj.bucket.name.c_str(), ioctx); /* system object only! */ + rgw_rados_ref ref; + int r = store->get_raw_obj_ref(obj, &ref); if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open pool (" << obj.bucket.name << ") ret=" << r << dendl; + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; return r; } @@ -192,11 +189,11 @@ int RGWAsyncUnlockSystemObj::_send_request() l.set_cookie(cookie); - return l.unlock(&ioctx, obj.get_object()); + return l.unlock(&ref.ioctx, ref.oid); } RGWAsyncUnlockSystemObj::RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, const string& _name, const string& _cookie) : RGWAsyncRadosRequest(caller, cn), store(_store), obj(_obj), lock_name(_name), cookie(_cookie) @@ -205,14 +202,14 @@ RGWAsyncUnlockSystemObj::RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCom RGWRadosSetOmapKeysCR::RGWRadosSetOmapKeysCR(RGWRados *_store, - rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, map& _entries) : RGWSimpleCoroutine(_store->ctx()), store(_store), entries(_entries), - pool(_pool), oid(_oid), cn(NULL) + obj(_obj), cn(NULL) { stringstream& s = set_description(); - s << "set omap keys dest=" << pool.name << "/" << oid << " keys=[" << s.str() << "]"; + s << "set omap keys dest=" << obj << " keys=[" << s.str() << "]"; for (auto i = entries.begin(); i != entries.end(); ++i) { if (i != entries.begin()) { s << ", "; @@ -231,11 +228,10 @@ RGWRadosSetOmapKeysCR::~RGWRadosSetOmapKeysCR() int RGWRadosSetOmapKeysCR::send_request() { - librados::IoCtx ioctx; - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */ + rgw_rados_ref ref; + int r = store->get_raw_obj_ref(obj, &ref); if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl; + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; return r; } @@ -246,7 +242,7 @@ int RGWRadosSetOmapKeysCR::send_request() cn = stack->create_completion_notifier(); cn->get(); - return ioctx.aio_operate(oid, cn->completion(), &op); + return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op); } int RGWRadosSetOmapKeysCR::request_complete() @@ -259,15 +255,15 @@ int RGWRadosSetOmapKeysCR::request_complete() } RGWRadosGetOmapKeysCR::RGWRadosGetOmapKeysCR(RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const string& _marker, map *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()), store(_store), marker(_marker), entries(_entries), max_entries(_max_entries), rval(0), - pool(_pool), oid(_oid), cn(NULL) + obj(_obj), cn(NULL) { - set_description() << "set omap keys dest=" << pool.name << "/" << oid << " marker=" << marker; + set_description() << "set omap keys dest=" << obj << " marker=" << marker; } RGWRadosGetOmapKeysCR::~RGWRadosGetOmapKeysCR() @@ -275,10 +271,10 @@ RGWRadosGetOmapKeysCR::~RGWRadosGetOmapKeysCR() } int RGWRadosGetOmapKeysCR::send_request() { - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */ + rgw_rados_ref ref; + int r = store->get_raw_obj_ref(obj, &ref); if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl; + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; return r; } @@ -288,17 +284,17 @@ int RGWRadosGetOmapKeysCR::send_request() { op.omap_get_vals2(marker, max_entries, entries, nullptr, &rval); cn = stack->create_completion_notifier(); - return ioctx.aio_operate(oid, cn->completion(), &op, NULL); + return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op, NULL); } RGWRadosRemoveOmapKeysCR::RGWRadosRemoveOmapKeysCR(RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const set& _keys) : RGWSimpleCoroutine(_store->ctx()), store(_store), keys(_keys), - pool(_pool), oid(_oid), cn(NULL) + obj(_obj), cn(NULL) { - set_description() << "remove omap keys dest=" << pool.name << "/" << oid << " keys=" << keys; + set_description() << "remove omap keys dest=" << obj << " keys=" << keys; } RGWRadosRemoveOmapKeysCR::~RGWRadosRemoveOmapKeysCR() @@ -306,10 +302,10 @@ RGWRadosRemoveOmapKeysCR::~RGWRadosRemoveOmapKeysCR() } int RGWRadosRemoveOmapKeysCR::send_request() { - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */ + rgw_rados_ref ref; + int r = store->get_raw_obj_ref(obj, &ref); if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl; + lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl; return r; } @@ -319,11 +315,12 @@ int RGWRadosRemoveOmapKeysCR::send_request() { op.omap_rm_keys(keys); cn = stack->create_completion_notifier(); - return ioctx.aio_operate(oid, cn->completion(), &op); + return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op); } RGWSimpleRadosLockCR::RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, const string& _lock_name, + const rgw_raw_obj& _obj, + const string& _lock_name, const string& _cookie, uint32_t _duration) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), @@ -331,10 +328,10 @@ RGWSimpleRadosLockCR::RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, lock_name(_lock_name), cookie(_cookie), duration(_duration), - pool(_pool), oid(_oid), + obj(_obj), req(NULL) { - set_description() << "rados lock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration; + set_description() << "rados lock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration; } void RGWSimpleRadosLockCR::request_cleanup() @@ -348,7 +345,6 @@ void RGWSimpleRadosLockCR::request_cleanup() int RGWSimpleRadosLockCR::send_request() { set_status() << "sending request"; - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncLockSystemObj(this, stack->create_completion_notifier(), store, NULL, obj, lock_name, cookie, duration); async_rados->queue(req); @@ -362,16 +358,17 @@ int RGWSimpleRadosLockCR::request_complete() } RGWSimpleRadosUnlockCR::RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, const string& _lock_name, + const rgw_raw_obj& _obj, + const string& _lock_name, const string& _cookie) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), lock_name(_lock_name), cookie(_cookie), - pool(_pool), oid(_oid), + obj(_obj), req(NULL) { - set_description() << "rados unlock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie; + set_description() << "rados unlock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie; } void RGWSimpleRadosUnlockCR::request_cleanup() @@ -386,7 +383,6 @@ int RGWSimpleRadosUnlockCR::send_request() { set_status() << "sending request"; - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncUnlockSystemObj(this, stack->create_completion_notifier(), store, NULL, obj, lock_name, cookie); async_rados->queue(req); @@ -420,7 +416,7 @@ int RGWOmapAppend::operate() { } if (entries.size() >= window_size || going_down) { set_status() << "flushing to omap"; - call(new RGWRadosSetOmapKeysCR(store, pool, oid, entries)); + call(new RGWRadosSetOmapKeysCR(store, obj, entries)); entries.clear(); } } @@ -575,7 +571,7 @@ int RGWAsyncRemoveObj::_send_request() ldout(store->ctx(), 0) << __func__ << "(): deleting obj=" << obj << dendl; - obj_ctx.set_atomic(obj); + obj_ctx.obj.set_atomic(obj); RGWObjState *state; @@ -638,19 +634,19 @@ int RGWContinuousLeaseCR::operate() } reenter(this) { while (!going_down.read()) { - yield call(new RGWSimpleRadosLockCR(async_rados, store, pool, oid, lock_name, cookie, interval)); + yield call(new RGWSimpleRadosLockCR(async_rados, store, obj, lock_name, cookie, interval)); caller->set_sleeping(false); /* will only be relevant when we return, that's why we can do it early */ if (retcode < 0) { set_locked(false); - ldout(store->ctx(), 20) << *this << ": couldn't lock " << pool.name << ":" << oid << ":" << lock_name << ": retcode=" << retcode << dendl; + ldout(store->ctx(), 20) << *this << ": couldn't lock " << obj << ":" << lock_name << ": retcode=" << retcode << dendl; return set_state(RGWCoroutine_Error, retcode); } set_locked(true); yield wait(utime_t(interval / 2, 0)); } set_locked(false); /* moot at this point anyway */ - yield call(new RGWSimpleRadosUnlockCR(async_rados, store, pool, oid, lock_name, cookie)); + yield call(new RGWSimpleRadosUnlockCR(async_rados, store, obj, lock_name, cookie)); return set_state(RGWCoroutine_Done); } return 0; @@ -734,7 +730,9 @@ int RGWRadosTimelogTrimCR::request_complete() int RGWAsyncStatObj::_send_request() { - return store->raw_obj_stat(obj, psize, pmtime, pepoch, + rgw_raw_obj raw_obj; + store->obj_to_raw(obj, &raw_obj); + return store->raw_obj_stat(raw_obj, psize, pmtime, pepoch, nullptr, nullptr, objv_tracker); } diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index fa8ac58241d5d..a80ad5850ca28 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -101,7 +101,7 @@ class RGWAsyncGetSystemObj : public RGWAsyncRadosRequest { RGWObjectCtx *obj_ctx; RGWRados::SystemObject::Read::GetObjState read_state; RGWObjVersionTracker *objv_tracker; - rgw_obj obj; + rgw_raw_obj obj; bufferlist *pbl; map *pattrs; off_t ofs; @@ -110,14 +110,14 @@ protected: int _send_request(); public: RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, bufferlist *_pbl, off_t _ofs, off_t _end); void set_read_attrs(map *_pattrs) { pattrs = _pattrs; } }; class RGWAsyncPutSystemObj : public RGWAsyncRadosRequest { RGWRados *store; - rgw_obj obj; + rgw_raw_obj obj; bool exclusive; bufferlist bl; @@ -125,27 +125,27 @@ protected: int _send_request(); public: RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - rgw_obj& _obj, bool _exclusive, + const rgw_raw_obj& _obj, bool _exclusive, bufferlist& _bl); }; class RGWAsyncPutSystemObjAttrs : public RGWAsyncRadosRequest { RGWRados *store; RGWObjVersionTracker *objv_tracker; - rgw_obj obj; + rgw_raw_obj obj; map *attrs; protected: int _send_request(); public: RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, map *_attrs); }; class RGWAsyncLockSystemObj : public RGWAsyncRadosRequest { RGWRados *store; - rgw_obj obj; + rgw_raw_obj obj; string lock_name; string cookie; uint32_t duration_secs; @@ -154,13 +154,13 @@ protected: int _send_request(); public: RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, const string& _name, const string& _cookie, uint32_t _duration_secs); }; class RGWAsyncUnlockSystemObj : public RGWAsyncRadosRequest { RGWRados *store; - rgw_obj obj; + rgw_raw_obj obj; string lock_name; string cookie; @@ -168,7 +168,7 @@ protected: int _send_request(); public: RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, - RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj, + RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj, const string& _name, const string& _cookie); }; @@ -180,8 +180,7 @@ class RGWSimpleRadosReadCR : public RGWSimpleCoroutine { RGWObjectCtx obj_ctx; bufferlist bl; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; map *pattrs{nullptr}; @@ -193,10 +192,10 @@ class RGWSimpleRadosReadCR : public RGWSimpleCoroutine { public: RGWSimpleRadosReadCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, T *_result, bool empty_on_enoent = true) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - obj_ctx(store), pool(_pool), oid(_oid), result(_result), + obj_ctx(store), obj(_obj), result(_result), empty_on_enoent(empty_on_enoent) {} ~RGWSimpleRadosReadCR() { request_cleanup(); @@ -220,7 +219,6 @@ public: template int RGWSimpleRadosReadCR::send_request() { - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(), store, &obj_ctx, NULL, obj, @@ -268,8 +266,7 @@ class RGWSimpleRadosReadAttrsCR : public RGWSimpleCoroutine { RGWObjectCtx obj_ctx; bufferlist bl; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; map *pattrs; @@ -277,11 +274,11 @@ class RGWSimpleRadosReadAttrsCR : public RGWSimpleCoroutine { public: RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, map *_pattrs) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), obj_ctx(store), - pool(_pool), oid(_oid), + obj(_obj), pattrs(_pattrs), req(NULL) { } ~RGWSimpleRadosReadAttrsCR() { @@ -305,18 +302,17 @@ class RGWSimpleRadosWriteCR : public RGWSimpleCoroutine { RGWRados *store; bufferlist bl; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAsyncPutSystemObj *req; public: RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const T& _data) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - pool(_pool), oid(_oid), + obj(_obj), req(NULL) { ::encode(_data, bl); } @@ -333,7 +329,6 @@ public: } int send_request() { - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncPutSystemObj(this, stack->create_completion_notifier(), store, obj, false, bl); async_rados->queue(req); @@ -349,8 +344,7 @@ class RGWSimpleRadosWriteAttrsCR : public RGWSimpleCoroutine { RGWAsyncRadosProcessor *async_rados; RGWRados *store; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; map attrs; @@ -358,11 +352,11 @@ class RGWSimpleRadosWriteAttrsCR : public RGWSimpleCoroutine { public: RGWSimpleRadosWriteAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, map& _attrs) : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - pool(_pool), oid(_oid), + obj(_obj), attrs(_attrs), req(NULL) { } ~RGWSimpleRadosWriteAttrsCR() { @@ -377,7 +371,6 @@ public: } int send_request() { - rgw_obj obj = rgw_obj(pool, oid); req = new RGWAsyncPutSystemObjAttrs(this, stack->create_completion_notifier(), store, NULL, obj, &attrs); async_rados->queue(req); @@ -393,14 +386,13 @@ class RGWRadosSetOmapKeysCR : public RGWSimpleCoroutine { RGWRados *store; map entries; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAioCompletionNotifier *cn; public: RGWRadosSetOmapKeysCR(RGWRados *_store, - rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, map& _entries); ~RGWRadosSetOmapKeysCR(); @@ -419,14 +411,13 @@ class RGWRadosGetOmapKeysCR : public RGWSimpleCoroutine { int rval; librados::IoCtx ioctx; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAioCompletionNotifier *cn; public: RGWRadosGetOmapKeysCR(RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const string& _marker, map *_entries, int _max_entries); @@ -451,14 +442,13 @@ class RGWRadosRemoveOmapKeysCR : public RGWSimpleCoroutine { set keys; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAioCompletionNotifier *cn; public: RGWRadosRemoveOmapKeysCR(RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const set& _keys); ~RGWRadosRemoveOmapKeysCR(); @@ -477,14 +467,14 @@ class RGWSimpleRadosLockCR : public RGWSimpleCoroutine { string cookie; uint32_t duration; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAsyncLockSystemObj *req; public: RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, const string& _lock_name, + const rgw_raw_obj& _obj, + const string& _lock_name, const string& _cookie, uint32_t _duration); ~RGWSimpleRadosLockCR() { @@ -509,14 +499,14 @@ class RGWSimpleRadosUnlockCR : public RGWSimpleCoroutine { string lock_name; string cookie; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; RGWAsyncUnlockSystemObj *req; public: RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, const string& _lock_name, + const rgw_raw_obj& _obj, + const string& _lock_name, const string& _cookie); ~RGWSimpleRadosUnlockCR() { request_cleanup(); @@ -533,8 +523,7 @@ class RGWOmapAppend : public RGWConsumerCR { RGWAsyncRadosProcessor *async_rados; RGWRados *store; - rgw_bucket pool; - string oid; + rgw_raw_obj obj; bool going_down; @@ -546,7 +535,8 @@ class RGWOmapAppend : public RGWConsumerCR { uint64_t window_size; uint64_t total_entries; public: - RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid, + RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, + const rgw_raw_obj& _obj, uint64_t _window_size = OMAP_APPEND_MAX_ENTRIES_DEFAULT); int operate(); void flush_pending(); @@ -557,12 +547,8 @@ public: return total_entries; } - const rgw_bucket& get_pool() { - return pool; - } - - const string& get_oid() { - return oid; + const rgw_raw_obj& get_obj() { + return obj; } }; @@ -639,14 +625,14 @@ class RGWShardedOmapCRManager { vector shards; public: - RGWShardedOmapCRManager(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, RGWCoroutine *_op, int _num_shards, rgw_bucket& pool, const string& oid_prefix) + RGWShardedOmapCRManager(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, RGWCoroutine *_op, int _num_shards, const rgw_pool& pool, const string& oid_prefix) : async_rados(_async_rados), store(_store), op(_op), num_shards(_num_shards) { shards.reserve(num_shards); for (int i = 0; i < num_shards; ++i) { char buf[oid_prefix.size() + 16]; snprintf(buf, sizeof(buf), "%s.%d", oid_prefix.c_str(), i); - RGWOmapAppend *shard = new RGWOmapAppend(async_rados, store, pool, buf); + RGWOmapAppend *shard = new RGWOmapAppend(async_rados, store, rgw_raw_obj(pool, buf)); shard->get(); shards.push_back(shard); op->spawn(shard, false); @@ -1018,8 +1004,7 @@ class RGWContinuousLeaseCR : public RGWCoroutine { RGWAsyncRadosProcessor *async_rados; RGWRados *store; - const rgw_bucket& pool; - const string oid; + const rgw_raw_obj obj; const string lock_name; const string cookie; @@ -1036,10 +1021,10 @@ class RGWContinuousLeaseCR : public RGWCoroutine { public: RGWContinuousLeaseCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, - const rgw_bucket& _pool, const string& _oid, + const rgw_raw_obj& _obj, const string& _lock_name, int _interval, RGWCoroutine *_caller) : RGWCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), - pool(_pool), oid(_oid), lock_name(_lock_name), + obj(_obj), lock_name(_lock_name), cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct)), interval(_interval), lock("RGWContinuousLeaseCR"), caller(_caller) {} diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 3d82956320fc4..1e9c29654252e 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -121,7 +121,8 @@ class RGWReadDataSyncStatusMarkersCR : public RGWShardCollectCR { RGWDataSyncEnv *env; const int num_shards; - int shard_id{0}; + int shard_id{0};; + map& markers; public: @@ -139,8 +140,8 @@ bool RGWReadDataSyncStatusMarkersCR::spawn_next() return false; } using CR = RGWSimpleRadosReadCR; - spawn(new CR(env->async_rados, env->store, env->store->get_zone_params().log_pool, - RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id), + spawn(new CR(env->async_rados, env->store, + rgw_raw_obj(env->store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id)), &markers[shard_id]), false); shard_id++; @@ -167,8 +168,7 @@ int RGWReadDataSyncStatusCoroutine::operate() yield { bool empty_on_enoent = false; // fail on ENOENT call(new ReadInfoCR(sync_env->async_rados, sync_env->store, - sync_env->store->get_zone_params().log_pool, - RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone), + rgw_raw_obj(sync_env->store->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)), &sync_status->sync_info, empty_on_enoent)); } if (retcode < 0) { @@ -487,7 +487,8 @@ public: reenter(this) { yield { uint32_t lock_duration = 30; - call(new RGWSimpleRadosLockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid, + call(new RGWSimpleRadosLockCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), lock_name, cookie, lock_duration)); if (retcode < 0) { ldout(cct, 0) << "ERROR: failed to take a lock on " << sync_status_oid << dendl; @@ -495,13 +496,17 @@ public: } } yield { - call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_status_oid, status)); + call(new RGWSimpleRadosWriteCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), + status)); } yield { /* take lock again, we just recreated the object */ uint32_t lock_duration = 30; - call(new RGWSimpleRadosLockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid, - lock_name, cookie, lock_duration)); + call(new RGWSimpleRadosLockCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), + lock_name, cookie, lock_duration)); if (retcode < 0) { ldout(cct, 0) << "ERROR: failed to take a lock on " << sync_status_oid << dendl; return set_cr_error(retcode); @@ -530,18 +535,22 @@ public: RGWDataChangesLogInfo& info = shards_info[i]; marker.next_step_marker = info.marker; marker.timestamp = info.last_update; - spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, i), marker), true); + spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, i)), + marker), true); } } yield { status.state = rgw_data_sync_info::StateBuildingFullSyncMaps; - call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_status_oid, status)); + call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), + status)); } yield { /* unlock */ - call(new RGWSimpleRadosUnlockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid, - lock_name, cookie)); + call(new RGWSimpleRadosUnlockCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), + lock_name, cookie)); } while (collect(&ret, NULL)) { if (ret < 0) { @@ -782,8 +791,9 @@ public: 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(sync_env->async_rados, store, store->get_zone_params().log_pool, - RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id), marker), true); + spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)), + marker), true); } } else { yield call(sync_env->error_logger->log_error_cr(sync_env->conn->get_remote_id(), "data.init", "", @@ -843,8 +853,9 @@ public: ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl; RGWRados *store = sync_env->store; - return new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - marker_oid, sync_marker); + return new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, marker_oid), + sync_marker); } /* @@ -992,10 +1003,10 @@ public: } } else if (error_repo && remove_from_repo) { keys = {raw_key}; - yield call(new RGWRadosRemoveOmapKeysCR(sync_env->store, error_repo->get_pool(), error_repo->get_oid(), keys)); + yield call(new RGWRadosRemoveOmapKeysCR(sync_env->store, error_repo->get_obj(), keys)); if (retcode < 0) { ldout(sync_env->store->ctx(), 0) << "ERROR: failed to remove omap key from error repo (" - << error_repo->get_pool() << ":" << error_repo->get_oid() << " retcode=" << retcode << dendl; + << error_repo->get_obj() << " retcode=" << retcode << dendl; } } /* FIXME: what do do in case of error */ @@ -1021,7 +1032,7 @@ public: class RGWDataSyncShardCR : public RGWCoroutine { RGWDataSyncEnv *sync_env; - rgw_bucket pool; + rgw_pool pool; uint32_t shard_id; rgw_data_sync_marker sync_marker; @@ -1081,7 +1092,7 @@ class RGWDataSyncShardCR : public RGWCoroutine { RGWDataSyncDebugLogger logger; public: RGWDataSyncShardCR(RGWDataSyncEnv *_sync_env, - rgw_bucket& _pool, + rgw_pool& _pool, uint32_t _shard_id, rgw_data_sync_marker& _marker, bool *_reset_backoff) : RGWCoroutine(_sync_env->cct), sync_env(_sync_env), pool(_pool), @@ -1153,7 +1164,8 @@ public: lease_cr->put(); } RGWRados *store = sync_env->store; - lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, store->get_zone_params().log_pool, status_oid, + lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, status_oid), lock_name, lock_duration, this); lease_cr->get(); lease_stack = spawn(lease_cr, false); @@ -1178,7 +1190,7 @@ public: set_marker_tracker(new RGWDataSyncShardMarkerTrack(sync_env, status_oid, sync_marker)); total_entries = sync_marker.pos; do { - yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, oid, sync_marker.marker, &entries, max_entries)); + yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid), sync_marker.marker, &entries, max_entries)); if (retcode < 0) { ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): RGWRadosGetOmapKeysCR() returned ret=" << retcode << dendl; lease_cr->go_down(); @@ -1213,8 +1225,9 @@ public: sync_marker.marker = sync_marker.next_step_marker; sync_marker.next_step_marker.clear(); RGWRados *store = sync_env->store; - call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - status_oid, sync_marker)); + call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, status_oid), + sync_marker)); } if (retcode < 0) { ldout(sync_env->cct, 0) << "ERROR: failed to set sync marker: retcode=" << retcode << dendl; @@ -1227,7 +1240,9 @@ public: int incremental_sync() { reenter(&incremental_cr) { - error_repo = new RGWOmapAppend(sync_env->async_rados, sync_env->store, pool, error_oid, 1 /* no buffer */); + error_repo = new RGWOmapAppend(sync_env->async_rados, sync_env->store, + rgw_raw_obj(pool, error_oid), + 1 /* no buffer */); error_repo->get(); spawn(error_repo, false); yield init_lease_cr(); @@ -1258,7 +1273,9 @@ public: } /* process bucket shards that previously failed */ - yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, error_oid, error_marker, &error_entries, max_error_entries)); + yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, error_oid), + error_marker, &error_entries, + max_error_entries)); ldout(sync_env->cct, 20) << __func__ << "(): read error repo, got " << error_entries.size() << " entries" << dendl; iter = error_entries.begin(); for (; iter != error_entries.end(); ++iter) { @@ -1359,13 +1376,13 @@ public: class RGWDataSyncShardControlCR : public RGWBackoffControlCR { RGWDataSyncEnv *sync_env; - rgw_bucket pool; + rgw_pool pool; uint32_t shard_id; rgw_data_sync_marker sync_marker; public: - RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_bucket& _pool, + RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_pool& _pool, uint32_t _shard_id, rgw_data_sync_marker& _marker) : RGWBackoffControlCR(_sync_env->cct, false), sync_env(_sync_env), pool(_pool), @@ -1379,8 +1396,9 @@ public: RGWCoroutine *alloc_finisher_cr() override { RGWRados *store = sync_env->store; - return new RGWSimpleRadosReadCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id), &sync_marker); + return new RGWSimpleRadosReadCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)), + &sync_marker); } void append_modified_shards(set& keys) { @@ -1500,8 +1518,8 @@ public: RGWCoroutine *set_sync_info_cr() { RGWRados *store = sync_env->store; - return new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone), + return new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)), sync_status.sync_info); } @@ -1652,19 +1670,9 @@ int RGWDataSyncStatusManager::init() return -EINVAL; } - const char *log_pool = zone_params.log_pool.name.c_str(); - librados::Rados *rados = store->get_rados_handle(); - int r = rados->ioctx_create(log_pool, ioctx); - if (r < 0) { - lderr(store->ctx()) << "ERROR: failed to open log pool (" << zone_params.log_pool.name << " ret=" << r << dendl; - return r; - } - - source_status_obj = rgw_obj(zone_params.log_pool, RGWDataSyncStatusManager::sync_status_oid(source_zone)); - error_logger = new RGWSyncErrorLogger(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, ERROR_LOGGER_SHARDS); - r = source_log.init(source_zone, conn, error_logger, sync_module); + int r = source_log.init(source_zone, conn, error_logger); if (r < 0) { lderr(store->ctx()) << "ERROR: failed to init remote log, r=" << r << dendl; finalize(); @@ -1682,7 +1690,7 @@ int RGWDataSyncStatusManager::init() num_shards = datalog_info.num_shards; for (int i = 0; i < num_shards; i++) { - shard_objs[i] = rgw_obj(zone_params.log_pool, shard_obj_name(source_zone, i)); + shard_objs[i] = rgw_raw_obj(zone_params.log_pool, shard_obj_name(source_zone, i)); } return 0; @@ -1692,7 +1700,6 @@ void RGWDataSyncStatusManager::finalize() { delete error_logger; error_logger = nullptr; - ioctx.close(); } string RGWDataSyncStatusManager::sync_status_oid(const string& source_zone) @@ -1804,8 +1811,8 @@ public: status.encode_all_attrs(attrs); auto store = sync_env->store; call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, - store->get_zone_params().log_pool, - sync_status_oid, attrs)); + rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid), + attrs)); } return set_cr_done(); } @@ -1884,8 +1891,7 @@ int RGWReadBucketSyncStatusCoroutine::operate() { reenter(this) { yield call(new RGWSimpleRadosReadAttrsCR(sync_env->async_rados, sync_env->store, - sync_env->store->get_zone_params().log_pool, - oid, + rgw_raw_obj(sync_env->store->get_zone_params().log_pool, oid), &attrs)); if (retcode == -ENOENT) { *status = rgw_bucket_shard_sync_info(); @@ -2077,8 +2083,9 @@ public: RGWRados *store = sync_env->store; ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl; - return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - marker_oid, attrs); + return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, marker_oid), + attrs); } }; @@ -2118,8 +2125,10 @@ public: RGWRados *store = sync_env->store; ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl; - return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - marker_oid, attrs); + return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, marker_oid), + attrs); } /* @@ -2410,8 +2419,8 @@ int RGWBucketShardFullSyncCR::operate() sync_status.encode_state_attr(attrs); RGWRados *store = sync_env->store; call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, - store->get_zone_params().log_pool, - status_oid, attrs)); + rgw_raw_obj(store->get_zone_params().log_pool, status_oid), + attrs)); } } else { ldout(sync_env->cct, 0) << "ERROR: failure in sync, backing out (sync_status=" << sync_status<< ")" << dendl; diff --git a/src/rgw/rgw_data_sync.h b/src/rgw/rgw_data_sync.h index 6b5b7e76b60a1..75ae358198de4 100644 --- a/src/rgw/rgw_data_sync.h +++ b/src/rgw/rgw_data_sync.h @@ -264,7 +264,7 @@ public: class RGWDataSyncStatusManager { RGWRados *store; - librados::IoCtx ioctx; + rgw_rados_ref ref; string source_zone; RGWRESTConn *conn; @@ -275,9 +275,8 @@ class RGWDataSyncStatusManager { string source_status_oid; string source_shard_status_oid_prefix; - rgw_obj source_status_obj; - map shard_objs; + map shard_objs; int num_shards; @@ -473,7 +472,6 @@ public: class RGWBucketSyncStatusManager { RGWRados *store; - librados::IoCtx ioctx; RGWCoroutinesManager cr_mgr; @@ -490,10 +488,9 @@ class RGWBucketSyncStatusManager { string source_status_oid; string source_shard_status_oid_prefix; - rgw_obj source_status_obj; map sync_status; - rgw_obj status_obj; + rgw_raw_obj status_obj; int num_shards; diff --git a/src/rgw/rgw_dencoder.cc b/src/rgw/rgw_dencoder.cc index 74563963d923a..766960476828b 100644 --- a/src/rgw/rgw_dencoder.cc +++ b/src/rgw/rgw_dencoder.cc @@ -12,12 +12,24 @@ static string shadow_ns = RGW_OBJ_NS_SHADOW; +static void init_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id) +{ + b->tenant = t; + b->name = n; + b->marker = m; + b->bucket_id = id; + b->placement.data_pool = rgw_pool(dp); + b->placement.index_pool = rgw_pool(ip); +} + void RGWObjManifestPart::generate_test_instances(std::list& o) { o.push_back(new RGWObjManifestPart); RGWObjManifestPart *p = new RGWObjManifestPart; - rgw_bucket b("tenant", "bucket", ".pool", ".index_pool", "marker_", "12", "region"); + rgw_bucket b; + init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12"); + p->loc = rgw_obj(b, "object"); p->loc_ofs = 512 * 1024; p->size = 128 * 1024; @@ -133,7 +145,8 @@ void RGWObjManifest::generate_test_instances(std::list& o) RGWObjManifest *m = new RGWObjManifest; for (int i = 0; i<10; i++) { RGWObjManifestPart p; - rgw_bucket b("tenant", "bucket", ".pool", ".index_pool", "marker_", "12", "region"); + rgw_bucket b; + init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12"); p.loc = rgw_obj(b, "object"); p.loc_ofs = 0; p.size = 512 * 1024; @@ -408,7 +421,8 @@ void RGWUserInfo::generate_test_instances(list& o) void rgw_bucket::generate_test_instances(list& o) { - rgw_bucket *b = new rgw_bucket("tenant", "name", "pool", ".index_pool", "marker", "123", "region"); + rgw_bucket *b = new rgw_bucket; + init_bucket(b, "tenant", "name", "pool", ".index_pool", "marker", "123"); o.push_back(b); o.push_back(new rgw_bucket); } @@ -416,7 +430,7 @@ void rgw_bucket::generate_test_instances(list& o) void RGWBucketInfo::generate_test_instances(list& o) { RGWBucketInfo *i = new RGWBucketInfo; - i->bucket = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region"); + init_bucket(&i->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10"); i->owner = "owner"; i->flags = BUCKET_SUSPENDED; o.push_back(i); @@ -454,7 +468,7 @@ void RGWOLHInfo::generate_test_instances(list &o) void RGWBucketEnt::generate_test_instances(list& o) { RGWBucketEnt *e = new RGWBucketEnt; - e->bucket = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region"); + init_bucket(&e->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10"); e->size = 1024; e->size_rounded = 4096; e->count = 1; @@ -474,7 +488,8 @@ void RGWUploadPartInfo::generate_test_instances(list& o) void rgw_obj::generate_test_instances(list& o) { - rgw_bucket b = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region"); + rgw_bucket b; + init_bucket(&b, "tenant", "bucket", "pool", ".index_pool", "marker", "10"); rgw_obj *obj = new rgw_obj(b, "object"); o.push_back(obj); o.push_back(new rgw_obj); diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 33a0a28228263..d3e5c2bcd1d50 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -40,6 +40,18 @@ void encode_json(const char *name, const RGWUserCaps& val, Formatter *f) } +void encode_json(const char *name, const rgw_pool& pool, Formatter *f) +{ + f->dump_string(name, pool.name); +} + +void decode_json_obj(rgw_pool& pool, JSONObj *obj) +{ + string s; + decode_json_obj(s, obj); + pool = rgw_pool(s); +} + void RGWOLHInfo::dump(Formatter *f) const { encode_json("target", target, f); @@ -545,25 +557,40 @@ void RGWQuotaInfo::decode_json(JSONObj *obj) JSONDecoder::decode_json("enabled", enabled, obj); } -void rgw_bucket::dump(Formatter *f) const +void rgw_data_placement_target::dump(Formatter *f) const { - encode_json("name", name, f); - encode_json("pool", data_pool, f); + encode_json("data_pool", data_pool, f); encode_json("data_extra_pool", data_extra_pool, f); encode_json("index_pool", index_pool, f); +} + +void rgw_data_placement_target::decode_json(JSONObj *obj) { + JSONDecoder::decode_json("data_pool", data_pool, obj); + JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj); + JSONDecoder::decode_json("index_pool", index_pool, obj); +} + +void rgw_bucket::dump(Formatter *f) const +{ + encode_json("name", name, f); encode_json("marker", marker, f); encode_json("bucket_id", bucket_id, f); encode_json("tenant", tenant, f); + encode_json("placement", placement, f); } void rgw_bucket::decode_json(JSONObj *obj) { JSONDecoder::decode_json("name", name, obj); - JSONDecoder::decode_json("pool", data_pool, obj); - JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj); - JSONDecoder::decode_json("index_pool", index_pool, obj); JSONDecoder::decode_json("marker", marker, obj); JSONDecoder::decode_json("bucket_id", bucket_id, obj); JSONDecoder::decode_json("tenant", tenant, obj); + JSONDecoder::decode_json("placement", placement, obj); + if (placement.data_pool.empty()) { + /* decoding old format */ + JSONDecoder::decode_json("pool", placement.data_pool, obj); + JSONDecoder::decode_json("data_extra_pool", placement.data_extra_pool, obj); + JSONDecoder::decode_json("index_pool", placement.index_pool, obj); + } } void RGWBucketEntryPoint::dump(Formatter *f) const @@ -772,6 +799,19 @@ void RGWUploadPartInfo::dump(Formatter *f) const encode_json("modified", ut, f); } +void rgw_raw_obj::dump(Formatter *f) const +{ + encode_json("pool", pool, f); + encode_json("oid", oid, f); + encode_json("loc", loc, f); +} + +void rgw_raw_obj::decode_json(JSONObj *obj) { + JSONDecoder::decode_json("pool", pool, obj); + JSONDecoder::decode_json("oid", oid, obj); + JSONDecoder::decode_json("loc", loc, obj); +} + void rgw_obj::dump(Formatter *f) const { encode_json("bucket", bucket, f); @@ -851,31 +891,24 @@ void RGWPeriod::decode_json(JSONObj *obj) void RGWZoneParams::dump(Formatter *f) const { RGWSystemMetaObj::dump(f); - encode_json("domain_root", domain_root.data_pool, f); - encode_json("control_pool", control_pool.data_pool, f); - encode_json("gc_pool", gc_pool.data_pool, f); - encode_json("lc_pool", lc_pool.data_pool, f); - encode_json("log_pool", log_pool.data_pool, f); - encode_json("intent_log_pool", intent_log_pool.data_pool, f); - encode_json("usage_log_pool", usage_log_pool.data_pool, f); - encode_json("user_keys_pool", user_keys_pool.data_pool, f); - encode_json("user_email_pool", user_email_pool.data_pool, f); - encode_json("user_swift_pool", user_swift_pool.data_pool, f); - encode_json("user_uid_pool", user_uid_pool.data_pool, f); + encode_json("domain_root", domain_root, f); + encode_json("control_pool", control_pool, f); + encode_json("gc_pool", gc_pool, f); + encode_json("lc_pool", lc_pool, f); + encode_json("log_pool", log_pool, f); + encode_json("intent_log_pool", intent_log_pool, f); + encode_json("usage_log_pool", usage_log_pool, f); + encode_json("user_keys_pool", user_keys_pool, f); + encode_json("user_email_pool", user_email_pool, f); + encode_json("user_swift_pool", user_swift_pool, f); + encode_json("user_uid_pool", user_uid_pool, f); encode_json_plain("system_key", system_key, f); encode_json("placement_pools", placement_pools, f); - encode_json("metadata_heap", metadata_heap.data_pool, f); + encode_json("metadata_heap", metadata_heap, f); encode_json("tier_config", tier_config, f); encode_json("realm_id", realm_id, f); } -static void decode_json(const char *field, rgw_bucket& bucket, JSONObj *obj) -{ - string pool; - JSONDecoder::decode_json(field, pool, obj); - bucket = rgw_bucket(pool.c_str()); -} - void RGWZonePlacementInfo::dump(Formatter *f) const { encode_json("index_pool", index_pool, f); @@ -899,20 +932,20 @@ void RGWZonePlacementInfo::decode_json(JSONObj *obj) void RGWZoneParams::decode_json(JSONObj *obj) { RGWSystemMetaObj::decode_json(obj); - ::decode_json("domain_root", domain_root, obj); - ::decode_json("control_pool", control_pool, obj); - ::decode_json("gc_pool", gc_pool, obj); - ::decode_json("lc_pool", lc_pool, obj); - ::decode_json("log_pool", log_pool, obj); - ::decode_json("intent_log_pool", intent_log_pool, obj); - ::decode_json("usage_log_pool", usage_log_pool, obj); - ::decode_json("user_keys_pool", user_keys_pool, obj); - ::decode_json("user_email_pool", user_email_pool, obj); - ::decode_json("user_swift_pool", user_swift_pool, obj); - ::decode_json("user_uid_pool", user_uid_pool, obj); + JSONDecoder::decode_json("domain_root", domain_root, obj); + JSONDecoder::decode_json("control_pool", control_pool, obj); + JSONDecoder::decode_json("gc_pool", gc_pool, obj); + JSONDecoder::decode_json("lc_pool", lc_pool, obj); + JSONDecoder::decode_json("log_pool", log_pool, obj); + JSONDecoder::decode_json("intent_log_pool", intent_log_pool, obj); + JSONDecoder::decode_json("usage_log_pool", usage_log_pool, obj); + JSONDecoder::decode_json("user_keys_pool", user_keys_pool, obj); + JSONDecoder::decode_json("user_email_pool", user_email_pool, obj); + JSONDecoder::decode_json("user_swift_pool", user_swift_pool, obj); + JSONDecoder::decode_json("user_uid_pool", user_uid_pool, obj); JSONDecoder::decode_json("system_key", system_key, obj); JSONDecoder::decode_json("placement_pools", placement_pools, obj); - ::decode_json("metadata_heap", metadata_heap, obj); + JSONDecoder::decode_json("metadata_heap", metadata_heap, obj); JSONDecoder::decode_json("tier_config", tier_config, obj); JSONDecoder::decode_json("realm_id", realm_id, obj); diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index a6b60ffe5bbe8..153ddb060d708 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -400,7 +400,7 @@ int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s, string oid = render_log_object_name(s->cct->_conf->rgw_log_object_name, &bdt, s->bucket.bucket_id, entry.bucket); - rgw_obj obj(store->get_zone_params().log_pool, oid); + rgw_raw_obj obj(store->get_zone_params().log_pool, oid); ret = store->append_async(obj, bl.length(), bl); if (ret == -ENOENT) { diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 837b64f7e2caa..12f97492cba46 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -280,7 +280,7 @@ public: int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, real_time mtime, JSONObj *obj, sync_type_t sync_type) override { return -ENOTSUP; } - void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {} + virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {} int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override { return -ENOTSUP; } @@ -677,7 +677,7 @@ int RGWMetadataManager::lock_exclusive(string& metadata_key, timespan duration, if (ret < 0) return ret; - rgw_bucket pool; + rgw_pool pool; string oid; handler->get_pool_and_oid(store, entry, pool, oid); @@ -695,7 +695,7 @@ int RGWMetadataManager::unlock(string& metadata_key, string& owner_id) { if (ret < 0) return ret; - rgw_bucket pool; + rgw_pool pool; string oid; handler->get_pool_and_oid(store, entry, pool, oid); @@ -849,7 +849,7 @@ int RGWMetadataManager::store_in_heap(RGWMetadataHandler *handler, const string& return -EINVAL; } - rgw_bucket heap_pool(store->get_zone_params().metadata_heap); + rgw_pool heap_pool(store->get_zone_params().metadata_heap); if (heap_pool.name.empty()) { return 0; @@ -875,14 +875,14 @@ int RGWMetadataManager::remove_from_heap(RGWMetadataHandler *handler, const stri return -EINVAL; } - rgw_bucket heap_pool(store->get_zone_params().metadata_heap); + rgw_pool heap_pool(store->get_zone_params().metadata_heap); if (heap_pool.name.empty()) { return 0; } string oid = heap_oid(handler, key, objv_tracker->write_version); - rgw_obj obj(heap_pool, oid); + rgw_raw_obj obj(heap_pool, oid); int ret = store->delete_system_obj(obj); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: store->delete_system_obj()=" << oid << ") returned ret=" << ret << dendl; @@ -902,9 +902,9 @@ int RGWMetadataManager::put_entry(RGWMetadataHandler *handler, const string& key return ret; string oid; - rgw_bucket bucket; + rgw_pool pool; - handler->get_pool_and_oid(store, key, bucket, oid); + handler->get_pool_and_oid(store, key, pool, oid); ret = store_in_heap(handler, key, bl, objv_tracker, mtime, pattrs); if (ret < 0) { @@ -912,7 +912,7 @@ int RGWMetadataManager::put_entry(RGWMetadataHandler *handler, const string& key goto done; } - ret = rgw_put_system_obj(store, bucket, oid, + ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, objv_tracker, mtime, pattrs); @@ -941,11 +941,11 @@ int RGWMetadataManager::remove_entry(RGWMetadataHandler *handler, string& key, R return ret; string oid; - rgw_bucket bucket; + rgw_pool pool; - handler->get_pool_and_oid(store, key, bucket, oid); + handler->get_pool_and_oid(store, key, pool, oid); - rgw_obj obj(bucket, oid); + rgw_raw_obj obj(pool, oid); ret = store->delete_system_obj(obj, objv_tracker); /* cascading ret into post_modify() */ diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 22e15e1505926..f14076673d62f 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -178,13 +178,12 @@ static int get_user_policy_from_attr(CephContext * const cct, return 0; } -static int get_bucket_policy_from_attr(CephContext *cct, +static int get_bucket_instance_policy_from_attr(CephContext *cct, RGWRados *store, - void *ctx, RGWBucketInfo& bucket_info, map& bucket_attrs, RGWAccessControlPolicy *policy, - rgw_obj& obj) + rgw_raw_obj& obj) { map::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL); @@ -245,26 +244,16 @@ static int get_obj_policy_from_attr(CephContext *cct, * object: name of the object to get the ACL for. * Returns: 0 on success, -ERR# otherwise. */ -static int get_policy_from_attr(CephContext *cct, +static int get_bucket_policy_from_attr(CephContext *cct, RGWRados *store, - void *ctx, RGWBucketInfo& bucket_info, map& bucket_attrs, - RGWAccessControlPolicy *policy, - rgw_obj& obj) + RGWAccessControlPolicy *policy) { - if (obj.bucket.name.empty()) { - return 0; - } - - if (obj.get_object().empty()) { - rgw_obj instance_obj; - store->get_bucket_instance_obj(bucket_info.bucket, instance_obj); - return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, - policy, instance_obj); - } - return get_obj_policy_from_attr(cct, store, *static_cast(ctx), bucket_info, bucket_attrs, - policy, obj); + rgw_raw_obj instance_obj; + store->get_bucket_instance_obj(bucket_info.bucket, instance_obj); + return get_bucket_instance_policy_from_attr(cct, store, bucket_info, bucket_attrs, + policy, instance_obj); } static int get_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map& attrs) @@ -296,7 +285,7 @@ static int modify_obj_attr(RGWRados *store, struct req_state *s, rgw_obj& obj, c return store->set_attrs(s->obj_ctx, read_op.state.obj, attrs, NULL); } -static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map& attrs, +static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_raw_obj& obj, map& attrs, uint64_t *obj_size, RGWObjVersionTracker *objv_tracker) { RGWRados::SystemObject src(store, *static_cast(s->obj_ctx), obj); @@ -309,13 +298,37 @@ static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& o return ret; } -static int read_policy(RGWRados *store, - struct req_state *s, - RGWBucketInfo& bucket_info, - map& bucket_attrs, - RGWAccessControlPolicy *policy, - rgw_bucket& bucket, - rgw_obj_key& object) +static int read_bucket_policy(RGWRados *store, + struct req_state *s, + RGWBucketInfo& bucket_info, + map& bucket_attrs, + RGWAccessControlPolicy *policy, + rgw_bucket& bucket) +{ + if (!s->system_request && bucket_info.flags & BUCKET_SUSPENDED) { + ldout(s->cct, 0) << "NOTICE: bucket " << bucket_info.bucket.name << " is suspended" << dendl; + return -ERR_USER_SUSPENDED; + } + + if (bucket.name.empty()) { + return 0; + } + + int ret = get_bucket_policy_from_attr(s->cct, store, bucket_info, bucket_attrs, policy); + if (ret == -ENOENT) { + ret = -ERR_NO_SUCH_BUCKET; + } + + return ret; +} + +static int read_obj_policy(RGWRados *store, + struct req_state *s, + RGWBucketInfo& bucket_info, + map& bucket_attrs, + RGWAccessControlPolicy *policy, + rgw_bucket& bucket, + rgw_obj_key& object) { string upload_id; upload_id = s->info.args.get("uploadId"); @@ -326,7 +339,7 @@ static int read_policy(RGWRados *store, return -ERR_USER_SUSPENDED; } - if (!object.empty() && !upload_id.empty()) { + if (!upload_id.empty()) { /* multipart upload */ RGWMPObj mp(object.name, upload_id); string oid = mp.get_meta(); @@ -336,14 +349,14 @@ static int read_policy(RGWRados *store, obj = rgw_obj(bucket, object.name); obj.set_instance(object.instance); } - int ret = get_policy_from_attr(s->cct, store, s->obj_ctx, bucket_info, bucket_attrs, policy, obj); - if (ret == -ENOENT && !object.empty()) { + RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); + int ret = get_obj_policy_from_attr(s->cct, store, *obj_ctx, + bucket_info, bucket_attrs, policy, obj); + if (ret == -ENOENT) { /* object does not exist checking the bucket's ACL to make sure that we send a proper error code */ RGWAccessControlPolicy bucket_policy(s->cct); - string no_object; - rgw_obj no_obj(bucket, no_object); - ret = get_policy_from_attr(s->cct, store, s->obj_ctx, bucket_info, bucket_attrs, &bucket_policy, no_obj); + ret = get_bucket_policy_from_attr(s->cct, store, bucket_info, bucket_attrs, &bucket_policy); if (ret < 0) { return ret; } @@ -357,8 +370,6 @@ static int read_policy(RGWRados *store, } else { ret = -ENOENT; } - } else if (ret == -ENOENT) { - ret = -ERR_NO_SUCH_BUCKET; } return ret; @@ -437,8 +448,7 @@ int rgw_build_bucket_policies(RGWRados* store, struct req_state* s) s->bucket = s->bucket_info.bucket; if (s->bucket_exists) { - rgw_obj_key no_obj; - ret = read_policy(store, s, s->bucket_info, s->bucket_attrs, s->bucket_acl, s->bucket, no_obj); + ret = read_bucket_policy(store, s, s->bucket_info, s->bucket_attrs, s->bucket_acl, s->bucket); acct_acl_user = { s->bucket_info.owner, s->bucket_acl->get_owner().get_display_name(), @@ -534,7 +544,7 @@ int rgw_build_object_policies(RGWRados *store, struct req_state *s, if (prefetch_data) { store->set_prefetch_data(s->obj_ctx, obj); } - ret = read_policy(store, s, s->bucket_info, s->bucket_attrs, s->object_acl, s->bucket, s->object); + ret = read_obj_policy(store, s, s->bucket_info, s->bucket_attrs, s->object_acl, s->bucket, s->object); } return ret; @@ -819,7 +829,7 @@ int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, ldout(s->cct, 20) << "reading obj=" << part << " ofs=" << cur_ofs << " end=" << cur_end << dendl; - obj_ctx.set_atomic(part); + obj_ctx.obj.set_atomic(part); store->set_prefetch_data(&obj_ctx, part); RGWRados::Object op_target(store, s->bucket_info, obj_ctx, part); @@ -1105,9 +1115,8 @@ int RGWGetObj::handle_user_manifest(const char *prefix) } bucket = bucket_info.bucket; pbucket_info = &bucket_info; - rgw_obj_key no_obj; bucket_policy = &_bucket_policy; - r = read_policy(store, s, bucket_info, bucket_attrs, bucket_policy, bucket, no_obj); + r = read_bucket_policy(store, s, bucket_info, bucket_attrs, bucket_policy, bucket); if (r < 0) { ldout(s->cct, 0) << "failed to read bucket policy" << dendl; return r; @@ -1220,10 +1229,9 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl) return r; } bucket = bucket_info.bucket; - rgw_obj_key no_obj; bucket_policy = &_bucket_policy; - r = read_policy(store, s, bucket_info, bucket_attrs, bucket_policy, - bucket, no_obj); + r = read_bucket_policy(store, s, bucket_info, bucket_attrs, bucket_policy, + bucket); if (r < 0) { ldout(s->cct, 0) << "failed to read bucket policy for bucket " << bucket << dendl; @@ -2241,7 +2249,7 @@ void RGWCreateBucket::execute() bool existed; string bucket_name; rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name, bucket_name); - rgw_obj obj(store->get_zone_params().domain_root, bucket_name); + rgw_raw_obj obj(store->get_zone_params().domain_root, bucket_name); obj_version objv, *pobjv = NULL; op_ret = get_params(); @@ -2267,8 +2275,8 @@ void RGWCreateBucket::execute() s->bucket_owner.set_id(s->user->user_id); s->bucket_owner.set_name(s->user->display_name); if (s->bucket_exists) { - int r = get_policy_from_attr(s->cct, store, s->obj_ctx, s->bucket_info, - s->bucket_attrs, &old_policy, obj); + int r = get_bucket_policy_from_attr(s->cct, store, s->bucket_info, + s->bucket_attrs, &old_policy); if (r >= 0) { if (old_policy.get_owner().get_id().compare(s->user->user_id) != 0) { op_ret = -EEXIST; @@ -2733,7 +2741,11 @@ int RGWPutObjProcessor_Multipart::do_complete(size_t accounted_size, meta_obj.init_ns(bucket, multipart_meta_obj, mp_ns); meta_obj.set_in_extra_data(true); - r = store->omap_set(meta_obj, p, bl); + rgw_raw_obj raw_meta_obj; + + store->obj_to_raw(meta_obj, &raw_meta_obj); + + r = store->omap_set(raw_meta_obj, p, bl); return r; } @@ -3733,7 +3745,7 @@ void RGWDeleteObj::execute() } RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); - obj_ctx->set_atomic(obj); + obj_ctx->obj.set_atomic(obj); bool ver_restored = false; op_ret = store->swift_versioning_restore(*obj_ctx, s->bucket_owner.get_id(), @@ -3865,7 +3877,7 @@ int RGWCopyObj::verify_permission() store->set_prefetch_data(s->obj_ctx, src_obj); /* check source object permissions */ - op_ret = read_policy(store, s, src_bucket_info, src_attrs, &src_policy, + op_ret = read_obj_policy(store, s, src_bucket_info, src_attrs, &src_policy, src_bucket, src_object); if (op_ret < 0) { return op_ret; @@ -3902,11 +3914,9 @@ int RGWCopyObj::verify_permission() rgw_obj dest_obj(dest_bucket, dest_object); store->set_atomic(s->obj_ctx, dest_obj); - rgw_obj_key no_obj; - /* check dest bucket permissions */ - op_ret = read_policy(store, s, dest_bucket_info, dest_attrs, - &dest_bucket_policy, dest_bucket, no_obj); + op_ret = read_bucket_policy(store, s, dest_bucket_info, dest_attrs, + &dest_bucket_policy, dest_bucket); if (op_ret < 0) { return op_ret; } @@ -3988,8 +3998,8 @@ void RGWCopyObj::execute() rgw_obj dst_obj(dest_bucket, dest_object); RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - obj_ctx.set_atomic(src_obj); - obj_ctx.set_atomic(dst_obj); + obj_ctx.obj.set_atomic(src_obj); + obj_ctx.obj.set_atomic(dst_obj); encode_delete_at_attr(delete_at, attrs); @@ -4201,16 +4211,14 @@ void RGWPutACLs::execute() } new_policy.encode(bl); - obj = rgw_obj(s->bucket, s->object.name); - obj.set_instance(s->object.instance); map attrs; if (!s->object.empty()) { + obj = rgw_obj(s->bucket, s->object); + store->set_atomic(s->obj_ctx, obj); //if instance is empty, we should modify the latest object op_ret = modify_obj_attr(store, s, obj, RGW_ATTR_ACL, bl); } else { - store->set_atomic(s->obj_ctx, obj); - attrs = s->bucket_attrs; attrs[RGW_ATTR_ACL] = bl; op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); @@ -4320,9 +4328,9 @@ void RGWDeleteLC::execute() bufferlist bl; map orig_attrs, attrs; map::iterator iter; - rgw_obj obj; + rgw_raw_obj obj; store->get_bucket_instance_obj(s->bucket, obj); - store->set_atomic(s->obj_ctx, obj); + store->set_prefetch_data(s->obj_ctx, obj); op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker); if (op_ret < 0) return; @@ -4400,22 +4408,15 @@ int RGWPutCORS::verify_permission() void RGWPutCORS::execute() { - rgw_obj obj; + rgw_raw_obj obj; op_ret = get_params(); if (op_ret < 0) return; - bool is_object_op = (!s->object.empty()); - if (is_object_op) { - store->get_bucket_instance_obj(s->bucket, obj); - store->set_atomic(s->obj_ctx, obj); - op_ret = store->set_attr(s->obj_ctx, obj, RGW_ATTR_CORS, cors_bl); - } else { - map attrs = s->bucket_attrs; - attrs[RGW_ATTR_CORS] = cors_bl; - op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); - } + map attrs = s->bucket_attrs; + attrs[RGW_ATTR_CORS] = cors_bl; + op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); } int RGWDeleteCORS::verify_permission() @@ -4434,30 +4435,20 @@ void RGWDeleteCORS::execute() return; bufferlist bl; - rgw_obj obj; + rgw_raw_obj obj; if (!cors_exist) { dout(2) << "No CORS configuration set yet for this bucket" << dendl; op_ret = -ENOENT; return; } store->get_bucket_instance_obj(s->bucket, obj); - store->set_atomic(s->obj_ctx, obj); + store->set_prefetch_data(s->obj_ctx, obj); map orig_attrs, attrs, rmattrs; map::iterator iter; - bool is_object_op = (!s->object.empty()); - - - if (is_object_op) { - /* check if obj exists, read orig attrs */ - op_ret = get_obj_attrs(store, s, obj, orig_attrs); - if (op_ret < 0) - return; - } else { - op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker); - if (op_ret < 0) - return; - } + op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker); + if (op_ret < 0) + return; /* only remove meta attrs */ for (iter = orig_attrs.begin(); iter != orig_attrs.end(); ++iter) { @@ -4469,11 +4460,7 @@ void RGWDeleteCORS::execute() attrs[name] = iter->second; } } - if (is_object_op) { - op_ret = store->set_attrs(s->obj_ctx, obj, attrs, &rmattrs); - } else { - op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); - } + op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); } void RGWOptionsCORS::get_response_params(string& hdrs, string& exp_hdrs, unsigned *max_age) { @@ -4690,6 +4677,9 @@ static int list_multipart_parts(RGWRados *store, struct req_state *s, obj.init_ns(s->bucket, meta_oid, mp_ns); obj.set_in_extra_data(true); + rgw_raw_obj raw_obj; + store->obj_to_raw(obj, &raw_obj); + bool sorted_omap = is_v2_upload_id(upload_id) && !assume_unsorted; int ret; @@ -4704,9 +4694,9 @@ static int list_multipart_parts(RGWRados *store, struct req_state *s, snprintf(buf, sizeof(buf), "%08d", marker); p.append(buf); - ret = store->omap_get_vals(obj, header, p, num_parts + 1, parts_map); + ret = store->omap_get_vals(raw_obj, header, p, num_parts + 1, parts_map); } else { - ret = store->omap_get_all(obj, header, parts_map); + ret = store->omap_get_all(raw_obj, header, parts_map); } if (ret < 0) return ret; @@ -4994,7 +4984,7 @@ void RGWCompleteMultipart::execute() RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - obj_ctx.set_atomic(target_obj); + obj_ctx.obj.set_atomic(target_obj); RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), target_obj); RGWRados::Object::Write obj_op(&op_target); @@ -5287,7 +5277,7 @@ void RGWDeleteMultiObj::execute() rgw_obj obj(bucket, iter->name); obj.set_instance(iter->instance); - obj_ctx->set_atomic(obj); + obj_ctx->obj.set_atomic(obj); RGWRados::Object del_target(store, s->bucket_info, *obj_ctx, obj); RGWRados::Object::Delete del_op(&del_target); @@ -5327,8 +5317,7 @@ bool RGWBulkDelete::Deleter::verify_permission(RGWBucketInfo& binfo, ACLOwner& bucket_owner /* out */) { RGWAccessControlPolicy bacl(store->ctx()); - rgw_obj_key no_obj; - int ret = read_policy(store, s, binfo, battrs, &bacl, binfo.bucket, no_obj); + int ret = read_bucket_policy(store, s, binfo, battrs, &bacl, binfo.bucket); if (ret < 0) { return false; } @@ -5362,7 +5351,7 @@ bool RGWBulkDelete::Deleter::delete_single(const acct_path_t& path) if (!path.obj_key.empty()) { rgw_obj obj(binfo.bucket, path.obj_key); - obj_ctx.set_atomic(obj); + obj_ctx.obj.set_atomic(obj); RGWRados::Object del_target(store, binfo, obj_ctx, obj); RGWRados::Object::Delete del_op(&del_target); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 93c0001ee83e5..1bcd4f00ed531 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5670,22 +5670,47 @@ int RGWRados::get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx) return 0; } +int RGWRados::get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref) +{ + get_obj_bucket_and_oid_loc(obj, ref->oid, ref->key); + + int r; + + if (!obj.is_in_extra_data()) { + r = open_pool_ctx(obj.bucket.placement.data_pool, ref->ioctx); + } else { + r = open_pool_ctx(obj.bucket.placement.get_data_extra_pool(), ref->ioctx); + } + if (r < 0) + return r; + + ref->ioctx.locator_set_key(ref->key); + + return 0; +} + int RGWRados::get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool) { - *pool = obj.pool; ref->oid = obj.oid; - ref->key.clear(); + ref->key = obj.loc; int r; if (ref->oid.empty()) { - ref->oid = pool->name; - *pool = get_zone_params().domain_root; + ref->oid = obj.pool.name; + ref->pool = get_zone_params().domain_root; + } else { + ref->pool = obj.pool; } - r = open_pool_ctx(pool->name, ref->ioctx); + if (pool) { + *pool = ref->pool; + } + r = open_pool_ctx(ref->pool.name, ref->ioctx); if (r < 0) return r; + ref->ioctx.locator_set_key(ref->key); + return 0; } @@ -5868,8 +5893,7 @@ int RGWRados::fix_tail_obj_locator(rgw_bucket& bucket, rgw_obj_key& key, bool fi } rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -6237,7 +6261,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si return -EIO; } - r = store->get_obj_ref(obj, &ref, &pool); + r = store->get_obj_ref(obj, &ref); if (r < 0) return r; @@ -6588,8 +6612,7 @@ int RGWRados::aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, void **handle) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -7452,8 +7475,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, } rgw_rados_ref ref; - rgw_pool pool; - ret = get_obj_ref(miter.get_location(), &ref, &pool); + ret = get_obj_ref(miter.get_location(), &ref); if (ret < 0) { return ret; } @@ -8165,8 +8187,7 @@ int RGWRados::Object::Delete::delete_obj() } rgw_rados_ref ref; - rgw_pool pool; - int r = store->get_obj_ref(obj, &ref, &pool); + int r = store->get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -8954,8 +8975,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj, map* rmattrs) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -10032,8 +10052,7 @@ int RGWRados::iterate_obj(RGWObjectCtx& obj_ctx, rgw_obj& obj, int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -10044,8 +10063,7 @@ int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op) int RGWRados::obj_operate(rgw_obj& obj, ObjectReadOperation *op) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -10173,8 +10191,7 @@ int RGWRados::bucket_index_link_olh(RGWObjState& olh_state, rgw_obj& obj_instanc real_time unmod_since, bool high_precision_time) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj_instance, &ref, &pool); + int r = get_obj_ref(obj_instance, &ref); if (r < 0) { return r; } @@ -10206,8 +10223,7 @@ void RGWRados::bucket_index_guard_olh_op(RGWObjState& olh_state, ObjectOperation int RGWRados::bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj_instance, &ref, &pool); + int r = get_obj_ref(obj_instance, &ref); if (r < 0) { return r; } @@ -10233,8 +10249,7 @@ int RGWRados::bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instanc bool *is_truncated) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj_instance, &ref, &pool); + int r = get_obj_ref(obj_instance, &ref); if (r < 0) { return r; } @@ -10262,8 +10277,7 @@ int RGWRados::bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instanc int RGWRados::bucket_index_trim_olh_log(RGWObjState& state, rgw_obj& obj_instance, uint64_t ver) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj_instance, &ref, &pool); + int r = get_obj_ref(obj_instance, &ref); if (r < 0) { return r; } @@ -10293,8 +10307,7 @@ int RGWRados::bucket_index_trim_olh_log(RGWObjState& state, rgw_obj& obj_instanc int RGWRados::bucket_index_clear_olh(RGWObjState& state, rgw_obj& obj_instance) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj_instance, &ref, &pool); + int r = get_obj_ref(obj_instance, &ref); if (r < 0) { return r; } @@ -10376,8 +10389,7 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket } rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -10691,8 +10703,7 @@ int RGWRados::remove_olh_pending_entries(RGWObjState& state, rgw_obj& olh_obj, m } rgw_rados_ref ref; - rgw_pool pool; - int r = get_obj_ref(olh_obj, &ref, &pool); + int r = get_obj_ref(olh_obj, &ref); if (r < 0) { return r; } @@ -10769,8 +10780,7 @@ int RGWRados::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, RGWObjVersionTracker *objv_tracker) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -11282,8 +11292,7 @@ int RGWRados::put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, real_t int RGWRados::omap_get_vals(rgw_raw_obj& obj, bufferlist& header, const string& marker, uint64_t count, std::map& m) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -11328,12 +11337,11 @@ int RGWRados::omap_get_all(rgw_raw_obj& obj, bufferlist& header, int RGWRados::omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } - ldout(cct, 15) << "omap_set pool=" << pool << " oid=" << ref.oid << " key=" << key << dendl; + ldout(cct, 15) << "omap_set obj=" << obj << " key=" << key << dendl; map m; m[key] = bl; @@ -11346,8 +11354,7 @@ int RGWRados::omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl) int RGWRados::omap_set(rgw_raw_obj& obj, std::map& m) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -11360,8 +11367,7 @@ int RGWRados::omap_set(rgw_raw_obj& obj, std::map& m) int RGWRados::omap_del(rgw_raw_obj& obj, const std::string& key) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -11407,8 +11413,7 @@ int RGWRados::update_containers_stats(map& m) int RGWRados::append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl) { rgw_rados_ref ref; - rgw_pool pool; - int r = get_raw_obj_ref(obj, &ref, &pool); + int r = get_raw_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -11643,9 +11648,8 @@ int RGWRados::trim_bi_log_entries(rgw_bucket& bucket, int shard_id, string& star int RGWRados::bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent) { - rgw_pool pool; rgw_rados_ref ref; - int r = get_obj_ref(obj, &ref, &pool); + int r = get_obj_ref(obj, &ref); if (r < 0) { return r; } @@ -12934,8 +12938,7 @@ int RGWRados::delete_obj_aio(rgw_obj& obj, rgw_bucket& bucket, list& handles, bool keep_index_consistent) { rgw_rados_ref ref; - rgw_pool pool; - int ret = get_obj_ref(obj, &ref, &pool); + int ret = get_obj_ref(obj, &ref); if (ret < 0) { lderr(cct) << "ERROR: failed to get obj ref with ret=" << ret << dendl; return ret; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 494ea0c833284..5a63bb802f885 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1864,6 +1864,7 @@ class RGWGetDirHeader_CB; class RGWGetUserHeader_CB; struct rgw_rados_ref { + rgw_pool pool; string oid; string key; librados::IoCtx ioctx; @@ -1914,12 +1915,12 @@ public: void set_atomic(T& obj) { RWLock::WLocker wl(lock); - assert (!obj.get_object().empty()); + assert (!obj.empty()); objs_state[obj].is_atomic = true; } void set_prefetch_data(T& obj) { RWLock::WLocker wl(lock); - assert (!obj.get_object().empty()); + assert (!obj.empty()); objs_state[obj].prefetch_data = true; } void invalidate(T& obj) { @@ -1942,13 +1943,14 @@ public: }; struct RGWObjectCtx { + RGWRados *store; void *user_ctx; RGWObjectCtxImpl obj; RGWObjectCtxImpl raw; - explicit RGWObjectCtx(RGWRados *store) : user_ctx(NULL), obj(store), raw(store) { } - RGWObjectCtx(RGWRados *store, void *_user_ctx) : user_ctx(_user_ctx), obj(store), raw(store) { } + explicit RGWObjectCtx(RGWRados *_store) : store(_store), user_ctx(NULL), obj(store), raw(store) { } + RGWObjectCtx(RGWRados *_store, void *_user_ctx) : store(_store), user_ctx(_user_ctx), obj(store), raw(store) { } }; class Finisher; @@ -2052,10 +2054,8 @@ class RGWRados uint32_t bucket_index_max_shards; int get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx); - int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool); - int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool); - void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); - int get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool); + int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref); + int get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL); uint64_t max_bucket_id; int get_olh_target_state(RGWObjectCtx& rctx, rgw_obj& obj, RGWObjState *olh_state, @@ -2271,6 +2271,9 @@ public: return MAX_BUCKET_INDEX_SHARDS_PRIME; } + int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL); + void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); + int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max, RGWListRawObjsCtx& ctx, list& oids, bool *is_truncated); @@ -2301,18 +2304,18 @@ public: int init_complete(); int replace_region_with_zonegroup(); int convert_regionmap(); - virtual int initialize(); - virtual void finalize(); + int initialize(); + void finalize(); void schedule_context(Context *c); /** set up a bucket listing. handle is filled in. */ - virtual int list_buckets_init(RGWAccessHandle *handle); + int list_buckets_init(RGWAccessHandle *handle); /** * get the next bucket in the listing. obj is filled in, * handle is updated. */ - virtual int list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle); + int list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle); /// list logs int log_list_init(const string& prefix, RGWAccessHandle *handle); @@ -2337,7 +2340,7 @@ public: * create a bucket with name bucket and the given list of attrs * returns 0 on success, -ERR# otherwise. */ - virtual int init_bucket_index(rgw_bucket& bucket, int num_shards); + int init_bucket_index(rgw_bucket& bucket, int num_shards); int select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name, RGWZonePlacementInfo *rule_info); @@ -2349,7 +2352,7 @@ public: int set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, RGWZonePlacementInfo *rule_info); void create_bucket_id(string *bucket_id); - virtual int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, + int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, const string& zonegroup_id, const string& placement_rule, const string& swift_ver_location, @@ -2361,10 +2364,10 @@ public: ceph::real_time creation_time, rgw_bucket *master_bucket, bool exclusive = true); - virtual int add_bucket_placement(std::string& new_pool); - virtual int remove_bucket_placement(std::string& new_pool); - virtual int list_placement_set(set& names); - virtual int create_pools(vector& names, vector& retcodes); + int add_bucket_placement(std::string& new_pool); + int remove_bucket_placement(std::string& new_pool); + int list_placement_set(set& names); + int create_pools(vector& names, vector& retcodes); RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; } @@ -2730,9 +2733,9 @@ public: virtual int put_system_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive); - virtual int put_obj_data(void *ctx, rgw_obj& obj, const char *data, + int put_obj_data(void *ctx, rgw_obj& obj, const char *data, off_t ofs, size_t len, bool exclusive); - virtual int aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, + int aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive, void **handle); int put_system_obj(void *ctx, rgw_raw_obj& obj, const char *data, size_t len, bool exclusive, @@ -2746,8 +2749,8 @@ public: return put_system_obj_impl(obj, len, mtime, attrs, flags, bl, objv_tracker, set_mtime); } - virtual int aio_wait(void *handle); - virtual bool aio_completed(void *handle); + int aio_wait(void *handle); + bool aio_completed(void *handle); int on_last_entry_in_listing(RGWBucketInfo& bucket_info, const std::string& obj_prefix, @@ -2847,7 +2850,7 @@ public: * err: stores any errors resulting from the get of the original object * Returns: 0 on success, -ERR# otherwise. */ - virtual int copy_obj(RGWObjectCtx& obj_ctx, + int copy_obj(RGWObjectCtx& obj_ctx, const rgw_user& user_id, const string& client_id, const string& op_id, @@ -2899,7 +2902,7 @@ public: * bucket: the name of the bucket to delete * Returns 0 on success, -ERR# otherwise. */ - virtual int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker); + int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker); bool is_meta_master(); @@ -2918,7 +2921,7 @@ public: int bucket_suspended(rgw_bucket& bucket, bool *suspended); /** Delete an object.*/ - virtual int delete_obj(RGWObjectCtx& obj_ctx, + int delete_obj(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_owner, const rgw_obj& src_obj, int versioning_status, @@ -3040,21 +3043,21 @@ public: void gen_rand_obj_instance_name(rgw_obj *target); int omap_get_vals(rgw_raw_obj& obj, bufferlist& header, const std::string& marker, uint64_t count, std::map& m); - virtual int omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map& m); - virtual int omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl); - virtual int omap_set(rgw_raw_obj& obj, map& m); - virtual int omap_del(rgw_raw_obj& obj, const std::string& key); - virtual int update_containers_stats(map& m); - virtual int append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl); + int omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map& m); + int omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl); + int omap_set(rgw_raw_obj& obj, map& m); + int omap_del(rgw_raw_obj& obj, const std::string& key); + int update_containers_stats(map& m); + int append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl); int watch(const string& oid, uint64_t *watch_handle, librados::WatchCtx2 *ctx); int unwatch(uint64_t watch_handle); void add_watcher(int i); void remove_watcher(int i); virtual bool need_watch_notify() { return false; } - virtual int init_watch(); - virtual void finalize_watch(); - virtual int distribute(const string& key, bufferlist& bl); + int init_watch(); + void finalize_watch(); + int distribute(const string& key, bufferlist& bl); virtual int watch_cb(uint64_t notify_id, uint64_t cookie, uint64_t notifier_id, @@ -3071,6 +3074,10 @@ public: RGWObjectCtx *rctx = static_cast(ctx); rctx->obj.set_prefetch_data(obj); } + void set_prefetch_data(void *ctx, rgw_raw_obj& obj) { + RGWObjectCtx *rctx = static_cast(ctx); + rctx->raw.set_prefetch_data(obj); + } int decode_policy(bufferlist& bl, ACLOwner *owner); int get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ver, string *master_ver, @@ -3095,11 +3102,11 @@ public: int convert_old_bucket_info(RGWObjectCtx& 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); - virtual int get_bucket_info(RGWObjectCtx& obj_ctx, + int get_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs = NULL); - virtual int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, obj_version *pep_objv, + int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, obj_version *pep_objv, map *pattrs, bool create_entry_point); int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid); diff --git a/src/rgw/rgw_replica_log.cc b/src/rgw/rgw_replica_log.cc index b56a90b440f7b..fe7deaf3d4a26 100644 --- a/src/rgw/rgw_replica_log.cc +++ b/src/rgw/rgw_replica_log.cc @@ -39,7 +39,7 @@ int RGWReplicaLogger::open_ioctx(librados::IoCtx& ctx, const string& pool) { int r = store->get_rados_handle()->ioctx_create(pool.c_str(), ctx); if (r == -ENOENT) { - rgw_bucket p(pool.c_str()); + rgw_pool p(pool); r = store->create_pool(p); if (r < 0) return r; diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 27c636562a874..23353a28b8f7e 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -1814,7 +1814,8 @@ bool RGWSwiftWebsiteHandler::is_web_dir() const /* First, get attrset of the object we'll try to retrieve. */ RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - obj_ctx.set_atomic(obj); + obj_ctx.obj.set_atomic(obj); + obj_ctx.obj.set_prefetch_data(obj); RGWObjState* state = nullptr; if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) { @@ -1843,7 +1844,8 @@ bool RGWSwiftWebsiteHandler::is_index_present(const std::string& index) rgw_obj obj(s->bucket, index); RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); - obj_ctx.set_atomic(obj); + obj_ctx.obj.set_atomic(obj); + obj_ctx.obj.set_prefetch_data(obj); RGWObjState* state = nullptr; if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) { diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 65c213fa690bb..d3158a45b246a 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -331,7 +331,7 @@ int RGWMetaSyncStatusManager::init() int num_shards = master_log.get_sync_status().sync_info.num_shards; for (int i = 0; i < num_shards; i++) { - shard_objs[i] = rgw_obj(store->get_zone_params().log_pool, sync_env.shard_obj_name(i)); + shard_objs[i] = rgw_raw_obj(store->get_zone_params().log_pool, sync_env.shard_obj_name(i)); } RWLock::WLocker wl(ts_to_shard_lock); @@ -616,7 +616,8 @@ public: uint32_t lock_duration = cct->_conf->rgw_sync_lease_period; string lock_name = "sync_lock"; RGWRados *store = sync_env->store; - lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_env->status_oid(), + lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()), lock_name, lock_duration, this); lease_cr->get(); lease_stack = spawn(lease_cr, false); @@ -633,8 +634,9 @@ public: yield { set_status("writing sync status"); RGWRados *store = sync_env->store; - call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_env->status_oid(), status)); + call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()), + status)); } if (retcode < 0) { @@ -662,16 +664,19 @@ public: marker.next_step_marker = info.marker; marker.timestamp = info.last_update; RGWRados *store = sync_env->store; - spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_env->shard_obj_name(i), marker), true); + spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env->shard_obj_name(i)), + marker), true); } } yield { set_status("changing sync state: build full sync maps"); status.state = rgw_meta_sync_info::StateBuildingFullSyncMaps; RGWRados *store = sync_env->store; - call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_env->status_oid(), status)); + call(new RGWSimpleRadosWriteCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()), + status)); } set_status("drop lock lease"); yield lease_cr->go_down(); @@ -696,8 +701,7 @@ class RGWReadSyncStatusCoroutine : public RGWSimpleRadosReadCRasync_rados, _sync_env->store, - _sync_env->store->get_zone_params().log_pool, - _sync_env->status_oid(), + rgw_raw_obj(_sync_env->store->get_zone_params().log_pool, _sync_env->status_oid()), &_status->sync_info), sync_env(_sync_env), sync_status(_status) { @@ -716,8 +720,9 @@ int RGWReadSyncStatusCoroutine::handle_data(rgw_meta_sync_info& data) RGWRados *store = sync_env->store; map& markers = sync_status->sync_markers; for (int i = 0; i < (int)data.num_shards; i++) { - spawn(new RGWSimpleRadosReadCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - sync_env->shard_obj_name(i), &markers[i]), true); + spawn(new RGWSimpleRadosReadCR(sync_env->async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env->shard_obj_name(i)), + &markers[i]), true); } return 0; } @@ -791,7 +796,9 @@ public: set_status(string("acquiring lock (") + sync_env->status_oid() + ")"); uint32_t lock_duration = cct->_conf->rgw_sync_lease_period; string lock_name = "sync_lock"; - lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, sync_env->store, sync_env->store->get_zone_params().log_pool, sync_env->status_oid(), + lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, + sync_env->store, + rgw_raw_obj(sync_env->store->get_zone_params().log_pool, sync_env->status_oid()), lock_name, lock_duration, this); lease_cr->get(); lease_stack = spawn(lease_cr, false); @@ -870,8 +877,9 @@ public: 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(sync_env->async_rados, sync_env->store, sync_env->store->get_zone_params().log_pool, - sync_env->shard_obj_name(shard_id), marker), true); + spawn(new RGWSimpleRadosWriteCR(sync_env->async_rados, sync_env->store, + rgw_raw_obj(sync_env->store->get_zone_params().log_pool, sync_env->shard_obj_name(shard_id)), + marker), true); } } @@ -1101,8 +1109,10 @@ public: ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl; RGWRados *store = sync_env->store; - return new RGWSimpleRadosWriteCR(sync_env->async_rados, store, store->get_zone_params().log_pool, - marker_oid, sync_marker); + return new RGWSimpleRadosWriteCR(sync_env->async_rados, + store, + rgw_raw_obj(store->get_zone_params().log_pool, marker_oid), + sync_marker); } }; @@ -1236,7 +1246,7 @@ public: class RGWMetaSyncShardCR : public RGWCoroutine { RGWMetaSyncEnv *sync_env; - const rgw_bucket& pool; + const rgw_pool& pool; const std::string& period; //< currently syncing period id RGWMetadataLog* mdlog; //< log of syncing period uint32_t shard_id; @@ -1284,7 +1294,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine { int total_entries = 0; public: - RGWMetaSyncShardCR(RGWMetaSyncEnv *_sync_env, const rgw_bucket& _pool, + RGWMetaSyncShardCR(RGWMetaSyncEnv *_sync_env, const rgw_pool& _pool, const std::string& period, RGWMetadataLog* mdlog, uint32_t _shard_id, rgw_meta_sync_marker& _marker, const std::string& period_marker, bool *_reset_backoff) @@ -1395,8 +1405,8 @@ public: lease_cr->put(); } RGWRados *store = sync_env->store; - lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, pool, - sync_env->shard_obj_name(shard_id), + lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, + rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)), lock_name, lock_duration, this); lease_cr->get(); lease_stack = spawn(lease_cr, false); @@ -1430,7 +1440,8 @@ public: lost_lock = true; break; } - yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, oid, marker, &entries, max_entries)); + yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid), + marker, &entries, max_entries)); if (retcode < 0) { ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): RGWRadosGetOmapKeysCR() returned ret=" << retcode << dendl; yield lease_cr->go_down(); @@ -1475,8 +1486,8 @@ public: using WriteMarkerCR = RGWSimpleRadosWriteCR; yield call(new WriteMarkerCR(sync_env->async_rados, sync_env->store, - pool, sync_env->shard_obj_name(shard_id), - *temp_marker)); + rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)), + sync_marker)); } if (retcode < 0) { @@ -1525,8 +1536,8 @@ public: uint32_t lock_duration = cct->_conf->rgw_sync_lease_period; string lock_name = "sync_lock"; RGWRados *store = sync_env->store; - lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, pool, - sync_env->shard_obj_name(shard_id), + lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, + rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)), lock_name, lock_duration, this); lease_cr->get(); lease_stack = spawn(lease_cr, false); @@ -1658,7 +1669,7 @@ class RGWMetaSyncShardControlCR : public RGWBackoffControlCR { RGWMetaSyncEnv *sync_env; - const rgw_bucket& pool; + const rgw_pool& pool; const std::string& period; RGWMetadataLog* mdlog; uint32_t shard_id; @@ -1667,7 +1678,7 @@ class RGWMetaSyncShardControlCR : public RGWBackoffControlCR static constexpr bool exit_on_error = false; // retry on all errors public: - RGWMetaSyncShardControlCR(RGWMetaSyncEnv *_sync_env, const rgw_bucket& _pool, + RGWMetaSyncShardControlCR(RGWMetaSyncEnv *_sync_env, const rgw_pool& _pool, const std::string& period, RGWMetadataLog* mdlog, uint32_t _shard_id, const rgw_meta_sync_marker& _marker, std::string&& period_marker) @@ -1682,14 +1693,15 @@ public: RGWCoroutine *alloc_finisher_cr() override { RGWRados *store = sync_env->store; - return new RGWSimpleRadosReadCR(sync_env->async_rados, store, pool, - sync_env->shard_obj_name(shard_id), &sync_marker); + return new RGWSimpleRadosReadCR(sync_env->async_rados, store, + rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)), + &sync_marker); } }; class RGWMetaSyncCR : public RGWCoroutine { RGWMetaSyncEnv *sync_env; - const rgw_bucket& pool; + const rgw_pool& pool; RGWPeriodHistory::Cursor cursor; //< sync position in period history RGWPeriodHistory::Cursor next; //< next period in history rgw_meta_sync_status sync_status; @@ -1786,8 +1798,8 @@ public: sync_status.sync_info.period = cursor.get_period().get_id(); sync_status.sync_info.realm_epoch = cursor.get_epoch(); yield call(new RGWSimpleRadosWriteCR(sync_env->async_rados, - sync_env->store, pool, - sync_env->status_oid(), + sync_env->store, + rgw_raw_obj(pool, sync_env->status_oid()), sync_status.sync_info)); } } @@ -1849,8 +1861,9 @@ int RGWRemoteMetaLog::init_sync_status() int RGWRemoteMetaLog::store_sync_info() { - return run(new RGWSimpleRadosWriteCR(async_rados, store, store->get_zone_params().log_pool, - sync_env.status_oid(), sync_status.sync_info)); + return run(new RGWSimpleRadosWriteCR(async_rados, store, + rgw_raw_obj(store->get_zone_params().log_pool, sync_env.status_oid()), + sync_status.sync_info)); } // return a cursor to the period at our sync position diff --git a/src/rgw/rgw_sync.h b/src/rgw/rgw_sync.h index 5ae136f85ca08..3038f4f7108e0 100644 --- a/src/rgw/rgw_sync.h +++ b/src/rgw/rgw_sync.h @@ -232,7 +232,7 @@ class RGWMetaSyncStatusManager { RGWRemoteMetaLog master_log; - map shard_objs; + map shard_objs; struct utime_shard { real_time ts; diff --git a/src/rgw/rgw_torrent.cc b/src/rgw/rgw_torrent.cc index 124de70470266..723330097a9d5 100644 --- a/src/rgw/rgw_torrent.cc +++ b/src/rgw/rgw_torrent.cc @@ -58,10 +58,9 @@ void seed::get_torrent_file(int &op_ret, RGWRados::Object::Read &read_op, uint64 } string oid, key; - rgw_bucket bucket; map m; set obj_key; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(obj, oid, key); ldout(s->cct, 0) << "NOTICE: head obj oid= " << oid << dendl; obj_key.insert(RGW_OBJ_TORRENT); @@ -268,7 +267,10 @@ int seed::save_torrent_file() string key = RGW_OBJ_TORRENT; rgw_obj obj(s->bucket, s->object.name); - op_ret = store->omap_set(obj, key, bl); + rgw_raw_obj raw_obj; + store->obj_to_raw(obj, &raw_obj); + + op_ret = store->omap_set(raw_obj, key, bl); if (op_ret < 0) { ldout(s->cct, 0) << "ERROR: failed to omap_set() op_ret = " << op_ret << dendl; diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 6c82524d9ea59..679242d94fcc4 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -210,7 +210,7 @@ static RGWChainedCacheImpl uinfo_cache; int rgw_get_user_info_from_index(RGWRados * const store, const string& key, - rgw_bucket& bucket, + rgw_pool& pool, RGWUserInfo& info, RGWObjVersionTracker * const objv_tracker, real_time * const pmtime) @@ -229,7 +229,7 @@ int rgw_get_user_info_from_index(RGWRados * const store, RGWUID uid; RGWObjectCtx obj_ctx(store); - int ret = rgw_get_system_obj(store, obj_ctx, bucket, key, bl, NULL, &e.mtime); + int ret = rgw_get_system_obj(store, obj_ctx, pool, key, bl, NULL, &e.mtime); if (ret < 0) return ret; @@ -342,7 +342,7 @@ int rgw_get_user_attrs_by_uid(RGWRados *store, RGWObjVersionTracker *objv_tracker) { RGWObjectCtx obj_ctx(store); - rgw_obj obj(store->get_zone_params().user_uid_pool, user_id.to_str()); + rgw_raw_obj obj(store->get_zone_params().user_uid_pool, user_id.to_str()); RGWRados::SystemObject src(store, obj_ctx, obj); RGWRados::SystemObject::Read rop(&src); @@ -352,7 +352,7 @@ int rgw_get_user_attrs_by_uid(RGWRados *store, int rgw_remove_key_index(RGWRados *store, RGWAccessKey& access_key) { - rgw_obj obj(store->get_zone_params().user_keys_pool, access_key.id); + rgw_raw_obj obj(store->get_zone_params().user_keys_pool, access_key.id); int ret = store->delete_system_obj(obj); return ret; } @@ -378,13 +378,13 @@ int rgw_remove_email_index(RGWRados *store, string& email) if (email.empty()) { return 0; } - rgw_obj obj(store->get_zone_params().user_email_pool, email); + rgw_raw_obj obj(store->get_zone_params().user_email_pool, email); return store->delete_system_obj(obj); } int rgw_remove_swift_name_index(RGWRados *store, string& swift_name) { - rgw_obj obj(store->get_zone_params().user_swift_pool, swift_name); + rgw_raw_obj obj(store->get_zone_params().user_swift_pool, swift_name); int ret = store->delete_system_obj(obj); return ret; } @@ -457,7 +457,7 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info, RGWObjVersionTracker& ob string buckets_obj_id; rgw_get_buckets_obj(info.user_id, buckets_obj_id); - rgw_obj uid_bucks(store->get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj uid_bucks(store->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); if (ret < 0 && ret != -ENOENT) { @@ -468,7 +468,7 @@ int rgw_delete_user(RGWRados *store, RGWUserInfo& info, RGWObjVersionTracker& ob string key; info.user_id.to_str(key); - rgw_obj uid_obj(store->get_zone_params().user_uid_pool, key); + rgw_raw_obj uid_obj(store->get_zone_params().user_uid_pool, key); ldout(store->ctx(), 10) << "removing user index: " << info.user_id << dendl; ret = store->meta_mgr->remove_entry(user_meta_handler, key, &objv_tracker); if (ret < 0 && ret != -ENOENT && ret != -ECANCELED) { @@ -2701,9 +2701,9 @@ public: return rgw_delete_user(store, info, objv_tracker); } - void get_pool_and_oid(RGWRados *store, const string& key, rgw_bucket& bucket, string& oid) override { + void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override { oid = key; - bucket = store->get_zone_params().user_uid_pool; + pool = store->get_zone_params().user_uid_pool; } int list_keys_init(RGWRados *store, void **phandle) override diff --git a/src/test/rgw/test_rgw_manifest.cc b/src/test/rgw/test_rgw_manifest.cc index 086e7d25f648c..2a121854df5cd 100644 --- a/src/test/rgw/test_rgw_manifest.cc +++ b/src/test/rgw/test_rgw_manifest.cc @@ -29,9 +29,19 @@ #endif using namespace std; +static void populate_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id) +{ + b->tenant = t; + b->name = n; + b->marker = m; + b->bucket_id = id; + b->placement.data_pool = rgw_pool(dp); + b->placement.index_pool = rgw_pool(ip); +} + static void init_bucket(rgw_bucket *bucket, const char *ten, const char *name) { - *bucket = rgw_bucket(ten, name, ".data-pool", ".index-pool", "marker.", "bucket-id", NULL); + populate_bucket(bucket, ten, name, ".data-pool", ".index-pool", "marker.", "bucket-id"); } void append_head(list *objs, rgw_obj& head) diff --git a/src/test/rgw/test_rgw_obj.cc b/src/test/rgw/test_rgw_obj.cc index 79159cacf05d8..3b5a7b6d84adf 100644 --- a/src/test/rgw/test_rgw_obj.cc +++ b/src/test/rgw/test_rgw_obj.cc @@ -30,9 +30,19 @@ #endif using namespace std; +static void populate_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id) +{ + b->tenant = t; + b->name = n; + b->marker = m; + b->bucket_id = id; + b->placement.data_pool = rgw_pool(dp); + b->placement.index_pool = rgw_pool(ip); +} + static void init_bucket(rgw_bucket *bucket, const char *name) { - *bucket = rgw_bucket("", name, ".data-pool", ".index-pool", "marker", "bucket-id", NULL); + populate_bucket(bucket, "", name, ".data-pool", ".index-pool", "marker", "bucket-id"); } void check_parsed_correctly(rgw_obj& obj, const string& name, const string& ns, const string& instance) -- 2.39.5