summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-10-02 14:37:53 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-10-02 14:37:53 -0700
commit563517df87b28dddaa2b434f5e116abdfd6bd075 (patch)
treee419004ceaf07eeb3997da253944ba588c2256c3
parent6fcea1a0ec6c69308bd2d8116ffa7f9c132f2c18 (diff)
downloadceph-563517df87b28dddaa2b434f5e116abdfd6bd075.tar.gz
rgw: update quota stats when needed
Now update the quota stats when completing specific operations. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_quota.cc4
-rw-r--r--src/rgw/rgw_quota.h3
-rw-r--r--src/rgw/rgw_rados.cc10
3 files changed, 17 insertions, 0 deletions
diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc
index 694fcc61dd1..8dfd52f6cb8 100644
--- a/src/rgw/rgw_quota.cc
+++ b/src/rgw/rgw_quota.cc
@@ -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);
+ };
};
diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h
index 0c686f0eae4..8b0404795b8 100644
--- a/src/rgw/rgw_quota.h
+++ b/src/rgw/rgw_quota.h
@@ -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);
};
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 8ce6b27c521..8035e0589de 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -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;
}