From: Casey Bodley Date: Tue, 21 Mar 2023 18:21:26 +0000 (-0400) Subject: rgw/sal: StoreBucket no longer wraps RGWBucketEnt X-Git-Tag: v19.0.0~427^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=958578aec1b0193e9215f91bac54725d1bbc5b39;p=ceph.git rgw/sal: StoreBucket no longer wraps RGWBucketEnt `sal::Bucket` no longer needs to wrap `RGWBucketEnt` to support user bucket listings, so can be represented by `RGWBucketInfo` alone. the bucket stats interfaces that relied on RGWBucketEnt internally now return their result as either `RGWBucketEnt` or `RGWStorageStats` Signed-off-by: Casey Bodley --- diff --git a/doc/radosgw/lua-scripting.rst b/doc/radosgw/lua-scripting.rst index f7d68b429e5fe..be56190415359 100644 --- a/doc/radosgw/lua-scripting.rst +++ b/doc/radosgw/lua-scripting.rst @@ -170,10 +170,6 @@ Request Fields +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+ | ``Request.Bucket.Id`` | string | bucket id | no | no | yes | +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+ -| ``Request.Bucket.Count`` | integer | number of objects in the bucket | no | no | yes | -+----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+ -| ``Request.Bucket.Size`` | integer | total size of objects in the bucket | no | no | yes | -+----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+ | ``Request.Bucket.ZoneGroupId`` | string | zone group of the bucket | no | no | yes | +----------------------------------------------------+----------+--------------------------------------------------------------+----------+-----------+----------+ | ``Request.Bucket.CreationTime`` | time | creation time of the bucket | no | no | yes | diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.cc b/src/rgw/driver/d4n/rgw_sal_d4n.cc index fe877cdb2246b..ff2ed7d9a204f 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.cc +++ b/src/rgw/driver/d4n/rgw_sal_d4n.cc @@ -365,10 +365,6 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix source->set_instance(it->second); } else if (!std::strcmp(it->first.data(), "source_zone_short_id")) { astate->zone_short_id = static_cast(std::stoul(it->second)); - } else if (!std::strcmp(it->first.data(), "bucket_count")) { - source->get_bucket()->set_count(std::stoull(it->second)); - } else if (!std::strcmp(it->first.data(), "bucket_size")) { - source->get_bucket()->set_size(std::stoull(it->second)); } else if (!std::strcmp(it->first.data(), "user_quota.max_size")) { quota_info.max_size = std::stoull(it->second); } else if (!std::strcmp(it->first.data(), "user_quota.max_objects")) { @@ -517,14 +513,6 @@ int D4NFilterWriter::complete(size_t accounted_size, const std::string& etag, bl.clear(); } - bl.append(std::to_string(obj->get_bucket()->get_count())); - baseAttrs.insert({"bucket_count", bl}); - bl.clear(); - - bl.append(std::to_string(obj->get_bucket()->get_size())); - baseAttrs.insert({"bucket_size", bl}); - bl.clear(); - RGWUserInfo info = obj->get_bucket()->get_owner()->get_info(); bl.append(std::to_string(info.quota.user_quota.max_size)); baseAttrs.insert({"user_quota.max_size", bl}); diff --git a/src/rgw/driver/daos/rgw_sal_daos.cc b/src/rgw/driver/daos/rgw_sal_daos.cc index e25977c1068ef..ebd6957d884b2 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.cc +++ b/src/rgw/driver/daos/rgw_sal_daos.cc @@ -452,8 +452,7 @@ int DaosBucket::put_info(const DoutPrefixProvider* dpp, bool exclusive, return ret; } -int DaosBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats) { +int DaosBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y) { ldpp_dout(dpp, 20) << "DEBUG: load_bucket(): bucket name=" << get_name() << dendl; int ret = open(dpp); diff --git a/src/rgw/driver/daos/rgw_sal_daos.h b/src/rgw/driver/daos/rgw_sal_daos.h index e27cc02cb6c86..d8f1d276da2d1 100644 --- a/src/rgw/driver/daos/rgw_sal_daos.h +++ b/src/rgw/driver/daos/rgw_sal_daos.h @@ -299,8 +299,7 @@ class DaosBucket : public StoreBucket { virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) override; - virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y) override; virtual int read_stats(const DoutPrefixProvider* dpp, const bucket_index_layout_generation& idx_layout, int shard_id, std::string* bucket_ver, diff --git a/src/rgw/driver/motr/rgw_sal_motr.cc b/src/rgw/driver/motr/rgw_sal_motr.cc index bd0fce07ff722..c0dff1c1f9f25 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.cc +++ b/src/rgw/driver/motr/rgw_sal_motr.cc @@ -714,7 +714,7 @@ int MotrBucket::put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::re return rc; } -int MotrBucket::load_bucket(const DoutPrefixProvider *dpp, optional_yield y, bool get_stats) +int MotrBucket::load_bucket(const DoutPrefixProvider *dpp, optional_yield y) { // Get bucket instance using bucket's name (string). or bucket id? bufferlist bl; @@ -825,12 +825,14 @@ int MotrBucket::read_stats_async(const DoutPrefixProvider *dpp, return 0; } -int MotrBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) +int MotrBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) { return 0; } -int MotrBucket::check_bucket_shards(const DoutPrefixProvider *dpp) +int MotrBucket::check_bucket_shards(const DoutPrefixProvider *dpp, + uint64_t num_objs) { return 0; } diff --git a/src/rgw/driver/motr/rgw_sal_motr.h b/src/rgw/driver/motr/rgw_sal_motr.h index 79a22cc7d8280..c9e6fab6a0f4f 100644 --- a/src/rgw/driver/motr/rgw_sal_motr.h +++ b/src/rgw/driver/motr/rgw_sal_motr.h @@ -359,7 +359,7 @@ class MotrBucket : public StoreBucket { DoutPrefixProvider *dpp) override; virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } virtual int set_acl(const DoutPrefixProvider *dpp, RGWAccessControlPolicy& acl, optional_yield y) override; - virtual int load_bucket(const DoutPrefixProvider *dpp, optional_yield y, bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider *dpp, optional_yield y) override; int link_user(const DoutPrefixProvider* dpp, User* new_user, optional_yield y); int unlink_user(const DoutPrefixProvider* dpp, User* new_user, optional_yield y); int create_bucket_index(); @@ -373,8 +373,10 @@ class MotrBucket : public StoreBucket { virtual int read_stats_async(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) override; - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; - virtual int check_bucket_shards(const DoutPrefixProvider *dpp) override; + int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) override; + int check_bucket_shards(const DoutPrefixProvider *dpp, + uint64_t num_objs) override; virtual int chown(const DoutPrefixProvider *dpp, User& new_user, optional_yield y) override; virtual int put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime) override; virtual bool is_owner(User* user) override; diff --git a/src/rgw/driver/posix/rgw_sal_posix.cc b/src/rgw/driver/posix/rgw_sal_posix.cc index bd6d8db352bc6..052471562e43c 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.cc +++ b/src/rgw/driver/posix/rgw_sal_posix.cc @@ -966,8 +966,7 @@ int POSIXBucket::remove_bucket_bypass_gc(int concurrent_max, return remove_bucket(dpp, true, false, nullptr, y); } -int POSIXBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats) +int POSIXBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y) { int ret; @@ -980,8 +979,8 @@ int POSIXBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, return ret; } - bucket_statx_save(stx, ent, mtime); - info.creation_time = ent.creation_time; + mtime = ceph::real_clock::from_time_t(stx.stx_mtime.tv_sec); + info.creation_time = ceph::real_clock::from_time_t(stx.stx_btime.tv_sec); if (owner) { info.owner = owner->get_id(); @@ -1009,8 +1008,6 @@ int POSIXBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, // TODO dang: fake info up (UID to owner conversion?) } - info.creation_time = ent.creation_time; - return 0; } @@ -1071,14 +1068,16 @@ int POSIXBucket::read_stats_async(const DoutPrefixProvider *dpp, return 0; } -int POSIXBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) +int POSIXBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) { return 0; } -int POSIXBucket::check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) +int POSIXBucket::check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) { - return 0; + return 0; } int POSIXBucket::chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) diff --git a/src/rgw/driver/posix/rgw_sal_posix.h b/src/rgw/driver/posix/rgw_sal_posix.h index 34f415bb18fe0..a2a5e5fdda9d4 100644 --- a/src/rgw/driver/posix/rgw_sal_posix.h +++ b/src/rgw/driver/posix/rgw_sal_posix.h @@ -171,13 +171,6 @@ public: ns(_ns) { } - POSIXBucket(POSIXDriver *_dr, int _p_fd, const RGWBucketEnt& _e, User* _u) - : StoreBucket(_e, _u), - driver(_dr), - parent_fd(_p_fd), - acls() - { } - POSIXBucket(POSIXDriver *_dr, int _p_fd, const RGWBucketInfo& _i, User* _u) : StoreBucket(_i, _u), driver(_dr), @@ -209,8 +202,7 @@ public: bool keep_index_consistent, optional_yield y, const DoutPrefixProvider *dpp) override; - virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y) override; virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) override; @@ -223,8 +215,10 @@ public: virtual int read_stats_async(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) override; - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; - virtual int check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) override; + virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) override; + virtual int check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) override; virtual int chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) override; virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime, optional_yield y) override; diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index bd505e3b0bdae..cf25e629e175c 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -10040,7 +10040,6 @@ int RGWRados::cls_bucket_head_async(const DoutPrefixProvider *dpp, const RGWBuck } int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, - const rgw_bucket& bucket, uint64_t num_objs, const DoutPrefixProvider *dpp, optional_yield y) { @@ -10079,7 +10078,7 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, return 0; } - ldpp_dout(dpp, 1) << "RGWRados::" << __func__ << " bucket " << bucket.name << + ldpp_dout(dpp, 1) << "RGWRados::" << __func__ << " bucket " << bucket_info.bucket.name << " needs resharding; current num shards " << bucket_info.layout.current_index.layout.normal.num_shards << "; new num shards " << final_num_shards << " (suggested " << suggested_num_shards << ")" << dendl; diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index 23b69a8259f89..5ca604c971f6c 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1559,8 +1559,8 @@ public: RGWQuota& quota, uint64_t obj_size, optional_yield y, bool check_size_only = false); - int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, - uint64_t num_objs, const DoutPrefixProvider *dpp, optional_yield y); + int check_bucket_shards(const RGWBucketInfo& bucket_info, uint64_t num_objs, + const DoutPrefixProvider *dpp, optional_yield y); int add_bucket_to_reshard(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, uint32_t new_num_shards, optional_yield y); diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 465a6e064d481..0eb675a6b7bcb 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -622,7 +622,7 @@ int RadosBucket::remove_bucket_bypass_gc(int concurrent_max, bool return ret; } - sync_user_stats(dpp, y); + sync_user_stats(dpp, y, nullptr); if (ret < 0) { ldpp_dout(dpp, 1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; } @@ -641,7 +641,7 @@ int RadosBucket::remove_bucket_bypass_gc(int concurrent_max, bool return ret; } -int RadosBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats) +int RadosBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y) { int ret; @@ -667,10 +667,6 @@ int RadosBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bo bucket_version = ep_ot.read_version; - if (get_stats) { - ret = store->ctl()->bucket->read_bucket_stats(info.bucket, &ent, y, dpp); - } - return ret; } @@ -690,14 +686,16 @@ int RadosBucket::read_stats_async(const DoutPrefixProvider *dpp, return store->getRados()->get_bucket_stats_async(dpp, get_info(), idx_layout, shard_id, ctx); } -int RadosBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) +int RadosBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) { - return store->ctl()->bucket->sync_user_stats(dpp, owner->get_id(), info, y, &ent); + return store->ctl()->bucket->sync_user_stats(dpp, owner->get_id(), info, y, ent); } -int RadosBucket::check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) +int RadosBucket::check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) { - return store->getRados()->check_bucket_shards(info, info.bucket, get_count(), dpp, y); + return store->getRados()->check_bucket_shards(info, num_objs, dpp, y); } int RadosBucket::link(const DoutPrefixProvider* dpp, User* new_user, optional_yield y, bool update_entrypoint, RGWObjVersionTracker* objv) diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 750460460e75f..75d4be843debc 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -516,12 +516,6 @@ class RadosBucket : public StoreBucket { acls() { } - RadosBucket(RadosStore *_st, const RGWBucketEnt& _e) - : StoreBucket(_e), - store(_st), - acls() { - } - RadosBucket(RadosStore *_st, const RGWBucketInfo& _i) : StoreBucket(_i), store(_st), @@ -534,12 +528,6 @@ class RadosBucket : public StoreBucket { acls() { } - RadosBucket(RadosStore *_st, const RGWBucketEnt& _e, User* _u) - : StoreBucket(_e, _u), - store(_st), - acls() { - } - RadosBucket(RadosStore *_st, const RGWBucketInfo& _i, User* _u) : StoreBucket(_i, _u), store(_st), @@ -556,7 +544,7 @@ class RadosBucket : public StoreBucket { DoutPrefixProvider *dpp) override; virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl, optional_yield y) override; - virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y) override; virtual int read_stats(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, std::string* bucket_ver, std::string* master_ver, @@ -566,8 +554,10 @@ class RadosBucket : public StoreBucket { virtual int read_stats_async(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) override; - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; - virtual int check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) override; + int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) override; + int check_bucket_shards(const DoutPrefixProvider* dpp, uint64_t num_objs, + optional_yield y) override; virtual int chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) override; virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, ceph::real_time mtime, optional_yield y) override; virtual int check_empty(const DoutPrefixProvider* dpp, optional_yield y) override; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 0a0bb6277a8b9..b2c2e5c262a85 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -8683,7 +8683,7 @@ next: cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; return -ret; } - ret = bucket->sync_user_stats(dpp(), null_yield); + ret = bucket->sync_user_stats(dpp(), null_yield, nullptr); if (ret < 0) { cerr << "ERROR: could not sync bucket stats: " << cpp_strerror(-ret) << std::endl; diff --git a/src/rgw/rgw_lua_request.cc b/src/rgw/rgw_lua_request.cc index 689624e80992b..cfbf511aac24a 100644 --- a/src/rgw/rgw_lua_request.cc +++ b/src/rgw/rgw_lua_request.cc @@ -293,10 +293,6 @@ struct BucketMetaTable : public EmptyMetaTable { pushstring(L, bucket->get_marker()); } else if (strcasecmp(index, "Id") == 0) { pushstring(L, bucket->get_bucket_id()); - } else if (strcasecmp(index, "Count") == 0) { - lua_pushinteger(L, bucket->get_count()); - } else if (strcasecmp(index, "Size") == 0) { - lua_pushinteger(L, bucket->get_size()); } else if (strcasecmp(index, "ZoneGroupId") == 0) { pushstring(L, bucket->get_info().zonegroup); } else if (strcasecmp(index, "CreationTime") == 0) { diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 8607f058ac746..374975f5d4c91 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3549,7 +3549,7 @@ void RGWDeleteBucket::execute(optional_yield y) } } - op_ret = s->bucket->sync_user_stats(this, y); + op_ret = s->bucket->sync_user_stats(this, y, nullptr); if ( op_ret < 0) { ldpp_dout(this, 1) << "WARNING: failed to sync user stats before bucket delete: op_ret= " << op_ret << dendl; } diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 484b472a387e1..9df4c36d112a3 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -619,13 +619,14 @@ int RGWUserStatsCache::sync_bucket(const rgw_user& _u, rgw_bucket& _b, optional_ return r; } - r = bucket->sync_user_stats(dpp, y); + RGWBucketEnt ent; + r = bucket->sync_user_stats(dpp, y, &ent); if (r < 0) { ldpp_dout(dpp, 0) << "ERROR: sync_user_stats() for user=" << _u << ", bucket=" << bucket << " returned " << r << dendl; return r; } - return bucket->check_bucket_shards(dpp, y); + return bucket->check_bucket_shards(dpp, ent.count, y); } int RGWUserStatsCache::sync_user(const DoutPrefixProvider *dpp, const rgw_user& _u, optional_yield y) diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index b8f27db0b8ad8..6b54067fb4c21 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -673,9 +673,8 @@ class Bucket { // XXXX hack virtual void set_owner(rgw::sal::User* _owner) = 0; - /** Load this bucket from the backing store. Requires the key to be set, fills other fields. - * If @a get_stats is true, then statistics on the bucket are also looked up. */ - virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, bool get_stats = false) = 0; + /** Load this bucket from the backing store. Requires the key to be set, fills other fields. */ + virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y) = 0; /** Read the bucket stats from the backing Store, synchronous */ virtual int read_stats(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, @@ -688,9 +687,11 @@ class Bucket { const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) = 0; /** Sync this bucket's stats to the owning user's stats in the backing store */ - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) = 0; + virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* optional_ent) = 0; /** Check if this bucket needs resharding, and schedule it if it does */ - virtual int check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) = 0; + virtual int check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) = 0; /** Change the owner of this bucket in the backing store. Current owner must be set. Does not * change ownership of the objects in the bucket. */ virtual int chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) = 0; @@ -728,10 +729,6 @@ class Bucket { virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) = 0; /** Remove this specific bucket instance from the backing store. May be removed from API */ virtual int purge_instance(const DoutPrefixProvider* dpp, optional_yield y) = 0; - /** Set the cached object count of this bucket */ - virtual void set_count(uint64_t _count) = 0; - /** Set the cached size of this bucket */ - virtual void set_size(uint64_t _size) = 0; /** Check if this instantiation is empty */ virtual bool empty() const = 0; @@ -743,12 +740,6 @@ class Bucket { virtual const std::string& get_marker() const = 0; /** Get the cached ID of this bucket */ virtual const std::string& get_bucket_id() const = 0; - /** Get the cached size of this bucket */ - virtual size_t get_size() const = 0; - /** Get the cached rounded size of this bucket */ - virtual size_t get_size_rounded() const = 0; - /** Get the cached object count of this bucket */ - virtual uint64_t get_count() const = 0; /** Get the cached placement rule of this bucket */ virtual rgw_placement_rule& get_placement_rule() = 0; /** Get the cached creation time of this bucket */ diff --git a/src/rgw/rgw_sal_dbstore.cc b/src/rgw/rgw_sal_dbstore.cc index 5b18986a902d1..c640c5bfe8cb6 100644 --- a/src/rgw/rgw_sal_dbstore.cc +++ b/src/rgw/rgw_sal_dbstore.cc @@ -284,7 +284,7 @@ namespace rgw::sal { return 0; } - int DBBucket::load_bucket(const DoutPrefixProvider *dpp, optional_yield y, bool get_stats) + int DBBucket::load_bucket(const DoutPrefixProvider *dpp, optional_yield y) { int ret = 0; @@ -310,12 +310,14 @@ namespace rgw::sal { return 0; } - int DBBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) + int DBBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) { return 0; } - int DBBucket::check_bucket_shards(const DoutPrefixProvider *dpp, optional_yield y) + int DBBucket::check_bucket_shards(const DoutPrefixProvider *dpp, + uint64_t num_objs, optional_yield y) { return 0; } diff --git a/src/rgw/rgw_sal_dbstore.h b/src/rgw/rgw_sal_dbstore.h index 274dd6e032f47..ed56e8c114969 100644 --- a/src/rgw/rgw_sal_dbstore.h +++ b/src/rgw/rgw_sal_dbstore.h @@ -149,12 +149,6 @@ protected: acls() { } - DBBucket(DBStore *_st, const RGWBucketEnt& _e) - : StoreBucket(_e), - store(_st), - acls() { - } - DBBucket(DBStore *_st, const RGWBucketInfo& _i) : StoreBucket(_i), store(_st), @@ -167,12 +161,6 @@ protected: acls() { } - DBBucket(DBStore *_st, const RGWBucketEnt& _e, User* _u) - : StoreBucket(_e, _u), - store(_st), - acls() { - } - DBBucket(DBStore *_st, const RGWBucketInfo& _i, User* _u) : StoreBucket(_i, _u), store(_st), @@ -190,7 +178,7 @@ protected: DoutPrefixProvider *dpp) override; virtual RGWAccessControlPolicy& get_acl(void) override { return acls; } virtual int set_acl(const DoutPrefixProvider *dpp, RGWAccessControlPolicy& acl, optional_yield y) override; - virtual int load_bucket(const DoutPrefixProvider *dpp, optional_yield y, bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider *dpp, optional_yield y) override; virtual int read_stats(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, @@ -199,8 +187,10 @@ protected: std::string *max_marker = nullptr, bool *syncstopped = nullptr) override; virtual int read_stats_async(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) override; - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; - virtual int check_bucket_shards(const DoutPrefixProvider *dpp, optional_yield y) override; + int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) override; + int check_bucket_shards(const DoutPrefixProvider *dpp, + uint64_t num_objs, optional_yield y) override; virtual int chown(const DoutPrefixProvider *dpp, User& new_user, optional_yield y) override; virtual int put_info(const DoutPrefixProvider *dpp, bool exclusive, ceph::real_time mtime, optional_yield y) override; virtual int check_empty(const DoutPrefixProvider *dpp, optional_yield y) override; diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index 32bdaa89346ff..6980cd01cd19c 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -670,10 +670,9 @@ int FilterBucket::set_acl(const DoutPrefixProvider* dpp, return next->set_acl(dpp, acl, y); } -int FilterBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats) +int FilterBucket::load_bucket(const DoutPrefixProvider* dpp, optional_yield y) { - return next->load_bucket(dpp, y, get_stats); + return next->load_bucket(dpp, y); } int FilterBucket::read_stats(const DoutPrefixProvider *dpp, @@ -694,14 +693,16 @@ int FilterBucket::read_stats_async(const DoutPrefixProvider *dpp, return next->read_stats_async(dpp, idx_layout, shard_id, ctx); } -int FilterBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) +int FilterBucket::sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) { - return next->sync_user_stats(dpp, y); + return next->sync_user_stats(dpp, y, ent); } -int FilterBucket::check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) +int FilterBucket::check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) { - return next->check_bucket_shards(dpp, y); + return next->check_bucket_shards(dpp, num_objs, y); } int FilterBucket::chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) diff --git a/src/rgw/rgw_sal_filter.h b/src/rgw/rgw_sal_filter.h index 3076d7d30d88e..5011b89df61a3 100644 --- a/src/rgw/rgw_sal_filter.h +++ b/src/rgw/rgw_sal_filter.h @@ -424,8 +424,7 @@ public: optional_yield y) override; virtual void set_owner(rgw::sal::User* _owner) override { next->set_owner(_owner); } - virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y, - bool get_stats = false) override; + virtual int load_bucket(const DoutPrefixProvider* dpp, optional_yield y) override; virtual int read_stats(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, std::string* bucket_ver, std::string* master_ver, @@ -435,8 +434,10 @@ public: virtual int read_stats_async(const DoutPrefixProvider *dpp, const bucket_index_layout_generation& idx_layout, int shard_id, RGWGetBucketStats_CB* ctx) override; - virtual int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y) override; - virtual int check_bucket_shards(const DoutPrefixProvider* dpp, optional_yield y) override; + int sync_user_stats(const DoutPrefixProvider *dpp, optional_yield y, + RGWBucketEnt* ent) override; + int check_bucket_shards(const DoutPrefixProvider* dpp, + uint64_t num_objs, optional_yield y) override; virtual int chown(const DoutPrefixProvider* dpp, User& new_user, optional_yield y) override; virtual int put_info(const DoutPrefixProvider* dpp, bool exclusive, @@ -470,16 +471,11 @@ public: virtual int rebuild_index(const DoutPrefixProvider *dpp) override; virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) override; virtual int purge_instance(const DoutPrefixProvider* dpp, optional_yield y) override; - virtual void set_count(uint64_t _count) override { return next->set_count(_count); } - virtual void set_size(uint64_t _size) override { return next->set_size(_size); } virtual bool empty() const override { return next->empty(); } virtual const std::string& get_name() const override { return next->get_name(); } virtual const std::string& get_tenant() const override { return next->get_tenant(); } virtual const std::string& get_marker() const override { return next->get_marker(); } virtual const std::string& get_bucket_id() const override { return next->get_bucket_id(); } - virtual size_t get_size() const override { return next->get_size(); } - virtual size_t get_size_rounded() const override { return next->get_size_rounded(); } - virtual uint64_t get_count() const override { return next->get_count(); } virtual rgw_placement_rule& get_placement_rule() override { return next->get_placement_rule(); } virtual ceph::real_time& get_creation_time() override { return next->get_creation_time(); } virtual ceph::real_time& get_modification_time() override { return next->get_modification_time(); } diff --git a/src/rgw/rgw_sal_store.h b/src/rgw/rgw_sal_store.h index be11b87163227..124debdb7b433 100644 --- a/src/rgw/rgw_sal_store.h +++ b/src/rgw/rgw_sal_store.h @@ -79,7 +79,6 @@ class StoreUser : public User { class StoreBucket : public Bucket { protected: - RGWBucketEnt ent; RGWBucketInfo info; User* owner = nullptr; Attrs attrs; @@ -89,31 +88,11 @@ class StoreBucket : public Bucket { public: StoreBucket() = default; - StoreBucket(User* _u) : - owner(_u) { } - StoreBucket(const rgw_bucket& _b) { ent.bucket = _b; info.bucket = _b; } - StoreBucket(const RGWBucketEnt& _e) : ent(_e) { - info.bucket = ent.bucket; - info.placement_rule = ent.placement_rule; - info.creation_time = ent.creation_time; - } - StoreBucket(const RGWBucketInfo& _i) : info(_i) { - ent.bucket = info.bucket; - ent.placement_rule = info.placement_rule; - ent.creation_time = info.creation_time; - } - StoreBucket(const rgw_bucket& _b, User* _u) : - owner(_u) { ent.bucket = _b; info.bucket = _b; } - StoreBucket(const RGWBucketEnt& _e, User* _u) : ent(_e), owner(_u) { - info.bucket = ent.bucket; - info.placement_rule = ent.placement_rule; - info.creation_time = ent.creation_time; - } - StoreBucket(const RGWBucketInfo& _i, User* _u) : info(_i), owner(_u) { - ent.bucket = info.bucket; - ent.placement_rule = info.placement_rule; - ent.creation_time = info.creation_time; - } + StoreBucket(User* u) : owner(u) { } + StoreBucket(const rgw_bucket& b) { info.bucket = b; } + StoreBucket(const RGWBucketInfo& i) : info(i) {} + StoreBucket(const rgw_bucket& b, User* u) : owner(u) { info.bucket = b; } + StoreBucket(const RGWBucketInfo& i, User* u) : info(i), owner(u) {} virtual ~StoreBucket() = default; virtual Attrs& get_attrs(void) override { return attrs; } @@ -122,12 +101,6 @@ class StoreBucket : public Bucket { owner = _owner; info.owner = owner->get_id(); } - virtual void set_count(uint64_t _count) override { - ent.count = _count; - } - virtual void set_size(uint64_t _size) override { - ent.size = _size; - } virtual User* get_owner(void) override { return owner; }; /* Make sure to call get_bucket_info() if you need it first */ virtual bool is_owner(User* user) override { return (info.owner.compare(user->get_id()) == 0); } @@ -137,9 +110,6 @@ class StoreBucket : public Bucket { virtual const std::string& get_tenant() const override { return info.bucket.tenant; } virtual const std::string& get_marker() const override { return info.bucket.marker; } virtual const std::string& get_bucket_id() const override { return info.bucket.bucket_id; } - virtual size_t get_size() const override { return ent.size; } - virtual size_t get_size_rounded() const override { return ent.size_rounded; } - virtual uint64_t get_count() const override { return ent.count; } virtual rgw_placement_rule& get_placement_rule() override { return info.placement_rule; } virtual ceph::real_time& get_creation_time() override { return info.creation_time; } virtual ceph::real_time& get_modification_time() override { return mtime; } @@ -179,9 +149,6 @@ class StoreBucket : public Bucket { optional_yield y, const DoutPrefixProvider *dpp) override {return 0;} friend class BucketList; - - protected: - virtual void set_ent(RGWBucketEnt& _ent) { ent = _ent; info.bucket = ent.bucket; info.placement_rule = ent.placement_rule; } }; class StoreObject : public Object { diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index cdaa08756df72..175b2e6b23fe5 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -35,12 +35,12 @@ int rgw_user_sync_all_stats(const DoutPrefixProvider *dpp, rgw::sal::Driver* dri ldpp_dout(dpp, 0) << "ERROR: could not read bucket info: bucket=" << bucket << " ret=" << ret << dendl; continue; } - ret = bucket->sync_user_stats(dpp, y); + ret = bucket->sync_user_stats(dpp, y, &ent); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: could not sync bucket stats: ret=" << ret << dendl; return ret; } - ret = bucket->check_bucket_shards(dpp, y); + ret = bucket->check_bucket_shards(dpp, ent.count, y); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR in check_bucket_shards: " << cpp_strerror(-ret)<< dendl; } diff --git a/src/test/rgw/test_d4n_filter.cc b/src/test/rgw/test_d4n_filter.cc index b4d37bc698df9..6c838c5b39ec2 100644 --- a/src/test/rgw/test_d4n_filter.cc +++ b/src/test/rgw/test_d4n_filter.cc @@ -1763,8 +1763,6 @@ TEST_F(D4NFilterFixture, StoreGetMetadata) { EXPECT_EQ(storeObject->state.accounted_size, (uint64_t)200); EXPECT_EQ(storeObject->state.epoch, (uint64_t)3); EXPECT_EQ(storeObject->state.zone_short_id, (uint32_t)300); - EXPECT_EQ(testObject_StoreGetMetadata->get_bucket()->get_count(), (uint64_t)10); - EXPECT_EQ(testObject_StoreGetMetadata->get_bucket()->get_size(), (uint64_t)20); EXPECT_EQ(info.quota.user_quota.max_size, (int64_t)0); EXPECT_EQ(info.quota.user_quota.max_objects, (int64_t)0); EXPECT_EQ(testObject_StoreGetMetadata->get_bucket()->get_owner()->get_max_buckets(), (int32_t)2000); diff --git a/src/test/rgw/test_rgw_lua.cc b/src/test/rgw/test_rgw_lua.cc index 80df413cca17c..9eca926e30f2d 100644 --- a/src/test/rgw/test_rgw_lua.cc +++ b/src/test/rgw/test_rgw_lua.cc @@ -321,8 +321,6 @@ TEST(TestRGWLua, Bucket) assert(Request.Bucket.Marker == "mymarker") assert(Request.Bucket.Name == "myname") assert(Request.Bucket.Tenant == "mytenant") - assert(Request.Bucket.Count == 0) - assert(Request.Bucket.Size == 0) assert(Request.Bucket.ZoneGroupId) assert(Request.Bucket.CreationTime) assert(Request.Bucket.MTime)