]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/sal: StoreBucket no longer wraps RGWBucketEnt 50611/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 21 Mar 2023 18:21:26 +0000 (14:21 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 22 Sep 2023 16:49:07 +0000 (12:49 -0400)
`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 <cbodley@redhat.com>
25 files changed:
doc/radosgw/lua-scripting.rst
src/rgw/driver/d4n/rgw_sal_d4n.cc
src/rgw/driver/daos/rgw_sal_daos.cc
src/rgw/driver/daos/rgw_sal_daos.h
src/rgw/driver/motr/rgw_sal_motr.cc
src/rgw/driver/motr/rgw_sal_motr.h
src/rgw/driver/posix/rgw_sal_posix.cc
src/rgw/driver/posix/rgw_sal_posix.h
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_sal_rados.cc
src/rgw/driver/rados/rgw_sal_rados.h
src/rgw/rgw_admin.cc
src/rgw/rgw_lua_request.cc
src/rgw/rgw_op.cc
src/rgw/rgw_quota.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_dbstore.cc
src/rgw/rgw_sal_dbstore.h
src/rgw/rgw_sal_filter.cc
src/rgw/rgw_sal_filter.h
src/rgw/rgw_sal_store.h
src/rgw/rgw_user.cc
src/test/rgw/test_d4n_filter.cc
src/test/rgw/test_rgw_lua.cc

index f7d68b429e5fe947f751d1cc0862c56fe2476259..be5619041535976b0b60c4ff34f4af08136cc0e6 100644 (file)
@@ -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      |
index fe877cdb2246bd76035fd2080f7e192b4385e799..ff2ed7d9a204f455ed35eb1344a58b1ae2ea8e66 100644 (file)
@@ -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<uint32_t>(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});
index e25977c1068ef951134868b13aba34923de2a525..ebd6957d884b222ac95a36d6f1232345acd03eb3 100644 (file)
@@ -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);
index e27cc02cb6c86cd59b7ea5cd1fd7a25822ea1147..d8f1d276da2d12fde021fd05157839c205543b47 100644 (file)
@@ -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,
index bd0fce07ff722eb0696fac1ea8457d9705e38488..c0dff1c1f9f25dccdc508554ef1b4c2a62fa7a73 100644 (file)
@@ -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;
 }
index 79a22cc7d828065fb67e874b90c0483ccbff495e..c9e6fab6a0f4fa773f6fe320b1aca9bb40b066f7 100644 (file)
@@ -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;
index bd6d8db352bc6d70d41d8d203df2c7c88f6f0480..052471562e43c5b597a641be61a00550142d667e 100644 (file)
@@ -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)
index 34f415bb18fe08467f044f55fa3debcb5a3a6901..a2a5e5fdda9d4b20e02a2a2adae2ab8c97225837 100644 (file)
@@ -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;
index bd505e3b0bdae8a46d697c90ee5e103d954663c3..cf25e629e175c5e74818b2fcaa6b5ec28a57e30c 100644 (file)
@@ -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;
index 23b69a8259f896bcd8b41840e8d49d4349409dfd..5ca604c971f6cee3f503b23e2cb9fedbc0ef530a 100644 (file)
@@ -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);
 
index 465a6e064d4815f7778abddea28a4c05622a7c79..0eb675a6b7bcbcf87f4c3fb42d60670482bc87ab 100644 (file)
@@ -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)
index 750460460e75fab15f23b219383345d04343bebb..75d4be843debc9c06a0242a4800bab7fbbdbbcd3 100644 (file)
@@ -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;
index 0a0bb6277a8b94a7c7fb9bcdc90f530b4646128a..b2c2e5c262a8588267918a8be508b7b6fddf889d 100644 (file)
@@ -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;
index 689624e80992b0843525c843e25dc24bcbeb3bcb..cfbf511aac24a39ad2dedbb0f1f756d97c77ec00 100644 (file)
@@ -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) {
index 8607f058ac74626fa53959fbae8a728486165585..374975f5d4c91dd6c23e0576a84a6e908a239190 100644 (file)
@@ -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;
   }
index 484b472a387e1300b64522b4bce3d69da6dc298c..9df4c36d112a337bbfc6c2ad68ad34789b9b1a8a 100644 (file)
@@ -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)
index b8f27db0b8ad8278969589c6c74d46506ae3da87..6b54067fb4c214fe65208a2d2946edee8b5923f4 100644 (file)
@@ -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 */
index 5b18986a902d1e3ae5b915f167b2b5c0a9da01da..c640c5bfe8cb67eb938d393c93c2a11302c16c23 100644 (file)
@@ -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;
   }
index 274dd6e032f47843d7c3efa7ae43ddd8e58e66e4..ed56e8c114969c3f352a1f61cd0d267f64e54320 100644 (file)
@@ -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;
index 32bdaa89346ffd77c42a92467bfb250eadf40178..6980cd01cd19ccdbb7ee6f9c1d99bac5e1b25323 100644 (file)
@@ -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)
index 3076d7d30d88e5a8397e6e9fd942b4a725b5e421..5011b89df61a3fde6fb8302df600e9019987ec30 100644 (file)
@@ -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(); }
index be11b87163227cf4c17f51b62b86532787f6f427..124debdb7b433fe11ea97141875beb0ceaa6f473 100644 (file)
@@ -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 {
index cdaa08756df72280754446429de80094b417a2a9..175b2e6b23fe5bcfb6111054a791eed26f7d86e0 100644 (file)
@@ -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;
       }
index b4d37bc698df9df3418b9efa1483fb6b65497794..6c838c5b39ec221205e48b6aa9e95e28a32ff613 100644 (file)
@@ -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);
index 80df413cca17c1757bb18232ef5d150f55cc95c4..9eca926e30f2d0c793ede698149f5810368f8bb8 100644 (file)
@@ -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)