rbd_trash_image_source_t trash_image_source =
RBD_TRASH_IMAGE_SOURCE_REMOVING;
uint64_t expire_seconds = 0;
- bool check_watchers = true;
if (config.get_val<bool>("rbd_move_to_trash_on_remove")) {
// keep the image in the trash upon remove requests
trash_image_source = RBD_TRASH_IMAGE_SOURCE_USER;
expire_seconds = config.get_val<uint64_t>(
"rbd_move_to_trash_on_remove_expire_seconds");
- check_watchers = false;
}
r = Trash<I>::move(io_ctx, trash_image_source, image_name, image_id,
- expire_seconds, check_watchers);
+ expire_seconds);
if (r >= 0) {
if (trash_image_source == RBD_TRASH_IMAGE_SOURCE_REMOVING) {
// proceed with attempting to immediately remove the image
}
int r = Trash<I>::move(m_src_io_ctx, RBD_TRASH_IMAGE_SOURCE_MIGRATION,
- m_src_image_ctx->name, 0, false);
+ m_src_image_ctx->name, 0);
if (r < 0) {
lderr(m_cct) << "failed moving image to trash: " << cpp_strerror(r)
<< dendl;
template <typename I>
int Trash<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
const std::string &image_name, const std::string &image_id,
- uint64_t delay, bool check_for_watchers) {
+ uint64_t delay) {
ceph_assert(!image_name.empty() && !image_id.empty());
CephContext *cct((CephContext *)io_ctx.cct());
ldout(cct, 20) << &io_ctx << " name=" << image_name << ", id=" << image_id
}
ictx->snap_lock.put_read();
- if (check_for_watchers) {
- std::list<obj_watch_t> t_watchers;
- int flags = librbd::image::LIST_WATCHERS_FILTER_OUT_MY_INSTANCE |
- librbd::image::LIST_WATCHERS_FILTER_OUT_MIRROR_INSTANCES;
- C_SaferCond t_on_list_watchers;
- auto list_req = librbd::image::ListWatchersRequest<I>::create(
- *ictx, flags, &t_watchers, &t_on_list_watchers);
- list_req->send();
- r = t_on_list_watchers.wait();
- if (r < 0) {
- lderr(cct) << "failed listing watchers:" << cpp_strerror(r) << dendl;
- ictx->state->close();
- return r;
- }
- if (!t_watchers.empty()) {
- lderr(cct) << "image has watchers - not moving" << dendl;
- ictx->state->close();
- return -EBUSY;
- }
- }
-
r = disable_mirroring<I>(ictx);
if (r < 0) {
ictx->state->close();
template <typename I>
int Trash<I>::move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
- const std::string &image_name, uint64_t delay,
- bool check_for_watchers) {
+ const std::string &image_name, uint64_t delay) {
CephContext *cct((CephContext *)io_ctx.cct());
ldout(cct, 20) << &io_ctx << " name=" << image_name << dendl;
}
ceph_assert(!image_name.empty() && !image_id.empty());
- return Trash<I>::move(io_ctx, source, image_name, image_id, delay,
- check_for_watchers);
+ return Trash<I>::move(io_ctx, source, image_name, image_id, delay);
}
template <typename I>
struct Trash {
static int move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
- const std::string &image_name, uint64_t delay,
- bool check_for_watchers);
+ const std::string &image_name, uint64_t delay);
static int move(librados::IoCtx &io_ctx, rbd_trash_image_source_t source,
const std::string &image_name, const std::string &image_id,
- uint64_t delay, bool check_for_watchers);
+ uint64_t delay);
static int get(librados::IoCtx &io_ctx, const std::string &id,
trash_image_info_t *info);
static int list(librados::IoCtx &io_ctx,
tracepoint(librbd, trash_move_enter, io_ctx.get_pool_name().c_str(),
io_ctx.get_id(), name);
int r = librbd::api::Trash<>::move(io_ctx, RBD_TRASH_IMAGE_SOURCE_USER,
- name, delay, false);
+ name, delay);
tracepoint(librbd, trash_move_exit, r);
return r;
}
tracepoint(librbd, trash_move_enter, io_ctx.get_pool_name().c_str(),
io_ctx.get_id(), name);
int r = librbd::api::Trash<>::move(io_ctx, RBD_TRASH_IMAGE_SOURCE_USER, name,
- delay, false);
+ delay);
tracepoint(librbd, trash_move_exit, r);
return r;
}
ASSERT_EQ(0, image.close());
ASSERT_EQ(0, api::Trash<>::move(m_ioctx, RBD_TRASH_IMAGE_SOURCE_USER,
- image_name1, image_id1, 0, false));
+ image_name1, image_id1, 0));
ASSERT_EQ(0, api::Trash<>::move(m_ioctx, RBD_TRASH_IMAGE_SOURCE_REMOVING,
- image_name2, image_id2, 0, true));
+ image_name2, image_id2, 0));
TrashEntries trash_entries{compare_lambda};
TrashEntries expected_trash_entries{compare_lambda};