From: taoCH Date: Wed, 31 Oct 2018 06:05:45 +0000 (+0800) Subject: librgw: not check max_objects when creating file X-Git-Tag: v14.1.0~883^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61fe8015b371d38be4a2ecb2270c4d187080a9e6;p=ceph.git librgw: not check max_objects when creating file Fixed: https://tracker.ceph.com/issues/36654 Signed-off-by: Tao Chen --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 702f9504f6b8..595d24980fd0 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 770a84334d18..4b6ab3775a9c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index ccf067d197f1..3ef75b539016 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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);