From a48c081d203c5cc10e36546b2d1c0a429ba3480f Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Sat, 6 Feb 2016 02:00:22 +0100 Subject: [PATCH 1/2] rgw/rgw_orphan: check the return value of save_state It was discovered by covscan that we do not check the return value of save_state in this one case. Signed-off-by: Boris Ranto --- src/rgw/rgw_orphan.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_orphan.cc b/src/rgw/rgw_orphan.cc index f59e1f75db4..861b89c84d2 100644 --- a/src/rgw/rgw_orphan.cc +++ b/src/rgw/rgw_orphan.cc @@ -578,7 +578,11 @@ int RGWOrphanSearch::build_linked_oids_index() return ret; } - save_state(); + ret = save_state(); + if (ret < 0) { + cerr << __func__ << ": ERROR: failed to write state ret=" << ret << std::endl; + return ret; + } return 0; } From 06507992e3fad837c4667f467d59fc026a2ca0e8 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Feb 2016 12:03:24 -0800 Subject: [PATCH 2/2] 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 eyang@us.fujitsu.com --- 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 3e4e85435e7..f9e15e1f108 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -499,6 +499,11 @@ int rgw_remove_bucket(RGWRados *store, rgw_bucket& bucket, bool delete_children) } } + ret = rgw_bucket_sync_user_stats(store, bucket.tenant, 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 8475f48ecc0..e5a6af131be 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1878,6 +1878,11 @@ void RGWDeleteBucket::execute() } } + op_ret = rgw_bucket_sync_user_stats(store, s->user.user_id, s->bucket); + if ( op_ret < 0) { + ldout(s->cct, 1) << "WARNING: failed to sync user stats before bucket delete: op_ret= " << op_ret << dendl; + } + op_ret = store->delete_bucket(s->bucket, ot); if (op_ret == 0) { op_ret = rgw_unlink_bucket(store, s->user.user_id, s->bucket.tenant,