@@ -461,22 +461,21 @@ static void dump_index_check(map<RGWObjCategory, RGWStorageStats> existing_stats
461461}
462462
463463int RGWBucket::check_bad_index_multipart (RGWBucketAdminOpState& op_state,
464- RGWFormatterFlusher& flusher,
465- const DoutPrefixProvider *dpp, std::string *err_msg)
464+ RGWFormatterFlusher& flusher,
465+ const DoutPrefixProvider *dpp,
466+ std::string *err_msg)
466467{
467- bool fix_index = op_state.will_fix_index ();
468-
469- bool is_truncated;
470- map<string, bool > meta_objs;
471- map<rgw_obj_index_key, string> all_objs;
468+ const bool fix_index = op_state.will_fix_index ();
472469
473470 bucket = op_state.get_bucket ()->clone ();
474471
475472 rgw::sal::Bucket::ListParams params;
476-
477473 params.list_versions = true ;
478474 params.ns = RGW_OBJ_NS_MULTIPART;
479475
476+ std::map<std::string, bool > meta_objs;
477+ std::map<rgw_obj_index_key, std::string> all_objs;
478+ bool is_truncated;
480479 do {
481480 rgw::sal::Bucket::ListResults results;
482481 int r = bucket->list (dpp, params, listing_max_entries, results, null_yield);
@@ -488,20 +487,19 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
488487 }
489488 is_truncated = results.is_truncated ;
490489
491- vector<rgw_bucket_dir_entry>::iterator iter;
492- for (iter = results.objs .begin (); iter != results.objs .end (); ++iter) {
493- rgw_obj_index_key key = iter->key ;
490+ for (const auto & o : results.objs ) {
491+ rgw_obj_index_key key = o.key ;
494492 rgw_obj obj (bucket->get_key (), key);
495- string oid = obj.get_oid ();
493+ std:: string oid = obj.get_oid ();
496494
497495 int pos = oid.find_last_of (' .' );
498496 if (pos < 0 ) {
499497 /* obj has no suffix */
500498 all_objs[key] = oid;
501499 } else {
502500 /* obj has suffix */
503- string name = oid.substr (0 , pos);
504- string suffix = oid.substr (pos + 1 );
501+ std:: string name = oid.substr (0 , pos);
502+ std:: string suffix = oid.substr (pos + 1 );
505503
506504 if (suffix.compare (" meta" ) == 0 ) {
507505 meta_objs[name] = true ;
@@ -512,20 +510,20 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
512510 }
513511 } while (is_truncated);
514512
515- list<rgw_obj_index_key> objs_to_unlink;
513+ std:: list<rgw_obj_index_key> objs_to_unlink;
516514 Formatter *f = flusher.get_formatter ();
517515
518516 f->open_array_section (" invalid_multipart_entries" );
519517
520- for (auto aiter = all_objs.begin (); aiter != all_objs.end (); ++aiter) {
521- string& name = aiter->second ;
522-
518+ for (const auto & o : all_objs) {
519+ const std::string& name = o.second ;
523520 if (meta_objs.find (name) == meta_objs.end ()) {
524- objs_to_unlink.push_back (aiter-> first );
521+ objs_to_unlink.push_back (o. first );
525522 }
526523
527524 if (objs_to_unlink.size () > listing_max_entries) {
528525 if (fix_index) {
526+ // note: under rados this removes directly from rados index objects
529527 int r = bucket->remove_objs_from_index (dpp, objs_to_unlink);
530528 if (r < 0 ) {
531529 set_err_msg (err_msg, " ERROR: remove_obj_from_index() returned error: " +
@@ -534,13 +532,14 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
534532 }
535533 }
536534
537- dump_mulipart_index_results (objs_to_unlink, flusher. get_formatter () );
535+ dump_mulipart_index_results (objs_to_unlink, f );
538536 flusher.flush ();
539537 objs_to_unlink.clear ();
540538 }
541539 }
542540
543541 if (fix_index) {
542+ // note: under rados this removes directly from rados index objects
544543 int r = bucket->remove_objs_from_index (dpp, objs_to_unlink);
545544 if (r < 0 ) {
546545 set_err_msg (err_msg, " ERROR: remove_obj_from_index() returned error: " +
0 commit comments