summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-09-27 10:41:14 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-09-27 10:41:14 -0700
commite5fa6d166cee0d5b8a6fd6c15f76ebfea6f6c61b (patch)
tree69b10a67cab376bb178639a0fa4bbe54a77bff19
parentdb5bbdd014440a05798659a73c200c8bee3c2e51 (diff)
downloadceph-e5fa6d166cee0d5b8a6fd6c15f76ebfea6f6c61b.tar.gz
rgw: more quota utility stuff
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/common/config_opts.h2
-rw-r--r--src/rgw/rgw_quota.cc3
-rw-r--r--src/rgw/rgw_quota.h25
3 files changed, 28 insertions, 2 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index f6283239660..9dbff06f4c4 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -715,6 +715,8 @@ OPTION(rgw_data_log_num_shards, OPT_INT, 128) // number of objects to keep data
OPTION(rgw_data_log_obj_prefix, OPT_STR, "data_log") //
OPTION(rgw_replica_log_obj_prefix, OPT_STR, "replica_log") //
+OPTION(rgw_bucket_quota_ttl, OPT_INT, 600) // time for cached bucket stats to be cached within rgw instance
+
OPTION(mutex_perf_counter, OPT_BOOL, false) // enable/disable mutex perf counter
// This will be set to true when it is safe to start threads.
diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc
index c466b3ca416..18f9d5efd3d 100644
--- a/src/rgw/rgw_quota.cc
+++ b/src/rgw/rgw_quota.cc
@@ -47,7 +47,8 @@ int RGWBucketStatsCache::get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& st
if (ret < 0 && ret != -ENOENT)
return ret;
- qs.expiration = ceph_clock_now(store->ctx()) + store->ctx()->_conf->rgw_bucket_quota_ttl;
+ qs.expiration = ceph_clock_now(store->ctx());
+ qs.expiration += store->ctx()->_conf->rgw_bucket_quota_ttl;
stats_map.add(bucket, qs);
diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h
index e37e0b473f5..66e1d832075 100644
--- a/src/rgw/rgw_quota.h
+++ b/src/rgw/rgw_quota.h
@@ -12,6 +12,29 @@ struct RGWQuotaBucketStats {
utime_t expiration;
};
+struct RGWQuotaInfo {
+ uint64_t max_kb;
+ uint64_t max_objs;
+ bool is_set;
+
+ RGWQuotaInfo() : max_kb(0), max_objs(0), is_set(false) {}
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(max_kb, bl);
+ ::encode(max_objs, bl);
+ ::encode(is_set, bl);
+ ENCODE_FINISH(bl);
+ }
+ void decode(bufferlist::iterator& bl) {
+ DECODE_START(1, bl);
+ ::decode(max_kb, bl);
+ ::decode(max_objs, bl);
+ ::decode(is_set, bl);
+ DECODE_FINISH(bl);
+ }
+};
+WRITE_CLASS_ENCODER(RGWQuotaInfo)
class RGWBucketStatsCache {
RGWRados *store;
@@ -24,9 +47,9 @@ public:
RGWBucketStatsCache(RGWRados *_store) : store(_store), stats_map(10000) {}
int get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& stats);
+ void adjust_bucket_stats(rgw_bucket& bucket, int objs_delta, uint64_t added_bytes, uint64_t removed_bytes);
};
-
#endif