]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: more quota utility stuff
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 27 Sep 2013 17:41:14 +0000 (10:41 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 27 Sep 2013 17:41:14 +0000 (10:41 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/config_opts.h
src/rgw/rgw_quota.cc
src/rgw/rgw_quota.h

index f62832396602da7ca177aa5b8ca19facdc3f6e9d..9dbff06f4c4a6230d476f0d06be70d6766f5cab6 100644 (file)
@@ -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.
index c466b3ca4162cd7ee2b53d38af12c7088d311988..18f9d5efd3d3299f8f95a570f72a2f9d50b55cf0 100644 (file)
@@ -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);
 
index e37e0b473f510bddd9c671c005361d21027d0ad5..66e1d832075bfc9d01664d4efff9ebffd5694e8c 100644 (file)
@@ -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