From c722d00af5286785ad23c574359220e47fd15076 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Tue, 9 Feb 2016 12:03:24 -0800 Subject: [PATCH] rgw: user quota may not adjust on bucket removal Description: If the user/admin removes a bucket using --force/--purge-objects options with s3cmd/radosgw-admin respectively, the user stats will continue to reflect the deleted objects for quota purposes, and there seems to be no way to reset them. User stats need to be sync'ed prior to bucket removal. Solution: Sync user stats before removing a bucket. Fixes: #14507 Signed-off-by: Edward Yang (cherry picked from commit 06507992e3fad837c4667f467d59fc026a2ca0e8) Conflicts: src/rgw/rgw_op.cc reordering the check seqence and replace some op_ret to ret Backport Change: We remove the `tenant` parameter because this feature is not introduced on hammer version. The rgw multi-tenant feature is introduced on pr#6784 (https://github.com/ceph/ceph/pull/6784) This feature is supported from v10.0.2 and later version. --- src/rgw/rgw_bucket.cc | 5 +++++ src/rgw/rgw_op.cc | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 5d2af38ea6fb1..54883063af3ae 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -433,6 +433,11 @@ int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& b } } + ret = rgw_bucket_sync_user_stats(store, bucket.name); + if ( ret < 0) { + dout(1) << "WARNING: failed sync user stats before bucket delete. ret=" << ret << dendl; + } + RGWObjVersionTracker objv_tracker; ret = store->delete_bucket(bucket, objv_tracker); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index cd8785f19dea8..4f32a584c8b75 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1471,6 +1471,11 @@ void RGWDeleteBucket::execute() } } + ret = rgw_bucket_sync_user_stats(store, s->user.user_id, s->bucket); + if ( ret < 0) { + ldout(s->cct, 1) << "WARNING: failed to sync user stats before bucket delete: ret= " << ret << dendl; + } + ret = store->delete_bucket(s->bucket, ot); if (ret == 0) { -- 2.39.5