From: Mohammad Fatemipour Date: Sun, 19 Dec 2021 18:33:55 +0000 (+0330) Subject: rgw: fix bad memory usage of bucket chown method X-Git-Tag: v17.2.0~31^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7e7f129ce964dbe7147fbd640dd7739028c6c67b;p=ceph.git rgw: fix bad memory usage of bucket chown method In RGWBucketCtl::chown we have one RGWObjectCtx for all objects of a bucket. In RGWObjectCtx there is a cache mechanism (std::map) for states of objects that will grows continuously. for buckets with millions of objects this mechanism leads to huge memory usage. in chown process we really do not need this caching mechanism so we could create one RGWObjectCtx for every 1000 objects to limit usage of memory. Fixes: https://tracker.ceph.com/issues/53599 Signed-off-by: Mohammad Fatemipour (cherry picked from commit cf2d83ef81458524715c23e802977dc0760c847f) --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index d13c856ab31b..12772f1ea28b 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -2893,7 +2893,6 @@ int RGWBucketCtl::chown(rgw::sal::Store* store, rgw::sal::Bucket* bucket, const rgw_user& user_id, const std::string& display_name, const std::string& marker, optional_yield y, const DoutPrefixProvider *dpp) { - RGWObjectCtx obj_ctx(store); map common_prefixes; rgw::sal::Bucket::ListParams params; @@ -2909,6 +2908,7 @@ int RGWBucketCtl::chown(rgw::sal::Store* store, rgw::sal::Bucket* bucket, //Loop through objects and update object acls to point to bucket owner do { + RGWObjectCtx obj_ctx(store); results.objs.clear(); int ret = bucket->list(dpp, params, max_entries, results, y); if (ret < 0) {