#include "librbd/ImageState.h"
#include "librbd/Utils.h"
#include "librbd/image/CloneRequest.h"
+#include "librbd/image/RemoveRequest.h"
#include "librbd/internal.h"
#include "librbd/Utils.h"
#include "librbd/api/Config.h"
return 0;
}
+template <typename I>
+int Image<I>::remove(IoCtx& io_ctx, const std::string &image_name,
+ const std::string &image_id, ProgressContext& prog_ctx,
+ bool force, bool from_trash_remove)
+{
+ CephContext *cct((CephContext *)io_ctx.cct());
+ ldout(cct, 20) << (image_id.empty() ? image_name : image_id) << dendl;
+
+ ThreadPool *thread_pool;
+ ContextWQ *op_work_queue;
+ ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
+
+ C_SaferCond cond;
+ auto req = librbd::image::RemoveRequest<>::create(
+ io_ctx, image_name, image_id, force, from_trash_remove, prog_ctx,
+ op_work_queue, &cond);
+ req->send();
+
+ return cond.wait();
+}
+
} // namespace api
} // namespace librbd
const char *snap_name);
static int snap_set(ImageCtxT *ictx, uint64_t snap_id);
+ static int remove(librados::IoCtx& io_ctx, const std::string &image_name,
+ const std::string &image_id, ProgressContext& prog_ctx,
+ bool force=false, bool from_trash_remove=false);
+
};
} // namespace api
#include "librbd/Operations.h"
#include "librbd/TrashWatcher.h"
#include "librbd/Utils.h"
+#include "librbd/api/Image.h"
#include "librbd/trash/MoveRequest.h"
#define dout_subsys ceph_subsys_rbd
return r;
}
- r = librbd::remove(io_ctx, "", image_id, prog_ctx, false, true);
+ r = Image<I>::remove(io_ctx, "", image_id, prog_ctx, false, true);
if (r < 0) {
lderr(cct) << "error removing image " << image_id
<< ", which is pending deletion" << dendl;
#include "librbd/exclusive_lock/StandardPolicy.h"
#include "librbd/image/CloneRequest.h"
#include "librbd/image/CreateRequest.h"
-#include "librbd/image/RemoveRequest.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/ImageRequest.h"
#include "librbd/io/ImageRequestWQ.h"
return 0;
}
- int remove(IoCtx& io_ctx, const std::string &image_name,
- const std::string &image_id, ProgressContext& prog_ctx,
- bool force, bool from_trash_remove)
- {
- CephContext *cct((CephContext *)io_ctx.cct());
- ldout(cct, 20) << "remove " << &io_ctx << " "
- << (image_id.empty() ? image_name : image_id) << dendl;
-
- ThreadPool *thread_pool;
- ContextWQ *op_work_queue;
- ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);
-
- C_SaferCond cond;
- auto req = librbd::image::RemoveRequest<>::create(
- io_ctx, image_name, image_id, force, from_trash_remove, prog_ctx,
- op_work_queue, &cond);
- req->send();
-
- return cond.wait();
- }
-
int snap_list(ImageCtx *ictx, vector<snap_info_t>& snaps)
{
ldout(ictx->cct, 20) << "snap_list " << ictx << dendl;
int lock_break(ImageCtx *ictx, rbd_lock_mode_t lock_mode,
const std::string &lock_owner);
- int remove(librados::IoCtx& io_ctx, const std::string &image_name,
- const std::string &image_id, ProgressContext& prog_ctx,
- bool force=false, bool from_trash_remove=false);
-
int snap_list(ImageCtx *ictx, std::vector<snap_info_t>& snaps);
int snap_exists(ImageCtx *ictx, const cls::rbd::SnapshotNamespace& snap_namespace,
const char *snap_name, bool *exists);
TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::NoOpProgressContext prog_ctx;
- int r = librbd::remove(io_ctx, name, "", prog_ctx);
+ int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
tracepoint(librbd, remove_exit, r);
return r;
}
{
TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
- int r = librbd::remove(io_ctx, name, "", pctx);
+ int r = librbd::api::Image<>::remove(io_ctx, name, "", pctx);
tracepoint(librbd, remove_exit, r);
return r;
}
TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::NoOpProgressContext prog_ctx;
- int r = librbd::remove(io_ctx, name, "", prog_ctx);
+ int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
tracepoint(librbd, remove_exit, r);
return r;
}
TracepointProvider::initialize<tracepoint_traits>(get_cct(io_ctx));
tracepoint(librbd, remove_enter, io_ctx.get_pool_name().c_str(), io_ctx.get_id(), name);
librbd::CProgressContext prog_ctx(cb, cbdata);
- int r = librbd::remove(io_ctx, name, "", prog_ctx);
+ int r = librbd::api::Image<>::remove(io_ctx, name, "", prog_ctx);
tracepoint(librbd, remove_exit, r);
return r;
}
}
librbd::NoOpProgressContext no_op;
- ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+ ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
ASSERT_EQ(0, ictx->operations->snap_unprotect(cls::rbd::UserSnapshotNamespace(), "snap"));
};
}
librbd::NoOpProgressContext no_op;
- ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+ ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
ASSERT_EQ(0, ictx->operations->snap_unprotect(cls::rbd::UserSnapshotNamespace(), "snap"));
};
parent->unlock_image();
}
librbd::NoOpProgressContext no_op;
- ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", no_op));
+ ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "", no_op));
} BOOST_SCOPE_EXIT_END;
ASSERT_EQ(0, open_image(clone_name, &ictx2));
}
librbd::NoOpProgressContext remove_no_op;
- ASSERT_EQ(0, librbd::remove(m_ioctx, clone_name, "", remove_no_op));
+ ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, clone_name, "",
+ remove_no_op));
} BOOST_SCOPE_EXIT_END;
ASSERT_EQ(0, open_image(clone_name, &ictx2));
close_image(ictx);
librbd::NoOpProgressContext remove_no_op;
- ASSERT_EQ(0, librbd::remove(m_ioctx, "", image_id, remove_no_op));
+ ASSERT_EQ(0, librbd::api::Image<>::remove(m_ioctx, "", image_id,
+ remove_no_op));
}
static int iterate_cb(uint64_t off, size_t len, int exists, void *arg)
promote_image();
}
NoOpProgressContext ctx;
- int r = remove(m_local_io_ctx, m_image_name, "", ctx, force);
+ int r = librbd::api::Image<>::remove(m_local_io_ctx, m_image_name, "", ctx,
+ force);
EXPECT_EQ(1, r == 0 || r == -ENOENT);
}