From: Jason Dillaman Date: Thu, 10 Oct 2019 00:04:32 +0000 (-0400) Subject: librbd: reuse async trash remove state machine X-Git-Tag: v13.2.7~65^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16cb15c2fa920d7eec1c7f4601f99037454235c8;p=ceph.git librbd: reuse async trash remove state machine Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index ed9f9ac330b8..9c84b6ebc16c 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -52,6 +52,7 @@ #include "librbd/mirror/EnableRequest.h" #include "librbd/operation/TrimRequest.h" #include "librbd/trash/MoveRequest.h" +#include "librbd/trash/RemoveRequest.h" #include "journal/Journaler.h" @@ -1605,16 +1606,17 @@ int enable_mirroring(IoCtx &io_ctx, const std::string &image_id) { return -EPERM; } - r = remove(io_ctx, "", image_id, prog_ctx, false, true); + ThreadPool *thread_pool; + ContextWQ *op_work_queue; + ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue); + + C_SaferCond cond; + auto req = librbd::trash::RemoveRequest<>::create( + io_ctx, image_id, op_work_queue, force, prog_ctx, &cond); + req->send(); + + r = cond.wait(); if (r < 0) { - lderr(cct) << "error removing image " << image_id - << ", which is pending deletion" << dendl; - return r; - } - r = cls_client::trash_remove(&io_ctx, image_id); - if (r < 0 && r != -ENOENT) { - lderr(cct) << "error removing image " << image_id - << " from rbd_trash object" << dendl; return r; }