From 66c2b0c0d66c6019e3f63148eede7802e89d3c51 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 7 Oct 2016 21:03:32 -0700 Subject: [PATCH] rgw: introduce rgw_pool, rgw_raw_obj Pools are represented by rgw_pool (and not rgw_bucket anymore), and we use rgw_raw_obj to reference rados objs and all 'system' objects (vs rgw_obj that is used for rgw objects). Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_bucket.cc | 31 +-- src/rgw/rgw_cache.h | 98 +++---- src/rgw/rgw_common.h | 216 +++++++++++---- src/rgw/rgw_metadata.cc | 2 +- src/rgw/rgw_metadata.h | 2 +- src/rgw/rgw_rados.cc | 594 +++++++++++++++++----------------------- src/rgw/rgw_rados.h | 127 +++++---- src/rgw/rgw_tools.cc | 10 +- src/rgw/rgw_tools.h | 4 +- 9 files changed, 541 insertions(+), 543 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 88e8a5d1532..f7f36c93830 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -113,7 +113,7 @@ int rgw_read_user_buckets(RGWRados * store, buckets.clear(); string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); list entries; bool truncated = false; @@ -155,7 +155,7 @@ int rgw_bucket_sync_user_stats(RGWRados *store, const rgw_user& user_id, rgw_buc { string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); return store->cls_user_sync_bucket_stats(obj, bucket); } @@ -211,7 +211,7 @@ int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); ret = store->cls_user_add_bucket(obj, new_bucket); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: error adding bucket to directory: " @@ -248,7 +248,7 @@ int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id, const string& te cls_user_bucket bucket; bucket.name = bucket_name; - rgw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id); ret = store->cls_user_remove_bucket(obj, bucket); if (ret < 0) { ldout(store->ctx(), 0) << "ERROR: error removing bucket from directory: " @@ -480,8 +480,7 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id, if (actual_bucket.name.compare(bucket.name) != 0 || actual_bucket.tenant.compare(bucket.tenant) != 0 || - actual_bucket.data_pool.compare(bucket.data_pool) != 0 || - actual_bucket.index_pool.compare(bucket.index_pool) != 0 || + actual_bucket.placement.compare(bucket.placement) != 0 || actual_bucket.marker.compare(bucket.marker) != 0 || actual_bucket.bucket_id.compare(bucket.bucket_id) != 0) { cout << "bucket info mismatch: expected " << actual_bucket << " got " << bucket << std::endl; @@ -1395,8 +1394,7 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st 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); ::encode_json("owner", bucket_info.owner, formatter); @@ -2024,9 +2022,9 @@ public: return 0; } - 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().domain_root; + pool = store->get_zone_params().domain_root; } int list_keys_init(RGWRados *store, void **phandle) override @@ -2137,15 +2135,12 @@ public: return ret; } bci.info.bucket.tenant = bucket.tenant; - bci.info.bucket.data_pool = bucket.data_pool; - bci.info.bucket.index_pool = bucket.index_pool; - bci.info.bucket.data_extra_pool = bucket.data_extra_pool; + bci.info.bucket.placement = bucket.placement; bci.info.index_type = rule_info.index_type; } else { /* existing bucket, keep its placement pools */ - bci.info.bucket.data_pool = old_bci.info.bucket.data_pool; - bci.info.bucket.index_pool = old_bci.info.bucket.index_pool; - bci.info.bucket.data_extra_pool = old_bci.info.bucket.data_extra_pool; + bci.info.bucket.placement = old_bci.info.bucket.placement; + bci.info.index_type = old_bci.info.index_type; } // are we actually going to perform this put, or is it too old? @@ -2189,10 +2184,10 @@ public: return rgw_bucket_instance_remove_entry(store, entry, &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 = RGW_BUCKET_INSTANCE_MD_PREFIX + key; rgw_bucket_instance_key_to_oid(oid); - bucket = store->get_zone_params().domain_root; + pool = store->get_zone_params().domain_root; } int list_keys_init(RGWRados *store, void **phandle) override diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 1768caa60c3..af3933108fa 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -94,7 +94,7 @@ WRITE_CLASS_ENCODER(ObjectCacheInfo) struct RGWCacheNotifyInfo { uint32_t op; - rgw_obj obj; + rgw_raw_obj obj; ObjectCacheInfo obj_info; off_t ofs; string ns; @@ -173,25 +173,25 @@ class RGWCache : public T { ObjectCache cache; - int list_objects_raw_init(rgw_bucket& bucket, RGWAccessHandle *handle) { - return T::list_objects_raw_init(bucket, handle); + int list_objects_raw_init(rgw_pool& pool, RGWAccessHandle *handle) { + return T::list_objects_raw_init(pool, handle); } int list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle) { return T::list_objects_raw_next(obj, handle); } - string normal_name(rgw_bucket& bucket, const std::string& oid) { - string& bucket_name = bucket.name; - char buf[bucket_name.size() + 1 + oid.size() + 1]; - const char *bucket_str = bucket_name.c_str(); + string normal_name(rgw_pool& pool, const std::string& oid) { + string& pool_name = pool.name; + char buf[pool_name.size() + 1 + oid.size() + 1]; + const char *pool_str = pool_name.c_str(); const char *oid_str = oid.c_str(); - sprintf(buf, "%s+%s", bucket_str, oid_str); + sprintf(buf, "%s+%s", pool_str, oid_str); return string(buf); } - void normalize_bucket_and_obj(rgw_bucket& src_bucket, const string& src_obj, rgw_bucket& dst_bucket, string& dst_obj); - string normal_name(rgw_obj& obj) { - return normal_name(obj.bucket, obj.get_object()); + void normalize_pool_and_obj(rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj); + string normal_name(rgw_raw_obj& obj) { + return normal_name(obj.pool, obj.oid); } int init_rados() { @@ -208,7 +208,7 @@ class RGWCache : public T return true; } - int distribute_cache(const string& normal_name, rgw_obj& obj, ObjectCacheInfo& obj_info, int op); + int distribute_cache(const string& normal_name, rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op); int watch_cb(uint64_t notify_id, uint64_t cookie, uint64_t notifier_id, @@ -224,27 +224,27 @@ public: cache.chain_cache(cc); } - int system_obj_set_attrs(void *ctx, rgw_obj& obj, + int system_obj_set_attrs(void *ctx, rgw_raw_obj& obj, map& attrs, map* rmattrs, RGWObjVersionTracker *objv_tracker); - int put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime, + int put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, real_time *mtime, map& attrs, int flags, bufferlist& data, RGWObjVersionTracker *objv_tracker, real_time set_mtime); - int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive); + int put_system_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive); int get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state, - RGWObjVersionTracker *objv_tracker, rgw_obj& obj, + RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, rgw_cache_entry_info *cache_info); - int raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, map *attrs, + int raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, map *attrs, bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker); - int delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker); + int delete_system_obj(rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker); bool chain_cache_entry(list& cache_info_entries, RGWChainedCache::Entry *chained_entry) { return cache.chain_cache_entry(cache_info_entries, chained_entry); @@ -252,23 +252,23 @@ public: }; template -void RGWCache::normalize_bucket_and_obj(rgw_bucket& src_bucket, const string& src_obj, rgw_bucket& dst_bucket, string& dst_obj) +void RGWCache::normalize_pool_and_obj(rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj) { if (src_obj.size()) { - dst_bucket = src_bucket; + dst_pool = src_pool; dst_obj = src_obj; } else { - dst_bucket = T::get_zone_params().domain_root; - dst_obj = src_bucket.name; + dst_pool = T::get_zone_params().domain_root; + dst_obj = src_pool.name; } } template -int RGWCache::delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker) +int RGWCache::delete_system_obj(rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); string name = normal_name(obj); cache.remove(name); @@ -281,18 +281,18 @@ int RGWCache::delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_trac template int RGWCache::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state, - RGWObjVersionTracker *objv_tracker, rgw_obj& obj, + RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj, bufferlist& obl, off_t ofs, off_t end, map *attrs, rgw_cache_entry_info *cache_info) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); if (ofs != 0) return T::get_system_obj(obj_ctx, read_state, objv_tracker, obj, obl, ofs, end, attrs, cache_info); - string name = normal_name(obj.bucket, oid); + string name = normal_name(obj.pool, oid); ObjectCacheInfo info; @@ -351,14 +351,14 @@ int RGWCache::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::R } template -int RGWCache::system_obj_set_attrs(void *ctx, rgw_obj& obj, +int RGWCache::system_obj_set_attrs(void *ctx, rgw_raw_obj& obj, map& attrs, map* rmattrs, RGWObjVersionTracker *objv_tracker) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); ObjectCacheInfo info; info.xattrs = attrs; if (rmattrs) @@ -370,7 +370,7 @@ int RGWCache::system_obj_set_attrs(void *ctx, rgw_obj& obj, info.flags |= CACHE_FLAG_OBJV; } int ret = T::system_obj_set_attrs(ctx, obj, attrs, rmattrs, objv_tracker); - string name = normal_name(bucket, oid); + string name = normal_name(pool, oid); if (ret >= 0) { cache.put(name, info, NULL); int r = distribute_cache(name, obj, info, UPDATE_OBJ); @@ -384,15 +384,15 @@ int RGWCache::system_obj_set_attrs(void *ctx, rgw_obj& obj, } template -int RGWCache::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime, +int RGWCache::put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, real_time *mtime, map& attrs, int flags, bufferlist& data, RGWObjVersionTracker *objv_tracker, real_time set_mtime) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); ObjectCacheInfo info; info.xattrs = attrs; info.status = 0; @@ -410,7 +410,7 @@ int RGWCache::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mti } info.meta.mtime = result_mtime; info.meta.size = size; - string name = normal_name(bucket, oid); + string name = normal_name(pool, oid); if (ret >= 0) { cache.put(name, info, NULL); int r = distribute_cache(name, obj, info, UPDATE_OBJ); @@ -424,11 +424,11 @@ int RGWCache::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mti } template -int RGWCache::put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& data, off_t ofs, bool exclusive) +int RGWCache::put_system_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& data, off_t ofs, bool exclusive) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); ObjectCacheInfo info; bool cacheable = false; if ((ofs == 0) || (ofs == -1)) { @@ -440,7 +440,7 @@ int RGWCache::put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& data, } int ret = T::put_system_obj_data(ctx, obj, data, ofs, exclusive); if (cacheable) { - string name = normal_name(bucket, oid); + string name = normal_name(pool, oid); if (ret >= 0) { cache.put(name, info, NULL); int r = distribute_cache(name, obj, info, UPDATE_OBJ); @@ -455,15 +455,15 @@ int RGWCache::put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& data, } template -int RGWCache::raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, +int RGWCache::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *pepoch, map *attrs, bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker) { - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid); + normalize_pool_and_obj(obj.pool, obj.oid, pool, oid); - string name = normal_name(bucket, oid); + string name = normal_name(pool, oid); uint64_t size; real_time mtime; @@ -516,7 +516,7 @@ done: } template -int RGWCache::distribute_cache(const string& normal_name, rgw_obj& obj, ObjectCacheInfo& obj_info, int op) +int RGWCache::distribute_cache(const string& normal_name, rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op) { RGWCacheNotifyInfo info; @@ -548,10 +548,10 @@ int RGWCache::watch_cb(uint64_t notify_id, return -EIO; } - rgw_bucket bucket; + rgw_pool pool; string oid; - normalize_bucket_and_obj(info.obj.bucket, info.obj.get_object(), bucket, oid); - string name = normal_name(bucket, oid); + normalize_pool_and_obj(info.obj.pool, info.obj.oid, pool, oid); + string name = normal_name(pool, oid); switch (info.op) { case UPDATE_OBJ: diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 53f0cbba6cd..b3c347bdf84 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -734,14 +734,143 @@ struct RGWUserInfo }; WRITE_CLASS_ENCODER(RGWUserInfo) +struct rgw_pool { + string name; + + rgw_pool() {} + rgw_pool(const rgw_pool& _p) : name(_p.name) {} + rgw_pool(const string& _name) : name(_name) {} + + const string& to_str() const { + return name; + } + + void init(const string& _name) { + name = _name; + } + + bool empty() const { + return name.empty(); + } + + int compare(const rgw_pool& p) const { + return name.compare(p.name); + } + + void encode(bufferlist& bl) const { + ENCODE_START(10, 10, bl); + ::encode(name, bl); + ENCODE_FINISH(bl); + } + + 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); + if (struct_v < 10) { + bl.seek(start_off); + decode_from_bucket(bl); + return; + } + + ::decode(name, bl); + DECODE_FINISH(bl); + } + + bool operator==(const rgw_pool& p) const { + return (compare(p) == 0); + } + bool operator!=(const rgw_pool& p) const { + return (*this != p); + } +}; +WRITE_CLASS_ENCODER(rgw_pool) + +struct rgw_data_placement_target { + rgw_pool data_pool; + rgw_pool data_extra_pool; + rgw_pool index_pool; + + rgw_data_placement_target() {} + + rgw_data_placement_target(const rgw_pool& _data_pool, const rgw_pool& _data_extra_pool, const rgw_pool& _index_pool) + : data_pool(_data_pool), data_extra_pool(_data_extra_pool), index_pool(_index_pool) {} + + const rgw_pool& get_data_extra_pool() const { + if (data_extra_pool.empty()) { + return data_pool; + } + return data_extra_pool; + } + + int compare(const rgw_data_placement_target& t) { + int c = data_pool.compare(t.data_pool); + if (c != 0) { + return c; + } + c = data_extra_pool.compare(t.data_extra_pool); + if (c != 0) { + return c; + } + return index_pool.compare(t.index_pool); + }; + + void dump(Formatter *f) const; +}; + +inline ostream& operator<<(ostream& out, const rgw_pool& p) { + out << p.name; + return out; +} + +struct rgw_raw_obj { + rgw_pool pool; + std::string oid; + std::string loc; + + rgw_raw_obj() {} + rgw_raw_obj(const rgw_pool& _pool, const std::string& _oid) { + init(_pool, _oid); + } + rgw_raw_obj(const rgw_pool& _pool, const std::string& _oid, const string& _loc) : loc(_loc) { + init(_pool, _oid); + } + + void init(const rgw_pool& _pool, const std::string& _oid) { + pool = _pool; + oid = _oid; + } + + void encode(bufferlist& bl) const { + ENCODE_START(6, 6, bl); + ::encode(pool, bl); + ::encode(oid, bl); + ::encode(loc, bl); + ENCODE_FINISH(bl); + } + void decode(bufferlist::iterator& bl) { + DECODE_START(6, bl); +#warning decode old rgw_obj + ::decode(pool, bl); + ::decode(oid, bl); + ::decode(loc, bl); + DECODE_FINISH(bl); + } +}; +WRITE_CLASS_ENCODER(rgw_raw_obj) + +inline ostream& operator<<(ostream& out, const rgw_raw_obj& o) { + out << o.pool << ":" << o.oid; + return out; +} + struct rgw_bucket { std::string tenant; std::string name; - std::string data_pool; - std::string data_extra_pool; /* if not set, then we should use data_pool instead */ - std::string index_pool; std::string marker; std::string bucket_id; + rgw_data_placement_target placement; std::string oid; /* * runtime in-memory only info. If not empty, points to the bucket instance object @@ -749,31 +878,18 @@ struct rgw_bucket { rgw_bucket() { } // cppcheck-suppress noExplicitConstructor - explicit rgw_bucket(const rgw_user& u, const cls_user_bucket& b) - : tenant(u.tenant), - name(b.name), - data_pool(b.data_pool), - data_extra_pool(b.data_extra_pool), - index_pool(b.index_pool), - marker(b.marker), - bucket_id(b.bucket_id) { - } - rgw_bucket(const string& s) : name(s) { - data_pool = index_pool = s; - marker = ""; - } - rgw_bucket(const char *n) : name(n) { - data_pool = index_pool = n; - marker = ""; - } - rgw_bucket(const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id, const char *h) : - tenant(t), name(n), data_pool(dp), index_pool(ip), marker(m), bucket_id(id) {} + explicit rgw_bucket(const rgw_user& u, const cls_user_bucket& b) : + tenant(u.tenant), + name(b.name), + marker(b.marker), + bucket_id(b.bucket_id), + placement(b.data_pool, b.data_extra_pool, b.index_pool) {} void convert(cls_user_bucket *b) { b->name = name; - b->data_pool = data_pool; - b->data_extra_pool = data_extra_pool; - b->index_pool = index_pool; + b->data_pool = placement.data_pool.to_str(); + b->data_extra_pool = placement.data_extra_pool.to_str(); + b->index_pool = placement.index_pool.to_str(); b->marker = marker; b->bucket_id = bucket_id; } @@ -781,18 +897,18 @@ struct rgw_bucket { void encode(bufferlist& bl) const { ENCODE_START(9, 3, bl); ::encode(name, bl); - ::encode(data_pool, bl); + ::encode(placement.data_pool.name, bl); ::encode(marker, bl); ::encode(bucket_id, bl); - ::encode(index_pool, bl); - ::encode(data_extra_pool, bl); + ::encode(placement.index_pool.name, bl); + ::encode(placement.data_extra_pool.name, bl); ::encode(tenant, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { DECODE_START_LEGACY_COMPAT_LEN(9, 3, 3, bl); ::decode(name, bl); - ::decode(data_pool, bl); + ::decode(placement.data_pool.name, bl); if (struct_v >= 2) { ::decode(marker, bl); if (struct_v <= 3) { @@ -806,12 +922,12 @@ struct rgw_bucket { } } if (struct_v >= 5) { - ::decode(index_pool, bl); + ::decode(placement.index_pool.name, bl); } else { - index_pool = data_pool; + placement.index_pool = placement.data_pool; } if (struct_v >= 7) { - ::decode(data_extra_pool, bl); + ::decode(placement.data_extra_pool.name, bl); } if (struct_v >= 8) { ::decode(tenant, bl); @@ -823,11 +939,8 @@ struct rgw_bucket { std::string get_key(char tenant_delim = '/', char id_delim = ':') const; - const string& get_data_extra_pool() { - if (data_extra_pool.empty()) { - return data_pool; - } - return data_extra_pool; + const rgw_pool& get_data_extra_pool() const { + return placement.get_data_extra_pool(); } void dump(Formatter *f) const; @@ -841,24 +954,7 @@ struct rgw_bucket { WRITE_CLASS_ENCODER(rgw_bucket) inline ostream& operator<<(ostream& out, const rgw_bucket &b) { - out << b.name; - if (b.name.compare(b.data_pool)) { - out << "(@"; - string s; - if (!b.index_pool.empty() && b.data_pool.compare(b.index_pool)) - s = "i=" + b.index_pool; - if (!b.data_extra_pool.empty() && b.data_pool.compare(b.data_extra_pool)) { - if (!s.empty()) { - s += ","; - } - s += "e=" + b.data_extra_pool; - } - if (!s.empty()) { - out << "{" << s << "}"; - } - - out << b.data_pool << "[" << b.marker << "])"; - } + out << b.name << "[" << b.marker << "])"; return out; } @@ -1509,18 +1605,18 @@ public: std::string index_hash_source; rgw_obj() : in_extra_data(false) {} - rgw_obj(rgw_bucket& b, const std::string& o) : in_extra_data(false) { + rgw_obj(const rgw_bucket& b, const std::string& o) : in_extra_data(false) { init(b, o); } - rgw_obj(rgw_bucket& b, const rgw_obj_key& k) : in_extra_data(false) { + rgw_obj(const rgw_bucket& b, const rgw_obj_key& k) : in_extra_data(false) { from_index_key(b, k); } - void init(rgw_bucket& b, const std::string& o) { + void init(const rgw_bucket& b, const std::string& o) { bucket = b; set_obj(o); reset_loc(); } - void init_ns(rgw_bucket& b, const std::string& o, const std::string& n) { + void init_ns(const rgw_bucket& b, const std::string& o, const std::string& n) { bucket = b; set_ns(n); set_obj(o); @@ -1622,7 +1718,7 @@ public: return string(buf) + orig_obj; }; - void from_index_key(rgw_bucket& b, const rgw_obj_key& key) { + void from_index_key(const rgw_bucket& b, const rgw_obj_key& key) { if (key.name[0] != '_') { init(b, key.name); set_instance(key.instance); diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 5c65bcb869d..837b64f7e2c 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_bucket& bucket, string& oid) override {} + 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; } diff --git a/src/rgw/rgw_metadata.h b/src/rgw/rgw_metadata.h index 1b83ae0ae92..d150e6cd36e 100644 --- a/src/rgw/rgw_metadata.h +++ b/src/rgw/rgw_metadata.h @@ -88,7 +88,7 @@ public: } protected: - virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_bucket& bucket, string& oid) = 0; + virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) = 0; /** * Compare an incoming versus on-disk tag/version+mtime combo against * the sync mode to see if the new one should replace the on-disk one. diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0a721d4f73a..586425b1566 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -441,9 +441,7 @@ int RGWSystemMetaObj::init(CephContext *_cct, RGWRados *_store, bool setup_obj, int RGWSystemMetaObj::read_default(RGWDefaultSystemMetaObjInfo& default_info, const string& oid) { - string pool_name = get_pool_name(cct); - - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); bufferlist bl; RGWObjectCtx obj_ctx(store); int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL); @@ -482,10 +480,9 @@ int RGWSystemMetaObj::use_default(bool old_format) int RGWSystemMetaObj::set_as_default(bool exclusive) { - string pool_name = get_pool_name(cct); string oid = get_default_oid(); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); bufferlist bl; RGWDefaultSystemMetaObjInfo default_info; @@ -503,8 +500,7 @@ int RGWSystemMetaObj::set_as_default(bool exclusive) int RGWSystemMetaObj::read_id(const string& obj_name, string& object_id) { - string pool_name = get_pool_name(cct); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); bufferlist bl; string oid = get_names_oid_prefix() + obj_name; @@ -529,8 +525,7 @@ int RGWSystemMetaObj::read_id(const string& obj_name, string& object_id) int RGWSystemMetaObj::delete_obj(bool old_format) { - string pool_name = get_pool_name(cct); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); /* check to see if obj is the default */ RGWDefaultSystemMetaObjInfo default_info; @@ -539,7 +534,7 @@ int RGWSystemMetaObj::delete_obj(bool old_format) return ret; if (default_info.default_id == id || (old_format && default_info.default_id == name)) { string oid = get_default_oid(old_format); - rgw_obj default_named_obj(pool, oid); + rgw_raw_obj default_named_obj(pool, oid); ret = store->delete_system_obj(default_named_obj); if (ret < 0) { ldout(cct, 0) << "Error delete default obj name " << name << ": " << cpp_strerror(-ret) << dendl; @@ -548,7 +543,7 @@ int RGWSystemMetaObj::delete_obj(bool old_format) } if (!old_format) { string oid = get_names_oid_prefix() + name; - rgw_obj object_name(pool, oid); + rgw_raw_obj object_name(pool, oid); ret = store->delete_system_obj(object_name); if (ret < 0) { ldout(cct, 0) << "Error delete obj name " << name << ": " << cpp_strerror(-ret) << dendl; @@ -563,7 +558,7 @@ int RGWSystemMetaObj::delete_obj(bool old_format) oid += id; } - rgw_obj object_id(pool, oid); + rgw_raw_obj object_id(pool, oid); ret = store->delete_system_obj(object_id); if (ret < 0) { ldout(cct, 0) << "Error delete object id " << id << ": " << cpp_strerror(-ret) << dendl; @@ -574,9 +569,7 @@ int RGWSystemMetaObj::delete_obj(bool old_format) int RGWSystemMetaObj::store_name(bool exclusive) { - string pool_name = get_pool_name(cct); - - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); string oid = get_names_oid_prefix() + name; RGWNameToId nameToId; @@ -611,10 +604,9 @@ int RGWSystemMetaObj::rename(const string& new_name) return ret; } /* delete old name */ - string pool_name = get_pool_name(cct); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); string oid = get_names_oid_prefix() + old_name; - rgw_obj old_name_obj(pool, oid); + rgw_raw_obj old_name_obj(pool, oid); ret = store->delete_system_obj(old_name_obj); if (ret < 0) { ldout(cct, 0) << "Error delete old obj name " << old_name << ": " << cpp_strerror(-ret) << dendl; @@ -626,9 +618,8 @@ int RGWSystemMetaObj::rename(const string& new_name) int RGWSystemMetaObj::read_info(const string& obj_id, bool old_format) { - string pool_name = get_pool_name(cct); + rgw_pool pool(get_pool_name(cct)); - rgw_bucket pool(pool_name.c_str()); bufferlist bl; string oid = get_info_oid_prefix(old_format) + obj_id; @@ -695,9 +686,7 @@ int RGWSystemMetaObj::create(bool exclusive) int RGWSystemMetaObj::store_info(bool exclusive) { - string pool_name = get_pool_name(cct); - - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); string oid = get_info_oid_prefix() + id; @@ -785,8 +774,7 @@ int RGWRealm::delete_obj() int RGWRealm::create_control(bool exclusive) { - auto pool_name = get_pool_name(cct); - auto pool = rgw_bucket{pool_name.c_str()}; + auto pool = rgw_pool{get_pool_name(cct)}; auto oid = get_control_oid(); return rgw_put_system_obj(store, pool, oid, nullptr, 0, exclusive, nullptr, real_time(), nullptr); @@ -794,9 +782,8 @@ int RGWRealm::create_control(bool exclusive) int RGWRealm::delete_control() { - auto pool_name = get_pool_name(cct); - auto pool = rgw_bucket{pool_name.c_str()}; - auto obj = rgw_obj{pool, get_control_oid()}; + auto pool = rgw_pool{get_pool_name(cct)}; + auto obj = rgw_raw_obj{pool, get_control_oid()}; return store->delete_system_obj(obj); } @@ -993,10 +980,9 @@ const string RGWPeriod::get_period_oid() int RGWPeriod::read_latest_epoch(RGWPeriodLatestEpochInfo& info) { - string pool_name = get_pool_name(cct); string oid = get_period_oid_prefix() + get_latest_epoch_oid(); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); bufferlist bl; RGWObjectCtx obj_ctx(store); int ret = rgw_get_system_obj(store, obj_ctx, pool, oid, bl, NULL, NULL); @@ -1044,10 +1030,9 @@ int RGWPeriod::use_latest_epoch() int RGWPeriod::set_latest_epoch(epoch_t epoch, bool exclusive) { - string pool_name = get_pool_name(cct); string oid = get_period_oid_prefix() + get_latest_epoch_oid(); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); bufferlist bl; RGWPeriodLatestEpochInfo info; @@ -1061,12 +1046,12 @@ int RGWPeriod::set_latest_epoch(epoch_t epoch, bool exclusive) int RGWPeriod::delete_obj() { - rgw_bucket pool(get_pool_name(cct)); + rgw_pool pool(get_pool_name(cct)); // delete the object for each period epoch for (epoch_t e = 1; e <= epoch; e++) { RGWPeriod p{get_id(), e}; - rgw_obj oid{pool, p.get_period_oid()}; + rgw_raw_obj oid{pool, p.get_period_oid()}; int ret = store->delete_system_obj(oid); if (ret < 0) { ldout(cct, 0) << "WARNING: failed to delete period object " << oid @@ -1075,7 +1060,7 @@ int RGWPeriod::delete_obj() } // delete the .latest_epoch object - rgw_obj oid{pool, get_period_oid_prefix() + get_latest_epoch_oid()}; + rgw_raw_obj oid{pool, get_period_oid_prefix() + get_latest_epoch_oid()}; int ret = store->delete_system_obj(oid); if (ret < 0) { ldout(cct, 0) << "WARNING: failed to delete period object " << oid @@ -1086,9 +1071,8 @@ int RGWPeriod::delete_obj() int RGWPeriod::read_info() { - string pool_name = get_pool_name(cct); + rgw_pool pool(get_pool_name(cct)); - rgw_bucket pool(pool_name.c_str()); bufferlist bl; RGWObjectCtx obj_ctx(store); @@ -1145,9 +1129,8 @@ int RGWPeriod::store_info(bool exclusive) ldout(cct, 0) << "ERROR: RGWPeriod::get_latest_epoch() returned " << cpp_strerror(-ret) << dendl; return ret; } - string pool_name = get_pool_name(cct); - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(get_pool_name(cct)); string oid = get_period_oid(); bufferlist bl; @@ -1549,7 +1532,7 @@ int RGWZoneParams::fix_pool_names() int RGWZoneParams::create(bool exclusive) { /* check for old pools config */ - rgw_obj obj(domain_root, avail_pools); + rgw_raw_obj obj(domain_root, avail_pools); int r = store->raw_obj_stat(obj, NULL, NULL, NULL, NULL, NULL, NULL); if (r < 0) { ldout(store->ctx(), 10) << "couldn't find old data placement pools config, setting up new ones for the zone" << dendl; @@ -2703,32 +2686,18 @@ RGWObjState *RGWObjectCtx::get_state(rgw_obj& obj) { RGWObjState *result; map::iterator iter; lock.get_read(); - if (!obj.get_object().empty()) { - iter = objs_state.find(obj); - if (iter != objs_state.end()) { - result = &iter->second; - lock.unlock(); - } else { - lock.unlock(); - lock.get_write(); - result = &objs_state[obj]; - lock.unlock(); - } - return result; + assert (!obj.get_object().empty()); + iter = objs_state.find(obj); + if (iter != objs_state.end()) { + result = &iter->second; + lock.unlock(); } else { - rgw_obj new_obj(store->get_zone_params().domain_root, obj.bucket.name); - iter = objs_state.find(new_obj); - if (iter != objs_state.end()) { - result = &iter->second; - lock.unlock(); - } else { - lock.unlock(); - lock.get_write(); - result = &objs_state[new_obj]; - lock.unlock(); - } - return result; + lock.unlock(); + lock.get_write(); + result = &objs_state[obj]; + lock.unlock(); } + return result; } void RGWObjectCtx::invalidate(rgw_obj& obj) @@ -2750,22 +2719,14 @@ void RGWObjectCtx::invalidate(rgw_obj& obj) void RGWObjectCtx::set_atomic(rgw_obj& obj) { RWLock::WLocker wl(lock); - if (!obj.get_object().empty()) { - objs_state[obj].is_atomic = true; - } else { - rgw_obj new_obj(store->get_zone_params().domain_root, obj.bucket.name); - objs_state[new_obj].is_atomic = true; - } + assert (!obj.get_object().empty()); + objs_state[obj].is_atomic = true; } void RGWObjectCtx::set_prefetch_data(rgw_obj& obj) { RWLock::WLocker wl(lock); - if (!obj.get_object().empty()) { - objs_state[obj].prefetch_data = true; - } else { - rgw_obj new_obj(store->get_zone_params().domain_root, obj.bucket.name); - objs_state[new_obj].prefetch_data = true; - } + assert (!obj.get_object().empty()); + objs_state[obj].prefetch_data = true; } class RGWMetaNotifierManager : public RGWCoroutinesManager { @@ -3164,9 +3125,9 @@ RGWDataSyncStatusManager* RGWRados::get_data_sync_manager(const std::string& sou int RGWRados::get_required_alignment(rgw_bucket& bucket, uint64_t *alignment) { IoCtx ioctx; - int r = open_bucket_data_ctx(bucket, ioctx); + int r = open_pool_ctx(bucket.placement.data_pool, ioctx); if (r < 0) { - ldout(cct, 0) << "ERROR: open_bucket_data_ctx() returned " << r << dendl; + ldout(cct, 0) << "ERROR: open_pool_ctx() returned " << r << dendl; return r; } @@ -3386,7 +3347,7 @@ int RGWRados::convert_regionmap() } string oid = region_map_oid; - rgw_bucket pool(pool_name.c_str()); + rgw_pool pool(pool_name); bufferlist bl; RGWObjectCtx obj_ctx(this); int ret = rgw_get_system_obj(this, obj_ctx, pool, oid, bl, NULL, NULL); @@ -3427,7 +3388,7 @@ int RGWRados::convert_regionmap() current_period.set_bucket_quota(zonegroupmap.bucket_quota); // remove the region_map so we don't try to convert again - rgw_obj obj(pool, oid); + rgw_raw_obj obj(pool, oid); ret = delete_system_obj(obj); if (ret < 0) { ldout(cct, 0) << "Error could not remove " << obj @@ -4143,9 +4104,8 @@ void RGWRados::schedule_context(Context *c) { finisher->queue(c); } -int RGWRados::list_raw_prefixed_objs(const string& pool_name, const string& prefix, list& result) +int RGWRados::list_raw_prefixed_objs(const rgw_pool& pool, const string& prefix, list& result) { - rgw_bucket pool(pool_name.c_str()); bool is_truncated; RGWListRawObjsCtx ctx; do { @@ -4183,23 +4143,24 @@ int RGWRados::list_zonegroups(list& zonegroups) int RGWRados::list_zones(list& zones) { RGWZoneParams zoneparams; - string pool_name = zoneparams.get_pool_name(cct); + rgw_pool pool(zoneparams.get_pool_name(cct)); - return list_raw_prefixed_objs(pool_name, zone_names_oid_prefix, zones); + return list_raw_prefixed_objs(pool, zone_names_oid_prefix, zones); } int RGWRados::list_realms(list& realms) { RGWRealm realm(cct, this); - string pool_name = realm.get_pool_name(cct); - return list_raw_prefixed_objs(pool_name, realm_names_oid_prefix, realms); + rgw_pool pool(realm.get_pool_name(cct)); + return list_raw_prefixed_objs(pool, realm_names_oid_prefix, realms); } int RGWRados::list_periods(list& periods) { RGWPeriod period; list raw_periods; - int ret = list_raw_prefixed_objs(period.get_pool_name(cct), period.get_info_oid_prefix(), raw_periods); + rgw_pool pool(period.get_pool_name(cct)); + int ret = list_raw_prefixed_objs(pool, period.get_info_oid_prefix(), raw_periods); if (ret < 0) { return ret; } @@ -4381,40 +4342,21 @@ void RGWRados::pick_control_oid(const string& key, string& notify_oid) notify_oid.append(buf); } -int RGWRados::open_pool_ctx(const string& pool, librados::IoCtx& io_ctx) +int RGWRados::open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx) { librados::Rados *rad = get_rados_handle(); - int r = rad->ioctx_create(pool.c_str(), io_ctx); + int r = rad->ioctx_create(pool.name.c_str(), io_ctx); if (r != -ENOENT) return r; if (!pools_initialized) return r; - r = rad->pool_create(pool.c_str()); + r = rad->pool_create(pool.name.c_str()); if (r < 0 && r != -EEXIST) return r; - return rad->ioctx_create(pool.c_str(), io_ctx); -} - -int RGWRados::open_bucket_data_ctx(rgw_bucket& bucket, librados::IoCtx& data_ctx) -{ - int r = open_pool_ctx(bucket.data_pool, data_ctx); - if (r < 0) - return r; - - return 0; -} - -int RGWRados::open_bucket_data_extra_ctx(rgw_bucket& bucket, librados::IoCtx& data_ctx) -{ - string& pool = (!bucket.data_extra_pool.empty() ? bucket.data_extra_pool : bucket.data_pool); - int r = open_pool_ctx(pool, data_ctx); - if (r < 0) - return r; - - return 0; + return rad->ioctx_create(pool.name.c_str(), io_ctx); } void RGWRados::build_bucket_index_marker(const string& shard_id_str, const string& shard_marker, @@ -4428,7 +4370,7 @@ void RGWRados::build_bucket_index_marker(const string& shard_id_str, const strin int RGWRados::open_bucket_index_ctx(rgw_bucket& bucket, librados::IoCtx& index_ctx) { - int r = open_pool_ctx(bucket.index_pool, index_ctx); + int r = open_pool_ctx(bucket.placement.index_pool, index_ctx); if (r < 0) return r; @@ -4786,7 +4728,7 @@ int RGWRados::time_log_add_init(librados::IoCtx& io_ctx) librados::Rados *rad = get_rados_handle(); int r = rad->ioctx_create(log_pool, io_ctx); if (r == -ENOENT) { - rgw_bucket pool(log_pool); + rgw_pool pool(log_pool); r = create_pool(pool); if (r < 0) return r; @@ -5049,7 +4991,7 @@ int RGWRados::objexp_hint_trim(const string& oid, return 0; } -int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, timespan& duration, +int RGWRados::lock_exclusive(rgw_pool& pool, const string& oid, timespan& duration, string& zone_id, string& owner_id) { librados::IoCtx io_ctx; @@ -5071,7 +5013,7 @@ int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, timespan& dura return l.lock_exclusive(&io_ctx, oid); } -int RGWRados::unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id) { +int RGWRados::unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id) { librados::IoCtx io_ctx; const char *pool_name = pool.name.c_str(); @@ -5309,27 +5251,17 @@ done: * create a rados pool, associated meta info * returns 0 on success, -ERR# otherwise. */ -int RGWRados::create_pool(rgw_bucket& bucket) +int RGWRados::create_pool(rgw_pool& pool) { int ret = 0; - string pool = bucket.index_pool; - librados::Rados *rad = get_rados_handle(); - ret = rad->pool_create(pool.c_str(), 0); + ret = rad->pool_create(pool.name.c_str(), 0); if (ret == -EEXIST) ret = 0; if (ret < 0) return ret; - if (bucket.data_pool != pool) { - ret = rad->pool_create(bucket.data_pool.c_str(), 0); - if (ret == -EEXIST) - ret = 0; - if (ret < 0) - return ret; - } - return 0; } @@ -5551,9 +5483,9 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const str RGWZonePlacementInfo& placement_info = piter->second; - bucket.data_pool = placement_info.data_pool; - bucket.data_extra_pool = placement_info.data_extra_pool; - bucket.index_pool = placement_info.index_pool; + bucket.placement.data_pool = placement_info.data_pool; + bucket.placement.data_extra_pool = placement_info.data_extra_pool; + bucket.placement.index_pool = placement_info.index_pool; if (rule_info) { *rule_info = placement_info; @@ -5586,7 +5518,7 @@ int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const st string pool_name; bool write_map = false; - rgw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); RGWObjectCtx obj_ctx(this); int ret = rgw_get_system_obj(this, obj_ctx, get_zone_params().domain_root, avail_pools, map_bl, NULL, NULL); @@ -5651,8 +5583,8 @@ read_omap: miter = m.begin(); pool_name = miter->first; } - bucket.data_pool = pool_name; - bucket.index_pool = pool_name; + bucket.placement.data_pool = pool_name; + bucket.placement.index_pool = pool_name; rule_info->data_pool = pool_name; rule_info->data_extra_pool = pool_name; @@ -5666,7 +5598,7 @@ int RGWRados::update_placement_map() { bufferlist header; map m; - rgw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); int ret = omap_get_all(obj, header, m); if (ret < 0) return ret; @@ -5688,7 +5620,7 @@ int RGWRados::add_bucket_placement(std::string& new_pool) if (ret < 0) // DNE, or something return ret; - rgw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); bufferlist empty_bl; ret = omap_set(obj, new_pool, empty_bl); @@ -5700,7 +5632,7 @@ int RGWRados::add_bucket_placement(std::string& new_pool) int RGWRados::remove_bucket_placement(std::string& old_pool) { - rgw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); int ret = omap_del(obj, old_pool); // don't care about return value @@ -5714,7 +5646,7 @@ int RGWRados::list_placement_set(set& names) bufferlist header; map m; - rgw_obj obj(get_zone_params().domain_root, avail_pools); + rgw_raw_obj obj(get_zone_params().domain_root, avail_pools); int ret = omap_get_all(obj, header, m); if (ret < 0) return ret; @@ -5766,16 +5698,16 @@ int RGWRados::create_pools(vector& names, vector& retcodes) int RGWRados::get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx) { - rgw_bucket bucket; + const rgw_bucket& bucket = obj.bucket; string oid, key; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(obj, oid, key); int r; if (!obj.is_in_extra_data()) { - r = open_bucket_data_ctx(bucket, *ioctx); + r = open_pool_ctx(bucket.placement.data_pool, *ioctx); } else { - r = open_bucket_data_extra_ctx(bucket, *ioctx); + r = open_pool_ctx(bucket.placement.get_data_extra_pool(), *ioctx); } if (r < 0) return r; @@ -5785,42 +5717,28 @@ 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, rgw_bucket *bucket) +int RGWRados::get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool) { - get_obj_bucket_and_oid_loc(obj, *bucket, ref->oid, ref->key); + *pool = obj.pool; + ref->oid = obj.oid; + ref->key.clear(); int r; - if (!obj.is_in_extra_data()) { - r = open_bucket_data_ctx(*bucket, ref->ioctx); - } else { - r = open_bucket_data_extra_ctx(*bucket, ref->ioctx); + if (ref->oid.empty()) { + ref->oid = pool->name; + *pool = get_zone_params().domain_root; } + r = open_pool_ctx(pool->name, ref->ioctx); if (r < 0) return r; - ref->ioctx.locator_set_key(ref->key); - return 0; } -int RGWRados::get_system_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_bucket *bucket) +int RGWRados::get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool) { - get_obj_bucket_and_oid_loc(obj, *bucket, ref->oid, ref->key); - - int r; - - if (ref->oid.empty()) { - ref->oid = bucket->name; - *bucket = get_zone_params().domain_root; - } - r = open_pool_ctx(bucket->name, ref->ioctx); - if (r < 0) - return r; - - ref->ioctx.locator_set_key(ref->key); - - return 0; + return get_raw_obj_ref(obj, ref, pool); } /* @@ -5834,7 +5752,7 @@ int RGWRados::fix_head_obj_locator(rgw_bucket& bucket, bool copy_obj, bool remov rgw_obj obj(bucket, key); - get_obj_bucket_and_oid_loc(obj, bucket, oid, locator); + get_obj_bucket_and_oid_loc(obj, oid, locator); if (locator.empty()) { ldout(cct, 20) << "object does not have a locator, nothing to fix" << dendl; @@ -5987,7 +5905,8 @@ int RGWRados::fix_tail_obj_locator(rgw_bucket& bucket, rgw_obj_key& key, bool fi } rgw_rados_ref ref; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -6011,7 +5930,7 @@ int RGWRados::fix_tail_obj_locator(rgw_bucket& bucket, rgw_obj_key& key, bool fi continue; } - get_obj_bucket_and_oid_loc(loc, bucket, oid, locator); + get_obj_bucket_and_oid_loc(loc, oid, locator); ref.ioctx.locator_set_key(locator); ldout(cct, 20) << __func__ << ": key=" << key << " oid=" << oid << " locator=" << locator << dendl; @@ -6337,7 +6256,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si void *_index_op) { RGWRados::Bucket::UpdateIndex *index_op = static_cast(_index_op); - rgw_bucket bucket; + rgw_pool pool; rgw_rados_ref ref; RGWRados *store = target->get_store(); @@ -6355,7 +6274,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si return -EIO; } - r = store->get_obj_ref(obj, &ref, &bucket); + r = store->get_obj_ref(obj, &ref, &pool); if (r < 0) return r; @@ -6506,7 +6425,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si obj.get_index_key(&obj_key); r = store->objexp_hint_add(meta.delete_at, - bucket.tenant, bucket.name, bucket.bucket_id, obj_key); + obj.bucket.tenant, obj.bucket.name, obj.bucket.bucket_id, obj_key); if (r < 0) { ldout(store->ctx(), 0) << "ERROR: objexp_hint_add() returned r=" << r << ", object will not get removed" << dendl; /* ignoring error, nothing we can do at this point */ @@ -6515,7 +6434,7 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si meta.canceled = false; /* update quota cache */ - store->quota_handler->update_stats(meta.owner, bucket, (orig_exists ? 0 : 1), + store->quota_handler->update_stats(meta.owner, obj.bucket, (orig_exists ? 0 : 1), accounted_size, orig_size); return 0; @@ -6587,15 +6506,15 @@ int RGWRados::Object::Write::write_meta(uint64_t size, uint64_t accounted_size, } /** Write/overwrite a system object. */ -int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime, +int RGWRados::put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, real_time *mtime, map& attrs, int flags, bufferlist& data, RGWObjVersionTracker *objv_tracker, real_time set_mtime /* 0 for don't set */) { - rgw_bucket bucket; + rgw_pool pool; rgw_rados_ref ref; - int r = get_system_obj_ref(obj, &ref, &bucket); + int r = get_system_obj_ref(obj, &ref, &pool); if (r < 0) return r; @@ -6651,12 +6570,12 @@ int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime, return 0; } -int RGWRados::put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, +int RGWRados::put_system_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_system_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_system_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -6706,8 +6625,8 @@ int RGWRados::aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, void **handle) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -7532,7 +7451,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, return ret; } - bool copy_data = !astate->has_manifest || (src_obj.bucket.data_pool != dest_obj.bucket.data_pool); + bool copy_data = !astate->has_manifest || (src_obj.bucket.placement.data_pool != dest_obj.bucket.placement.data_pool); bool copy_first = false; if (astate->has_manifest) { if (!astate->manifest.has_tail()) { @@ -7570,8 +7489,8 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, } rgw_rados_ref ref; - rgw_bucket bucket; - ret = get_obj_ref(miter.get_location(), &ref, &bucket); + rgw_pool pool; + ret = get_obj_ref(miter.get_location(), &ref, &pool); if (ret < 0) { return ret; } @@ -7615,7 +7534,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, ObjectWriteOperation op; cls_refcount_get(op, tag, true); const rgw_obj& loc = miter.get_location(); - get_obj_bucket_and_oid_loc(loc, bucket, oid, key); + get_obj_bucket_and_oid_loc(loc, oid, key); ref.ioctx.locator_set_key(key); ret = ref.ioctx.operate(oid, &op); @@ -7672,7 +7591,7 @@ done_ret: ObjectWriteOperation op; cls_refcount_put(op, tag, true); - get_obj_bucket_and_oid_loc(*riter, bucket, oid, key); + get_obj_bucket_and_oid_loc(*riter, oid, key); ref.ioctx.locator_set_key(key); int r = ref.ioctx.operate(oid, &op); @@ -7967,10 +7886,9 @@ void RGWRados::update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_ if (mobj == head_obj) continue; string oid, loc; - rgw_bucket bucket; - get_obj_bucket_and_oid_loc(mobj, bucket, oid, loc); + get_obj_bucket_and_oid_loc(mobj, oid, loc); cls_rgw_obj_key key(oid); - chain->push_obj(bucket.data_pool, key, loc); + chain->push_obj(mobj.bucket.placement.data_pool, key, loc); } } @@ -8157,9 +8075,8 @@ int RGWRados::bucket_rebuild_index(rgw_bucket& bucket) int RGWRados::defer_gc(void *ctx, rgw_obj& obj) { RGWObjectCtx *rctx = static_cast(ctx); - rgw_bucket bucket; std::string oid, key; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(obj, oid, key); if (!rctx) return 0; @@ -8285,8 +8202,8 @@ int RGWRados::Object::Delete::delete_obj() } rgw_rados_ref ref; - rgw_bucket bucket; - int r = store->get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = store->get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -8396,7 +8313,7 @@ int RGWRados::Object::Delete::delete_obj() return r; /* update quota cache */ - store->quota_handler->update_stats(params.bucket_owner, bucket, -1, 0, obj_size); + store->quota_handler->update_stats(params.bucket_owner, obj.bucket, -1, 0, obj_size); return 0; } @@ -8419,7 +8336,7 @@ int RGWRados::delete_obj(RGWObjectCtx& obj_ctx, return del_op.delete_obj(); } -int RGWRados::delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker) +int RGWRados::delete_system_obj(rgw_raw_obj& obj, RGWObjVersionTracker *objv_tracker) { if (obj.get_object().empty()) { ldout(cct, 1) << "delete_system_obj got empty object name " @@ -8427,8 +8344,8 @@ int RGWRados::delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker return -EINVAL; } rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -8449,16 +8366,15 @@ int RGWRados::delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker int RGWRados::delete_obj_index(rgw_obj& obj) { - rgw_bucket bucket; std::string oid, key; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(obj, oid, key); RGWObjectCtx obj_ctx(this); RGWBucketInfo bucket_info; - int ret = get_bucket_instance_info(obj_ctx, bucket, bucket_info, NULL, NULL); + int ret = get_bucket_instance_info(obj_ctx, obj.bucket, bucket_info, NULL, NULL); if (ret < 0) { - ldout(cct, 0) << "ERROR: " << __func__ << "() get_bucket_instance_info(bucket=" << bucket << ") returned ret=" << ret << dendl; + ldout(cct, 0) << "ERROR: " << __func__ << "() get_bucket_instance_info(bucket=" << obj.bucket << ") returned ret=" << ret << dendl; return ret; } @@ -8533,7 +8449,7 @@ int RGWRados::get_olh_target_state(RGWObjectCtx& obj_ctx, rgw_obj& obj, RGWObjSt return 0; } -int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker) +int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker) { RGWObjState *s = rctx->get_state(obj); ldout(cct, 20) << "get_system_obj_state: rctx=" << (void *)rctx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl; @@ -8567,7 +8483,7 @@ int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObj return 0; } -int RGWRados::get_system_obj_state(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker) +int RGWRados::get_system_obj_state(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker) { int ret; @@ -8783,8 +8699,7 @@ int RGWRados::Object::Stat::stat_async() string oid; string loc; - rgw_bucket bucket; - get_obj_bucket_and_oid_loc(obj, bucket, oid, loc); + get_obj_bucket_and_oid_loc(obj, oid, loc); int r = store->get_obj_ioctx(obj, &state.io_ctx); if (r < 0) { @@ -8852,11 +8767,11 @@ int RGWRados::Object::Stat::finish() * dest: bufferlist to store the result in * Returns: 0 on success, -ERR# otherwise. */ -int RGWRados::system_obj_get_attr(rgw_obj& obj, const char *name, bufferlist& dest) +int RGWRados::system_obj_get_attr(rgw_raw_obj& obj, const char *name, bufferlist& dest) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_system_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_system_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -8997,7 +8912,7 @@ int RGWRados::Object::prepare_atomic_modification(ObjectWriteOperation& op, bool return 0; } -int RGWRados::system_obj_set_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& bl, +int RGWRados::system_obj_set_attr(void *ctx, rgw_raw_obj& obj, const char *name, bufferlist& bl, RGWObjVersionTracker *objv_tracker) { map attrs; @@ -9005,14 +8920,14 @@ int RGWRados::system_obj_set_attr(void *ctx, rgw_obj& obj, const char *name, buf return system_obj_set_attrs(ctx, obj, attrs, NULL, objv_tracker); } -int RGWRados::system_obj_set_attrs(void *ctx, rgw_obj& obj, +int RGWRados::system_obj_set_attrs(void *ctx, rgw_raw_obj& obj, map& attrs, map* rmattrs, RGWObjVersionTracker *objv_tracker) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_system_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_system_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -9072,8 +8987,8 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj, map* rmattrs) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -9094,6 +9009,8 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj, } } + const rgw_bucket& bucket = obj.bucket; + for (iter = attrs.begin(); iter != attrs.end(); ++iter) { const string& name = iter->first; bufferlist& bl = iter->second; @@ -9327,7 +9244,7 @@ int RGWRados::SystemObject::get_state(RGWObjState **pstate, RGWObjVersionTracker int RGWRados::stat_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& state, - rgw_obj& obj, + rgw_raw_obj& obj, map *attrs, real_time *lastmod, uint64_t *obj_size, @@ -9364,7 +9281,7 @@ int RGWRados::stat_system_obj(RGWObjectCtx& obj_ctx, int RGWRados::SystemObject::Read::stat(RGWObjVersionTracker *objv_tracker) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); + rgw_raw_obj& obj = source->get_obj(); return store->stat_system_obj(source->get_ctx(), state, obj, stat_params.attrs, stat_params.lastmod, stat_params.obj_size, objv_tracker); @@ -9504,7 +9421,6 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) RGWRados *store = source->get_store(); CephContext *cct = store->ctx(); - rgw_bucket bucket; std::string oid, key; rgw_obj read_obj = state.obj; uint64_t read_ofs = ofs; @@ -9518,7 +9434,7 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) uint64_t max_chunk_size; - get_obj_bucket_and_oid_loc(state.obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(state.obj, oid, key); RGWObjState *astate; int r = source->get_state(&astate, true); @@ -9541,13 +9457,13 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) reading_from_head = (read_obj == state.obj); if (!reading_from_head) { - get_obj_bucket_and_oid_loc(read_obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(read_obj, oid, key); } } - r = store->get_max_chunk_size(bucket, &max_chunk_size); + r = store->get_max_chunk_size(read_obj.bucket, &max_chunk_size); if (r < 0) { - ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << bucket << dendl; + ldout(cct, 0) << "ERROR: failed to get max_chunk_size() for bucket " << read_obj.bucket << dendl; return r; } @@ -9602,33 +9518,30 @@ int RGWRados::Object::Read::read(int64_t ofs, int64_t end, bufferlist& bl) return bl.length(); } -int RGWRados::SystemObject::Read::GetObjState::get_ioctx(RGWRados *store, rgw_obj& obj, librados::IoCtx **ioctx) +int RGWRados::SystemObject::Read::GetObjState::get_ref(RGWRados *store, rgw_raw_obj& obj, rgw_rados_ref **pref) { - if (!has_ioctx) { - int r = store->get_obj_ioctx(obj, &io_ctx); + if (!has_ref) { + rgw_pool pool; + int r = store->get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } - has_ioctx = true; + has_ref = true; } - *ioctx = &io_ctx; + *pref = &ref; return 0; } int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state, - RGWObjVersionTracker *objv_tracker, rgw_obj& obj, + RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, rgw_cache_entry_info *cache_info) { - rgw_bucket bucket; - std::string oid, key; uint64_t len; ObjectReadOperation op; - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); - if (end < 0) len = 0; else @@ -9645,20 +9558,20 @@ int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read op.getxattrs(attrs, NULL); } - librados::IoCtx *io_ctx; - int r = read_state.get_ioctx(this, obj, &io_ctx); + rgw_rados_ref *ref; + int r = read_state.get_ref(this, obj, &ref); if (r < 0) { - ldout(cct, 20) << "get_ioctx() on obj=" << obj << " returned " << r << dendl; + ldout(cct, 20) << "read_state.get_ref() on obj=" << obj << " returned " << r << dendl; return r; } - r = io_ctx->operate(oid, &op, NULL); + r = ref->ioctx.operate(ref->oid, &op, NULL); if (r < 0) { ldout(cct, 20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl; return r; } ldout(cct, 20) << "rados->read r=" << r << " bl.length=" << bl.length() << dendl; - uint64_t op_ver = io_ctx->get_last_version(); + uint64_t op_ver = ref->ioctx.get_last_version(); if (read_state.last_ver > 0 && read_state.last_ver != op_ver) { @@ -9674,7 +9587,7 @@ int RGWRados::get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read int RGWRados::SystemObject::Read::read(int64_t ofs, int64_t end, bufferlist& bl, RGWObjVersionTracker *objv_tracker) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); + rgw_raw_obj& obj = source->get_obj(); return store->get_system_obj(source->get_ctx(), state, objv_tracker, obj, bl, ofs, end, read_params.attrs, read_params.cache_info); } @@ -9682,7 +9595,7 @@ int RGWRados::SystemObject::Read::read(int64_t ofs, int64_t end, bufferlist& bl, int RGWRados::SystemObject::Read::get_attr(const char *name, bufferlist& dest) { RGWRados *store = source->get_store(); - rgw_obj& obj = source->get_obj(); + rgw_raw_obj& obj = source->get_obj(); return store->system_obj_get_attr(obj, name, dest); } @@ -9969,7 +9882,6 @@ int RGWRados::get_obj_iterate_cb(RGWObjectCtx *ctx, RGWObjState *astate, ObjectReadOperation op; struct get_obj_data *d = (struct get_obj_data *)arg; string oid, key; - rgw_bucket bucket; bufferlist *pbl; AioCompletion *c; @@ -10003,7 +9915,7 @@ int RGWRados::get_obj_iterate_cb(RGWObjectCtx *ctx, RGWObjState *astate, } } - get_obj_bucket_and_oid_loc(obj, bucket, oid, key); + get_obj_bucket_and_oid_loc(obj, oid, key); d->throttle.get(len); if (d->is_cancelled()) { @@ -10088,7 +10000,6 @@ int RGWRados::iterate_obj(RGWObjectCtx& obj_ctx, rgw_obj& obj, int (*iterate_obj_cb)(rgw_obj&, off_t, off_t, off_t, bool, RGWObjState *, void *), void *arg) { - rgw_bucket bucket; rgw_obj read_obj = obj; uint64_t read_ofs = ofs; uint64_t len; @@ -10154,8 +10065,8 @@ int RGWRados::iterate_obj(RGWObjectCtx& obj_ctx, rgw_obj& obj, int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -10166,8 +10077,8 @@ int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op) int RGWRados::obj_operate(rgw_obj& obj, ObjectReadOperation *op) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -10295,14 +10206,14 @@ 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_bucket bucket; - int r = get_obj_ref(obj_instance, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj_instance, &ref, &pool); if (r < 0) { return r; } BucketShard bs(this); - int ret = bs.init(bucket, obj_instance); + int ret = bs.init(obj_instance.bucket, obj_instance); if (ret < 0) { ldout(cct, 5) << "bs.init() returned ret=" << ret << dendl; return ret; @@ -10328,14 +10239,14 @@ 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_bucket bucket; - int r = get_obj_ref(obj_instance, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj_instance, &ref, &pool); if (r < 0) { return r; } BucketShard bs(this); - int ret = bs.init(bucket, obj_instance); + int ret = bs.init(obj_instance.bucket, obj_instance); if (ret < 0) { ldout(cct, 5) << "bs.init() returned ret=" << ret << dendl; return ret; @@ -10355,14 +10266,14 @@ int RGWRados::bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instanc bool *is_truncated) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj_instance, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj_instance, &ref, &pool); if (r < 0) { return r; } BucketShard bs(this); - int ret = bs.init(bucket, obj_instance); + int ret = bs.init(obj_instance.bucket, obj_instance); if (ret < 0) { ldout(cct, 5) << "bs.init() returned ret=" << ret << dendl; return ret; @@ -10384,14 +10295,14 @@ 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_bucket bucket; - int r = get_obj_ref(obj_instance, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj_instance, &ref, &pool); if (r < 0) { return r; } BucketShard bs(this); - int ret = bs.init(bucket, obj_instance); + int ret = bs.init(obj_instance.bucket, obj_instance); if (ret < 0) { ldout(cct, 5) << "bs.init() returned ret=" << ret << dendl; return ret; @@ -10415,14 +10326,14 @@ 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_bucket bucket; - int r = get_obj_ref(obj_instance, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj_instance, &ref, &pool); if (r < 0) { return r; } BucketShard bs(this); - int ret = bs.init(bucket, obj_instance); + int ret = bs.init(obj_instance.bucket, obj_instance); if (ret < 0) { ldout(cct, 5) << "bs.init() returned ret=" << ret << dendl; return ret; @@ -10498,12 +10409,14 @@ int RGWRados::apply_olh_log(RGWObjectCtx& obj_ctx, RGWObjState& state, RGWBucket } rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } + const rgw_bucket& bucket = obj.bucket; + if (need_to_link) { rgw_obj target(bucket, key); RGWOLHInfo info; @@ -10811,8 +10724,8 @@ int RGWRados::remove_olh_pending_entries(RGWObjState& state, rgw_obj& olh_obj, m } rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(olh_obj, &ref, &bucket); + rgw_pool pool; + int r = get_obj_ref(olh_obj, &ref, &pool); if (r < 0) { return r; } @@ -10884,13 +10797,13 @@ int RGWRados::follow_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, rgw_obj& olh return 0; } -int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, +int RGWRados::raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, map *attrs, bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -11120,7 +11033,7 @@ void RGWRados::get_bucket_meta_oid(const rgw_bucket& bucket, string& oid) oid = RGW_BUCKET_INSTANCE_MD_PREFIX + bucket.get_key(':'); } -void RGWRados::get_bucket_instance_obj(const rgw_bucket& bucket, rgw_obj& obj) +void RGWRados::get_bucket_instance_obj(const rgw_bucket& bucket, rgw_raw_obj& obj) { if (!bucket.oid.empty()) { obj.init(get_zone_params().domain_root, bucket.oid); @@ -11144,7 +11057,7 @@ int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta return get_bucket_instance_from_oid(obj_ctx, oid, info, pmtime, pattrs); } -int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, +int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, real_time *pmtime, map *pattrs) { string oid; @@ -11399,11 +11312,11 @@ int RGWRados::put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, real_t return 0; } -int RGWRados::omap_get_vals(rgw_obj& obj, bufferlist& header, const string& marker, uint64_t count, std::map& m) +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_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -11416,7 +11329,7 @@ int RGWRados::omap_get_vals(rgw_obj& obj, bufferlist& header, const string& mark } -int RGWRados::omap_get_all(rgw_obj& obj, bufferlist& header, +int RGWRados::omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map& m) { rgw_rados_ref ref; @@ -11445,15 +11358,15 @@ int RGWRados::omap_get_all(rgw_obj& obj, bufferlist& header, return 0; } -int RGWRados::omap_set(rgw_obj& obj, std::string& key, bufferlist& bl) +int RGWRados::omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } - ldout(cct, 15) << "omap_set bucket=" << bucket << " oid=" << ref.oid << " key=" << key << dendl; + ldout(cct, 15) << "omap_set pool=" << pool << " oid=" << ref.oid << " key=" << key << dendl; map m; m[key] = bl; @@ -11463,11 +11376,11 @@ int RGWRados::omap_set(rgw_obj& obj, std::string& key, bufferlist& bl) return r; } -int RGWRados::omap_set(rgw_obj& obj, std::map& m) +int RGWRados::omap_set(rgw_raw_obj& obj, std::map& m) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -11477,11 +11390,11 @@ int RGWRados::omap_set(rgw_obj& obj, std::map& m) return r; } -int RGWRados::omap_del(rgw_obj& obj, const std::string& key) +int RGWRados::omap_del(rgw_raw_obj& obj, const std::string& key) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -11524,11 +11437,11 @@ int RGWRados::update_containers_stats(map& m) return m.size(); } -int RGWRados::append_async(rgw_obj& obj, size_t size, bufferlist& bl) +int RGWRados::append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -11557,12 +11470,12 @@ int RGWRados::distribute(const string& key, bufferlist& bl) return control_pool_ctx.notify2(notify_oid, bl, 0, NULL); } -int RGWRados::pool_iterate_begin(rgw_bucket& bucket, RGWPoolIterCtx& ctx) +int RGWRados::pool_iterate_begin(const rgw_pool& pool, RGWPoolIterCtx& ctx) { librados::IoCtx& io_ctx = ctx.io_ctx; librados::NObjectIterator& iter = ctx.iter; - int r = open_bucket_data_ctx(bucket, io_ctx); + int r = open_pool_ctx(pool, io_ctx); if (r < 0) return r; @@ -11610,7 +11523,7 @@ struct RGWAccessListFilterPrefix : public RGWAccessListFilter { } }; -int RGWRados::list_raw_objects(rgw_bucket& pool, const string& prefix_filter, +int RGWRados::list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max, RGWListRawObjsCtx& ctx, list& oids, bool *is_truncated) { @@ -11763,15 +11676,15 @@ 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_bucket bucket; + rgw_pool pool; rgw_rados_ref ref; - int r = get_obj_ref(obj, &ref, &bucket); + int r = get_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } rgw_cls_bi_entry bi_entry; - r = bi_get(bucket, obj, InstanceIdx, &bi_entry); + r = bi_get(obj.bucket, obj, InstanceIdx, &bi_entry); if (r < 0 && r != -ENOENT) { ldout(cct, 0) << "ERROR: bi_get() returned r=" << r << dendl; } @@ -12144,44 +12057,37 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, int shard_id, rgw_obj_key& sta int RGWRados::cls_obj_usage_log_add(const string& oid, rgw_usage_log_info& info) { - librados::IoCtx io_ctx; + rgw_raw_obj obj(get_zone_params().usage_log_pool, oid); - const char *usage_log_pool = get_zone_params().usage_log_pool.name.c_str(); - librados::Rados *rad = get_rados_handle(); - int r = rad->ioctx_create(usage_log_pool, io_ctx); - if (r == -ENOENT) { - rgw_bucket pool(usage_log_pool); - r = create_pool(pool); - if (r < 0) - return r; - - // retry - r = rad->ioctx_create(usage_log_pool, io_ctx); - } - if (r < 0) + rgw_rados_ref ref; + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); + if (r < 0) { return r; + } ObjectWriteOperation op; cls_rgw_usage_log_add(op, info); - r = io_ctx.operate(oid, &op); + r = ref.ioctx.operate(ref.oid, &op); return r; } int RGWRados::cls_obj_usage_log_read(string& oid, string& user, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, string& read_iter, map& usage, bool *is_truncated) { - librados::IoCtx io_ctx; + rgw_raw_obj obj(get_zone_params().usage_log_pool, oid); - *is_truncated = false; - - const char *usage_log_pool = get_zone_params().usage_log_pool.name.c_str(); - librados::Rados *rad = get_rados_handle(); - int r = rad->ioctx_create(usage_log_pool, io_ctx); - if (r < 0) + rgw_rados_ref ref; + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); + if (r < 0) { return r; + } - r = cls_rgw_usage_log_read(io_ctx, oid, user, start_epoch, end_epoch, + *is_truncated = false; + + r = cls_rgw_usage_log_read(ref.ioctx, ref.oid, user, start_epoch, end_epoch, max_entries, read_iter, usage, is_truncated); return r; @@ -12189,18 +12095,19 @@ int RGWRados::cls_obj_usage_log_read(string& oid, string& user, uint64_t start_e int RGWRados::cls_obj_usage_log_trim(string& oid, string& user, uint64_t start_epoch, uint64_t end_epoch) { - librados::IoCtx io_ctx; + rgw_raw_obj obj(get_zone_params().usage_log_pool, oid); - const char *usage_log_pool = get_zone_params().usage_log_pool.name.c_str(); - librados::Rados *rad = get_rados_handle(); - int r = rad->ioctx_create(usage_log_pool, io_ctx); - if (r < 0) + rgw_rados_ref ref; + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); + if (r < 0) { return r; + } ObjectWriteOperation op; cls_rgw_usage_log_trim(op, user, start_epoch, end_epoch); - r = io_ctx.operate(oid, &op); + r = ref.ioctx.operate(ref.oid, &op); return r; } @@ -12257,7 +12164,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx, obj.set_loc(list_state.locator); obj.set_ns(ns); obj.set_instance(key.instance); - get_obj_bucket_and_oid_loc(obj, bucket, oid, loc); + get_obj_bucket_and_oid_loc(obj, oid, loc); io_ctx.locator_set_key(loc); RGWObjState *astate = NULL; @@ -12391,11 +12298,11 @@ int RGWRados::cls_user_get_header(const string& user_id, cls_user_header *header { string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -12417,11 +12324,11 @@ int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_ { string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -12433,7 +12340,7 @@ int RGWRados::cls_user_get_header_async(const string& user_id, RGWGetUserHeader_ return 0; } -int RGWRados::cls_user_sync_bucket_stats(rgw_obj& user_obj, rgw_bucket& bucket) +int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& bucket) { map headers; int r = cls_bucket_head(bucket, RGW_NO_SHARD, headers); @@ -12482,7 +12389,7 @@ int RGWRados::update_user_bucket_stats(const string& user_id, rgw_bucket& bucket string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); int r = cls_user_update_buckets(obj, entries, false); if (r < 0) { @@ -12493,7 +12400,7 @@ int RGWRados::update_user_bucket_stats(const string& user_id, rgw_bucket& bucket return 0; } -int RGWRados::cls_user_list_buckets(rgw_obj& obj, +int RGWRados::cls_user_list_buckets(rgw_raw_obj& obj, const string& in_marker, const string& end_marker, const int max_entries, @@ -12502,8 +12409,8 @@ int RGWRados::cls_user_list_buckets(rgw_obj& obj, bool * const truncated) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -12522,11 +12429,11 @@ int RGWRados::cls_user_list_buckets(rgw_obj& obj, return 0; } -int RGWRados::cls_user_update_buckets(rgw_obj& obj, list& entries, bool add) +int RGWRados::cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -12544,15 +12451,15 @@ int RGWRados::complete_sync_user_stats(const rgw_user& user_id) { string buckets_obj_id; rgw_get_buckets_obj(user_id, buckets_obj_id); - rgw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); + rgw_raw_obj obj(get_zone_params().user_uid_pool, buckets_obj_id); return cls_user_complete_stats_sync(obj); } -int RGWRados::cls_user_complete_stats_sync(rgw_obj& obj) +int RGWRados::cls_user_complete_stats_sync(rgw_raw_obj& obj) { rgw_rados_ref ref; - rgw_bucket bucket; - int r = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int r = get_raw_obj_ref(obj, &ref, &pool); if (r < 0) { return r; } @@ -12566,7 +12473,7 @@ int RGWRados::cls_user_complete_stats_sync(rgw_obj& obj) return 0; } -int RGWRados::cls_user_add_bucket(rgw_obj& obj, const cls_user_bucket_entry& entry) +int RGWRados::cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry) { list l; l.push_back(entry); @@ -12574,11 +12481,11 @@ int RGWRados::cls_user_add_bucket(rgw_obj& obj, const cls_user_bucket_entry& ent return cls_user_update_buckets(obj, l, true); } -int RGWRados::cls_user_remove_bucket(rgw_obj& obj, const cls_user_bucket& bucket) +int RGWRados::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket) { - rgw_bucket b; + rgw_pool p; rgw_rados_ref ref; - int r = get_obj_ref(obj, &ref, &b); + int r = get_system_obj_ref(obj, &ref, &p); if (r < 0) { return r; } @@ -13060,7 +12967,8 @@ int RGWRados::delete_obj_aio(rgw_obj& obj, rgw_bucket& bucket, list& handles, bool keep_index_consistent) { rgw_rados_ref ref; - int ret = get_obj_ref(obj, &ref, &bucket); + rgw_pool pool; + int ret = get_obj_ref(obj, &ref, &pool); 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 70a651a4311..31cd933a038 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -51,7 +51,7 @@ class RGWRESTConn; #define MAX_BUCKET_INDEX_SHARDS_PRIME 7877 -static inline void prepend_bucket_marker(rgw_bucket& bucket, const string& orig_oid, string& oid) +static inline void prepend_bucket_marker(const rgw_bucket& bucket, const string& orig_oid, string& oid) { if (bucket.marker.empty() || orig_oid.empty()) { oid = orig_oid; @@ -62,9 +62,9 @@ static inline void prepend_bucket_marker(rgw_bucket& bucket, const string& orig_ } } -static inline void get_obj_bucket_and_oid_loc(const rgw_obj& obj, rgw_bucket& bucket, string& oid, string& locator) +static inline void get_obj_bucket_and_oid_loc(const rgw_obj& obj, string& oid, string& locator) { - bucket = obj.bucket; + const rgw_bucket& bucket = obj.bucket; prepend_bucket_marker(bucket, obj.get_object(), oid); const string& loc = obj.get_loc(); if (!loc.empty()) { @@ -976,20 +976,20 @@ struct RGWZonePlacementInfo { WRITE_CLASS_ENCODER(RGWZonePlacementInfo) struct RGWZoneParams : RGWSystemMetaObj { - rgw_bucket domain_root; - rgw_bucket metadata_heap; - rgw_bucket control_pool; - rgw_bucket gc_pool; - rgw_bucket lc_pool; - rgw_bucket log_pool; - rgw_bucket intent_log_pool; - rgw_bucket usage_log_pool; - - rgw_bucket user_keys_pool; - rgw_bucket user_email_pool; - rgw_bucket user_swift_pool; - rgw_bucket user_uid_pool; - rgw_bucket roles_pool; + rgw_pool domain_root; + rgw_pool metadata_heap; + rgw_pool control_pool; + rgw_pool gc_pool; + rgw_pool lc_pool; + rgw_pool log_pool; + rgw_pool intent_log_pool; + rgw_pool usage_log_pool; + + rgw_pool user_keys_pool; + rgw_pool user_email_pool; + rgw_pool user_swift_pool; + rgw_pool user_uid_pool; + rgw_pool roles_pool; RGWAccessKey system_key; @@ -1075,7 +1075,7 @@ struct RGWZoneParams : RGWSystemMetaObj { if (struct_v >= 7) { ::decode(lc_pool, bl); } else { - lc_pool = name + ".rgw.lc"; + lc_pool.init(name + ".rgw.lc"); } if (struct_v >= 8) { ::decode(tier_config, bl); @@ -1904,10 +1904,8 @@ class RGWRados int open_lc_pool_ctx(); int open_objexp_pool_ctx(); - int open_pool_ctx(const string& pool, librados::IoCtx& io_ctx); + int open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx); int open_bucket_index_ctx(rgw_bucket& bucket, librados::IoCtx& index_ctx); - int open_bucket_data_ctx(rgw_bucket& bucket, librados::IoCtx& io_ctx); - int open_bucket_data_extra_ctx(rgw_bucket& bucket, librados::IoCtx& io_ctx); int open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, string& bucket_oid); int open_bucket_index_base(rgw_bucket& bucket, librados::IoCtx& index_ctx, string& bucket_oid_base); @@ -1966,13 +1964,14 @@ 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_bucket *bucket); - int get_system_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_bucket *bucket); + 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); + int get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool); uint64_t max_bucket_id; int get_olh_target_state(RGWObjectCtx& rctx, rgw_obj& obj, RGWObjState *olh_state, RGWObjState **target_state); - int get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker); + int get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker); int get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, bool follow_olh, bool assume_noent = false); int append_atomic_test(RGWObjectCtx *rctx, rgw_obj& obj, librados::ObjectOperation& op, RGWObjState **state); @@ -2183,11 +2182,11 @@ public: return MAX_BUCKET_INDEX_SHARDS_PRIME; } - int list_raw_objects(rgw_bucket& pool, const string& prefix_filter, int max, + int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max, RGWListRawObjsCtx& ctx, list& oids, bool *is_truncated); - int list_raw_prefixed_objs(const string& pool_name, const string& prefix, list& result); + int list_raw_prefixed_objs(const rgw_pool& pool, const string& prefix, list& result); int list_zonegroups(list& zonegroups); int list_regions(list& regions); int list_zones(list& zones); @@ -2243,7 +2242,7 @@ public: bool *is_truncated, RGWUsageIter& read_iter, map& usage); int trim_usage(rgw_user& user, uint64_t start_epoch, uint64_t end_epoch); - virtual int create_pool(rgw_bucket& bucket); + int create_pool(rgw_pool& bucket); /** * create a bucket with name bucket and the given list of attrs @@ -2283,7 +2282,7 @@ public: class SystemObject { RGWRados *store; RGWObjectCtx& ctx; - rgw_obj obj; + rgw_raw_obj obj; RGWObjState *state; @@ -2291,23 +2290,23 @@ public: int get_state(RGWObjState **pstate, RGWObjVersionTracker *objv_tracker); public: - SystemObject(RGWRados *_store, RGWObjectCtx& _ctx, rgw_obj& _obj) : store(_store), ctx(_ctx), obj(_obj), state(NULL) {} + SystemObject(RGWRados *_store, RGWObjectCtx& _ctx, rgw_raw_obj& _obj) : store(_store), ctx(_ctx), obj(_obj), state(NULL) {} RGWRados *get_store() { return store; } - rgw_obj& get_obj() { return obj; } + rgw_raw_obj& get_obj() { return obj; } RGWObjectCtx& get_ctx() { return ctx; } struct Read { RGWRados::SystemObject *source; struct GetObjState { - librados::IoCtx io_ctx; - bool has_ioctx; - uint64_t last_ver; + rgw_rados_ref ref; + bool has_ref{false}; + uint64_t last_ver{0}; - GetObjState() : has_ioctx(false), last_ver(0) {} + GetObjState() {} - int get_ioctx(RGWRados *store, rgw_obj& obj, librados::IoCtx **ioctx); + int get_ref(RGWRados *store, rgw_raw_obj& obj, rgw_rados_ref **pref); } state; struct StatParams { @@ -2634,20 +2633,20 @@ public: }; /** Write/overwrite an object to the bucket storage. */ - virtual int put_system_obj_impl(rgw_obj& obj, uint64_t size, ceph::real_time *mtime, + virtual int put_system_obj_impl(rgw_raw_obj& obj, uint64_t size, ceph::real_time *mtime, map& attrs, int flags, bufferlist& data, RGWObjVersionTracker *objv_tracker, ceph::real_time set_mtime /* 0 for don't set */); - virtual int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, + 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, off_t ofs, size_t len, bool exclusive); virtual 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_obj& obj, const char *data, size_t len, bool exclusive, + int put_system_obj(void *ctx, rgw_raw_obj& obj, const char *data, size_t len, bool exclusive, ceph::real_time *mtime, map& attrs, RGWObjVersionTracker *objv_tracker, ceph::real_time set_mtime) { bufferlist bl; @@ -2838,7 +2837,7 @@ public: const ceph::real_time& expiration_time = ceph::real_time()); /* Delete a system object */ - virtual int delete_system_obj(rgw_obj& src_obj, RGWObjVersionTracker *objv_tracker = NULL); + virtual int delete_system_obj(rgw_raw_obj& src_obj, RGWObjVersionTracker *objv_tracker = NULL); /** Remove an object from the bucket index */ int delete_obj_index(rgw_obj& obj); @@ -2851,11 +2850,11 @@ public: * dest: bufferlist to store the result in * Returns: 0 on success, -ERR# otherwise. */ - virtual int system_obj_get_attr(rgw_obj& obj, const char *name, bufferlist& dest); + virtual int system_obj_get_attr(rgw_raw_obj& obj, const char *name, bufferlist& dest); - int system_obj_set_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& bl, + int system_obj_set_attr(void *ctx, rgw_raw_obj& obj, const char *name, bufferlist& bl, RGWObjVersionTracker *objv_tracker); - virtual int system_obj_set_attrs(void *ctx, rgw_obj& obj, + virtual int system_obj_set_attrs(void *ctx, rgw_raw_obj& obj, map& attrs, map* rmattrs, RGWObjVersionTracker *objv_tracker); @@ -2874,7 +2873,7 @@ public: map& attrs, map* rmattrs); - int get_system_obj_state(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker); + int get_system_obj_state(RGWObjectCtx *rctx, rgw_raw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker); int get_obj_state(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, bool follow_olh, bool assume_noent = false); int get_obj_state(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state) { return get_obj_state(rctx, obj, state, true); @@ -2882,14 +2881,14 @@ public: virtual int stat_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& state, - rgw_obj& obj, + rgw_raw_obj& obj, map *attrs, ceph::real_time *lastmod, uint64_t *obj_size, RGWObjVersionTracker *objv_tracker); virtual int get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state, - RGWObjVersionTracker *objv_tracker, rgw_obj& obj, + RGWObjVersionTracker *objv_tracker, rgw_raw_obj& obj, bufferlist& bl, off_t ofs, off_t end, map *attrs, rgw_cache_entry_info *cache_info); @@ -2916,7 +2915,7 @@ public: * a simple object read without keeping state */ - virtual int raw_obj_stat(rgw_obj& obj, uint64_t *psize, ceph::real_time *pmtime, uint64_t *epoch, + virtual int raw_obj_stat(rgw_raw_obj& obj, uint64_t *psize, ceph::real_time *pmtime, uint64_t *epoch, map *attrs, bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker); @@ -2951,13 +2950,13 @@ public: void gen_rand_obj_instance_name(rgw_obj *target); - int omap_get_vals(rgw_obj& obj, bufferlist& header, const std::string& marker, uint64_t count, std::map& m); - virtual int omap_get_all(rgw_obj& obj, bufferlist& header, std::map& m); - virtual int omap_set(rgw_obj& obj, std::string& key, bufferlist& bl); - virtual int omap_set(rgw_obj& obj, map& m); - virtual int omap_del(rgw_obj& obj, const std::string& key); + 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_obj& obj, size_t size, bufferlist& bl); + virtual 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); @@ -2990,7 +2989,7 @@ public: int get_bucket_stats_async(rgw_bucket& bucket, int shard_id, RGWGetBucketStats_CB *cb); int get_user_stats(const rgw_user& user, RGWStorageStats& stats); int get_user_stats_async(const rgw_user& user, RGWGetUserStats_CB *cb); - void get_bucket_instance_obj(const rgw_bucket& bucket, rgw_obj& obj); + void get_bucket_instance_obj(const rgw_bucket& bucket, rgw_raw_obj& obj); void get_bucket_meta_oid(const rgw_bucket& bucket, string& oid); int put_bucket_entrypoint_info(const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point, @@ -3001,7 +3000,7 @@ public: RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, ceph::real_time *pmtime, map *pattrs, rgw_cache_entry_info *cache_info = NULL); int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs); - int get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs); + int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs); int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, map *pattrs, rgw_cache_entry_info *cache_info = NULL); @@ -3094,8 +3093,8 @@ public: const string& from_marker = std::string(), const string& to_marker = std::string()); - int lock_exclusive(rgw_bucket& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id); - int unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id); + int lock_exclusive(rgw_pool& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id); + int unlock(rgw_pool& pool, const string& oid, string& zone_id, string& owner_id); void update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_rgw_obj_chain *chain); int send_chain_to_gc(cls_rgw_obj_chain& chain, const string& tag, bool sync); @@ -3125,21 +3124,21 @@ public: int cls_user_get_header(const string& user_id, cls_user_header *header); int cls_user_get_header_async(const string& user_id, RGWGetUserHeader_CB *ctx); - int cls_user_sync_bucket_stats(rgw_obj& user_obj, rgw_bucket& bucket); + int cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, rgw_bucket& bucket); int update_user_bucket_stats(const string& user_id, rgw_bucket& bucket, RGWStorageStats& stats); - int cls_user_list_buckets(rgw_obj& obj, + int cls_user_list_buckets(rgw_raw_obj& obj, const string& in_marker, const string& end_marker, int max_entries, list& entries, string *out_marker, bool *truncated); - int cls_user_add_bucket(rgw_obj& obj, const cls_user_bucket_entry& entry); - int cls_user_update_buckets(rgw_obj& obj, list& entries, bool add); - int cls_user_complete_stats_sync(rgw_obj& obj); + int cls_user_add_bucket(rgw_raw_obj& obj, const cls_user_bucket_entry& entry); + int cls_user_update_buckets(rgw_raw_obj& obj, list& entries, bool add); + int cls_user_complete_stats_sync(rgw_raw_obj& obj); int complete_sync_user_stats(const rgw_user& user_id); - int cls_user_add_bucket(rgw_obj& obj, list& entries); - int cls_user_remove_bucket(rgw_obj& obj, const cls_user_bucket& bucket); + int cls_user_add_bucket(rgw_raw_obj& obj, list& entries); + int cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bucket); int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size); @@ -3256,7 +3255,7 @@ public: * ctx: context object to use for the iteration * Returns: 0 on success, -ERR# otherwise. */ - int pool_iterate_begin(rgw_bucket& bucket, RGWPoolIterCtx& ctx); + int pool_iterate_begin(const rgw_pool& pool, RGWPoolIterCtx& ctx); /** * Iterate over pool return object names, use optional filter * ctx: iteration context, initialized with pool_iterate_begin() diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index c880f9c660f..19a0b51db8d 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -18,19 +18,19 @@ static std::map* ext_mime_map; -int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid, const char *data, size_t size, bool exclusive, +int rgw_put_system_obj(RGWRados *rgwstore, rgw_pool& pool, const string& oid, const char *data, size_t size, bool exclusive, RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs) { map no_attrs; if (!pattrs) pattrs = &no_attrs; - rgw_obj obj(bucket, oid); + rgw_raw_obj obj(pool, oid); int ret = rgwstore->put_system_obj(NULL, obj, data, size, exclusive, NULL, *pattrs, objv_tracker, set_mtime); if (ret == -ENOENT) { - ret = rgwstore->create_pool(bucket); + ret = rgwstore->create_pool(pool); if (ret >= 0) ret = rgwstore->put_system_obj(NULL, obj, data, size, exclusive, NULL, *pattrs, objv_tracker, set_mtime); } @@ -38,14 +38,14 @@ int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid return ret; } -int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, +int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_pool& pool, const string& key, bufferlist& bl, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map *pattrs, rgw_cache_entry_info *cache_info) { struct rgw_err err; bufferlist::iterator iter; int request_len = READ_CHUNK_LEN; - rgw_obj obj(bucket, key); + rgw_raw_obj obj(pool, key); do { RGWRados::SystemObject source(rgwstore, obj_ctx, obj); diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index f3254a05a87..bec35ed71a1 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -16,9 +16,9 @@ struct RGWObjVersionTracker; struct obj_version; -int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid, const char *data, size_t size, bool exclusive, +int rgw_put_system_obj(RGWRados *rgwstore, rgw_pool& pool, const string& oid, const char *data, size_t size, bool exclusive, RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs = NULL); -int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, +int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_pool& pool, const string& key, bufferlist& bl, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map *pattrs = NULL, rgw_cache_entry_info *cache_info = NULL); int rgw_delete_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid, -- 2.39.5