]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: update quota stats when needed
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 2 Oct 2013 21:37:53 +0000 (14:37 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 2 Oct 2013 21:37:53 +0000 (14:37 -0700)
Now update the quota stats when completing specific operations.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h
src/rgw/rgw_rados.cc

index 694fcc61dd106020a0ad6f0a4f4ba826d01c9523..8dfd52f6cb8eab20503e650a2d1d61a76d9e7e0b 100644 (file)
@@ -122,6 +122,10 @@ public:
 
     return 0;
   }
+
+  virtual void update_stats(rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) {
+    stats_cache.adjust_bucket_stats(bucket, obj_delta, added_bytes, removed_bytes);
+  };
 };
 
 
index 0c686f0eae4d47c29892d112258468f798a50cde..8b0404795b8172d3adea257e72e3dafe88a3efad 100644 (file)
@@ -41,10 +41,13 @@ class rgw_bucket;
 
 class RGWQuotaHandler {
 public:
+  RGWQuotaHandler() {}
   virtual ~RGWQuotaHandler() {}
   virtual int check_quota(rgw_bucket& bucket, RGWQuotaInfo& bucket_quota,
                          uint64_t num_objs, uint64_t size) = 0;
 
+  virtual void update_stats(rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) = 0;
+
   static RGWQuotaHandler *generate_handler(RGWRados *store);
   static void free_handler(RGWQuotaHandler *handler);
 };
index 8ce6b27c5212f99f65f343f72b28e2b801bf1105..8035e0589dea7aa50c7aff4e06ee8e0d70405180 100644 (file)
@@ -2347,6 +2347,11 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj,  uint64_t size,
     *mtime = set_mtime;
   }
 
+  if (state) {
+    /* update quota cache */
+    quota_handler->update_stats(bucket, (state->exists ? 0 : 1), size, state->size);
+  }
+
   return 0;
 
 done_cancel:
@@ -3217,6 +3222,11 @@ int RGWRados::delete_obj_impl(void *ctx, rgw_obj& obj, RGWObjVersionTracker *obj
   if (ret_not_existed)
     return -ENOENT;
 
+  if (state) {
+    /* update quota cache */
+    quota_handler->update_stats(bucket, -1, 0, state->size);
+  }
+
   return 0;
 }