]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check quota before completing write op
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 1 Oct 2013 20:32:28 +0000 (13:32 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 1 Oct 2013 20:32:28 +0000 (13:32 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 54c0a98e1d7495d2b9e01416c2f6390fc5e8bbdc..4dd6bf39a26c08247a44b1b06869a480141b6a85 100644 (file)
@@ -1444,6 +1444,11 @@ void RGWPutObj::execute()
   s->obj_size = ofs;
   perfcounter->inc(l_rgw_put_b, s->obj_size);
 
+  ret = store->check_quota(s->bucket, bucket_quota, s->obj_size);
+  if (ret < 0) {
+    goto done;
+  }
+
   hash.Final(m);
 
   buf_to_hex(m, CEPH_CRYPTO_MD5_DIGESTSIZE, calc_md5);
index 9ffb7b562649eb2b2bfa7ae30d546be88f25432f..8ce6b27c5212f99f65f343f72b28e2b801bf1105 100644 (file)
@@ -855,6 +855,7 @@ void RGWRados::finalize()
     RGWRESTConn *conn = iter->second;
     delete conn;
   }
+  RGWQuotaHandler::free_handler(quota_handler);
 }
 
 /** 
@@ -964,6 +965,8 @@ int RGWRados::init_complete()
   if (use_gc_thread)
     gc->start_processor();
 
+  quota_handler = RGWQuotaHandler::generate_handler(this);
+
   return ret;
 }
 
@@ -5483,6 +5486,10 @@ int RGWRados::cls_bucket_head(rgw_bucket& bucket, struct rgw_bucket_dir_header&
   return 0;
 }
 
+int RGWRados::check_quota(rgw_bucket& bucket, RGWQuotaInfo& quota_info, uint64_t obj_size)
+{
+  return quota_handler->check_quota(bucket, quota_info, 1, obj_size);
+}
 
 class IntentLogNameFilter : public RGWAccessListFilter
 {
index 0da686ced835bc714780bbde0bb7a31c429e8238..a23f90f1f23eb6512862cdd20ab9132d249490d9 100644 (file)
@@ -864,6 +864,8 @@ protected:
   string region_name;
   string zone_name;
 
+  RGWQuotaHandler *quota_handler;
+
 public:
   RGWRados() : lock("rados_timer_lock"), timer(NULL),
                gc(NULL), use_gc_thread(false),
@@ -872,6 +874,7 @@ public:
                bucket_id_lock("rados_bucket_id"), max_bucket_id(0),
                cct(NULL), rados(NULL),
                pools_initialized(false),
+               quota_handler(NULL),
                rest_master_conn(NULL),
                meta_mgr(NULL), data_log(NULL) {}
 
@@ -1378,6 +1381,8 @@ public:
   int bucket_rebuild_index(rgw_bucket& bucket);
   int remove_objs_from_index(rgw_bucket& bucket, list<string>& oid_list);
 
+  int check_quota(rgw_bucket& bucket, RGWQuotaInfo& quota_info, uint64_t obj_size);
+
   string unique_id(uint64_t unique_num) {
     char buf[32];
     snprintf(buf, sizeof(buf), ".%llu.%llu", (unsigned long long)instance_id(), (unsigned long long)unique_num);