.set_default(true)
.set_description("automatically acquire/release exclusive lock until it is explicitly requested"),
+ Option("rbd_move_to_trash_on_remove", Option::TYPE_BOOL, Option::LEVEL_BASIC)
+ .set_default(false)
+ .set_description("automatically move images to the trash when deleted"),
+
+ Option("rbd_move_to_trash_on_remove_expire_seconds", Option::TYPE_UINT, Option::LEVEL_BASIC)
+ .set_default(0)
+ .set_description("default number of seconds to protect deleted images in the trash"),
+
Option("rbd_mirroring_resync_after_disconnect", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
.set_default(false)
.set_description("automatically start image resync after mirroring is disconnected due to being laggy"),
#include "librbd/internal.h"
#include "librbd/Utils.h"
#include "librbd/api/Config.h"
+#include "librbd/api/Trash.h"
#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
CephContext *cct((CephContext *)io_ctx.cct());
ldout(cct, 20) << (image_id.empty() ? image_name : image_id) << dendl;
+ if (image_id.empty()) {
+ // id will only be supplied when used internally
+ ConfigProxy config(cct->_conf);
+ Config<I>::apply_pool_overrides(io_ctx, &config);
+
+ if (config.get_val<bool>("rbd_move_to_trash_on_remove")) {
+ return Trash<I>::move(
+ io_ctx, RBD_TRASH_IMAGE_SOURCE_USER, image_name,
+ config.get_val<uint64_t>("rbd_move_to_trash_on_remove_expire_seconds"));
+ }
+ }
+
ThreadPool *thread_pool;
ContextWQ *op_work_queue;
ImageCtx::get_thread_pool_instance(cct, &thread_pool, &op_work_queue);