]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: not check max_objects when creating file 24846/head
authortaoCH <sebastien.chen92@gmail.com>
Wed, 31 Oct 2018 06:05:45 +0000 (14:05 +0800)
committertaoCH <sebastien.chen92@gmail.com>
Wed, 31 Oct 2018 06:05:45 +0000 (14:05 +0800)
Fixed: https://tracker.ceph.com/issues/36654
Signed-off-by: Tao Chen <chentao@umcloud.com>
src/rgw/rgw_file.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 702f9504f6b8049cc866e5d46287b9cab5a20dac..595d24980fd00fe8214dea0f8bbde6526fedecd7 100644 (file)
@@ -660,6 +660,10 @@ namespace rgw {
     }
 
     get<1>(mkr) = rc;
+   
+    /* case like : quota exceed will be considered as fail too*/
+    if(rc2 < 0)
+       get<1>(mkr) = rc2;
 
     return mkr;
   } /* RGWLibFS::create */
@@ -1367,6 +1371,12 @@ namespace rgw {
       return -EIO;
     }
 
+    op_ret = get_store()->check_quota(s->bucket_owner.get_id(), s->bucket,
+                                      user_quota, bucket_quota, real_ofs, true);
+    /* max_size exceed */
+    if (op_ret < 0)
+      return -EIO;
+
     size_t len = data.length();
     if (! len)
       return 0;
@@ -1405,7 +1415,8 @@ namespace rgw {
     }
 
     op_ret = get_store()->check_quota(s->bucket_owner.get_id(), s->bucket,
-                                     user_quota, bucket_quota, s->obj_size);
+                                     user_quota, bucket_quota, s->obj_size, true);
+    /* max_size exceed */
     if (op_ret < 0) {
       goto done;
     }
index 770a84334d18203ca98e8ddf95766ebfa4a5f1e7..4b6ab3775a9cc13953716b825555a27696ef4bc2 100644 (file)
@@ -13575,8 +13575,12 @@ int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info, uint32_t n
 }
 
 int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
-                          RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size)
+                          RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only)
 {
+  // if we only check size, then num_objs will set to 0
+  if(check_size_only)
+    return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 0, obj_size);
+
   return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size);
 }
 
index ccf067d197f1b20d71d63ca26359ac9ba2fa1647..3ef75b539016b3a680312136e08d1ae39b443e8c 100644 (file)
@@ -3556,7 +3556,7 @@ public:
   int cls_user_get_bucket_stats(const rgw_bucket& bucket, cls_user_bucket_entry& entry);
 
   int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
-                  RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size);
+                  RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false);
 
   int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket,
                          RGWQuotaInfo& bucket_quota);