From 6a97b1d2a3f6a2c959e11cd3526f94b1a0cae078 Mon Sep 17 00:00:00 2001 From: "J. Eric Ivancich" Date: Mon, 8 Nov 2021 14:05:24 -0500 Subject: [PATCH] rgw: fix bucket purge incomplete multipart uploads The marker was not working correctly as segments of the bucket index were listed to shut down any incomplete multipart uploads. This fixes the marker, so it's maintained properly across iterations. Signed-off-by: J. Eric Ivancich (cherry picked from commit 9f2c2d901dff0acc16f80cb6ad32bb8c39c9ac6e) Conflicts: src/rgw/rgw_multi.cc src/rgw/rgw_multi.h - dpp changes --- src/rgw/rgw_multi.cc | 28 +++++++++++++++++++--------- src/rgw/rgw_multi.h | 23 ++++++++++++++--------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/rgw/rgw_multi.cc b/src/rgw/rgw_multi.cc index 2e4858c150069..16e62a579dff5 100644 --- a/src/rgw/rgw_multi.cc +++ b/src/rgw/rgw_multi.cc @@ -285,16 +285,19 @@ int abort_multipart_upload(rgw::sal::RGWRadosStore *store, CephContext *cct, return (ret == -ENOENT) ? -ERR_NO_SUCH_UPLOAD : ret; } -int list_bucket_multiparts(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info, - const string& prefix, const string& marker, - const string& delim, +int list_bucket_multiparts(rgw::sal::RGWRadosStore* store, + RGWBucketInfo& bucket_info, + const std::string& prefix, + std::string& marker, // in/out + const std::string& delim, const int& max_uploads, - vector *objs, - map *common_prefixes, bool *is_truncated) + std::vector *objs, + std::map *common_prefixes, + bool *is_truncated) { RGWRados::Bucket target(store->getRados(), bucket_info); RGWRados::Bucket::List list_op(&target); - MultipartMetaFilter mp_filter; + MultipartMetaFilter mp_filter; // filter out all but ".meta" entries list_op.params.prefix = prefix; list_op.params.delim = delim; @@ -302,11 +305,18 @@ int list_bucket_multiparts(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket list_op.params.ns = RGW_OBJ_NS_MULTIPART; list_op.params.filter = &mp_filter; - return(list_op.list_objects(max_uploads, objs, common_prefixes, is_truncated, null_yield)); + int ret = list_op.list_objects(max_uploads, objs, common_prefixes, is_truncated, null_yield); + if (ret >= 0) { + marker = list_op.params.marker.name; + } + return ret; } -int abort_bucket_multiparts(rgw::sal::RGWRadosStore *store, CephContext *cct, RGWBucketInfo& bucket_info, - string& prefix, string& delim) +int abort_bucket_multiparts(rgw::sal::RGWRadosStore* store, + CephContext* cct, + RGWBucketInfo& bucket_info, + const std::string& prefix, + const std::string& delim) { constexpr int max = 1000; int ret, num_deleted = 0; diff --git a/src/rgw/rgw_multi.h b/src/rgw/rgw_multi.h index 5f8fa11b336a5..3d6993ea29bea 100644 --- a/src/rgw/rgw_multi.h +++ b/src/rgw/rgw_multi.h @@ -126,14 +126,19 @@ extern int list_multipart_parts(rgw::sal::RGWRadosStore *store, struct req_state extern int abort_multipart_upload(rgw::sal::RGWRadosStore *store, CephContext *cct, RGWObjectCtx *obj_ctx, RGWBucketInfo& bucket_info, RGWMPObj& mp_obj); -extern int list_bucket_multiparts(rgw::sal::RGWRadosStore *store, RGWBucketInfo& bucket_info, - const string& prefix, - const string& marker, - const string& delim, +extern int list_bucket_multiparts(rgw::sal::RGWRadosStore* store, + RGWBucketInfo& bucket_info, + const std::string& prefix, + std::string& marker, // in/out + const std::string& delim, const int& max_uploads, - vector *objs, - map *common_prefixes, bool *is_truncated); - -extern int abort_bucket_multiparts(rgw::sal::RGWRadosStore *store, CephContext *cct, RGWBucketInfo& bucket_info, - string& prefix, string& delim); + std::vector* objs, + std::map* common_prefixes, + bool* is_truncated); + +extern int abort_bucket_multiparts(rgw::sal::RGWRadosStore* store, + CephContext* cct, + RGWBucketInfo& bucket_info, + const std::string& prefix, + const std::string& delim); #endif -- 2.39.5