@@ -5369,33 +5369,41 @@ std::tuple<int, std::optional<cls_rgw_obj_chain>> RGWRados::send_chain_to_gc(cls
53695369void RGWRados::delete_objs_inline (const DoutPrefixProvider *dpp, cls_rgw_obj_chain& chain,
53705370 const string& tag, optional_yield y)
53715371{
5372- string last_pool;
5373- std::unique_ptr<IoCtx> ctx ( new IoCtx) ;
5374- int ret = 0 ;
5375- for ( auto liter = chain. objs . begin (); liter != chain. objs . end (); ++liter) {
5376- cls_rgw_obj& obj = *liter;
5377- if (obj. pool != last_pool) {
5378- ctx. reset ( new IoCtx );
5379- ret = rgw_init_ioctx (dpp, get_rados_handle (), obj. pool , *ctx);
5380- if (ret < 0 ) {
5381- last_pool = " " ;
5382- ldpp_dout (dpp, 0 ) << " ERROR: failed to create ioctx pool= " <<
5383- obj. pool << dendl ;
5384- continue ;
5385- }
5386- last_pool = obj. pool ;
5387- }
5388- ctx-> locator_set_key (obj. loc );
5389- const string& oid = obj. key . name ; /* just stored raw oid there */
5390- ldpp_dout (dpp, 5 ) << " delete_objs_inline: removing " << obj. pool <<
5391- " : " << obj. key . name << dendl;
5372+ if (chain. objs . empty ()) {
5373+ return ;
5374+ }
5375+
5376+ // initialize an IoCtx for the first object's pool. RGWObjManifest uses the
5377+ // same pool for all tail objects
5378+ auto obj = chain. objs . begin ( );
5379+
5380+ librados::IoCtx ioctx;
5381+ int ret = rgw_init_ioctx (dpp, get_rados_handle (), obj-> pool , ioctx) ;
5382+ if (ret < 0 ) {
5383+ return ;
5384+ }
5385+
5386+ // issue deletions in parallel, up to max_aio at a time
5387+ auto aio = rgw::make_throttle (cct-> _conf -> rgw_multi_obj_del_max_aio , y);
5388+ static constexpr uint64_t cost = 1 ; // 1 throttle unit per request
5389+ static constexpr uint64_t id = 0 ; // ids unused
5390+
5391+ for (; obj != chain. objs . end (); ++obj) {
53925392 ObjectWriteOperation op;
53935393 cls_refcount_put (op, tag, true );
5394- ret = rgw_rados_operate (dpp, *ctx, oid, &op, y);
5395- if (ret < 0 ) {
5396- ldpp_dout (dpp, 5 ) << " delete_objs_inline: refcount put returned error " << ret << dendl;
5397- }
5394+
5395+ rgw_raw_obj raw;
5396+ raw.pool = std::move (obj->pool );
5397+ raw.oid = std::move (obj->key .name );
5398+ raw.loc = std::move (obj->loc );
5399+
5400+ auto completed = aio->get (std::move (raw), rgw::Aio::librados_op (
5401+ ioctx, std::move (op), y), cost, id);
5402+ std::ignore = rgw::check_for_errors (completed);
53985403 }
5404+
5405+ auto completed = aio->drain ();
5406+ std::ignore = rgw::check_for_errors (completed);
53995407}
54005408
54015409static void accumulate_raw_stats (const rgw_bucket_dir_header& header,
0 commit comments