RGW: Multipart upload may double the quota

Fixes: http://tracker.ceph.com/issues/21586

Signed-off-by: Sibei Gao <gaosb@inspur.com>
This commit is contained in:
gaosibei 2017-09-26 10:44:09 +08:00
parent 998bf1b43c
commit 97f95e457f
3 changed files with 11 additions and 3 deletions

View File

@ -5522,6 +5522,7 @@ void RGWCompleteMultipart::execute()
obj_op.meta.owner = s->owner.get_id();
obj_op.meta.flags = PUT_OBJ_CREATE;
obj_op.meta.modify_tail = true;
obj_op.meta.completeMultipart = true;
op_ret = obj_op.write_meta(ofs, accounted_size, attrs);
if (op_ret < 0)
return;

View File

@ -6972,8 +6972,14 @@ int RGWRados::Object::Write::_do_write_meta(uint64_t size, uint64_t accounted_si
meta.canceled = false;
/* update quota cache */
store->quota_handler->update_stats(meta.owner, obj.bucket, (orig_exists ? 0 : 1),
accounted_size, orig_size);
if (meta.completeMultipart){
store->quota_handler->update_stats(meta.owner, obj.bucket, (orig_exists ? 0 : 1),
0, orig_size);
}
else {
store->quota_handler->update_stats(meta.owner, obj.bucket, (orig_exists ? 0 : 1),
accounted_size, orig_size);
}
return 0;
done_cancel:

View File

@ -2815,11 +2815,12 @@ public:
const string *user_data;
rgw_zone_set *zones_trace;
bool modify_tail;
bool completeMultipart;
MetaParams() : mtime(NULL), rmattrs(NULL), data(NULL), manifest(NULL), ptag(NULL),
remove_objs(NULL), category(RGW_OBJ_CATEGORY_MAIN), flags(0),
if_match(NULL), if_nomatch(NULL), olh_epoch(0), canceled(false), user_data(nullptr), zones_trace(nullptr),
modify_tail(false) {}
modify_tail(false), completeMultipart(false) {}
} meta;
explicit Write(RGWRados::Object *_target) : target(_target) {}