*/
I &image_ctx;
- std::string request_type;
+ std::string name;
+ exclusive_lock::OperationRequestType request_type;
bool permit_snapshot;
boost::function<void(Context*)> local;
boost::function<void(Context*)> remote;
Context *on_finish;
bool request_lock = false;
- C_InvokeAsyncRequest(I &image_ctx, const std::string& request_type,
+ C_InvokeAsyncRequest(I &image_ctx, const std::string& name,
+ exclusive_lock::OperationRequestType request_type,
bool permit_snapshot,
const boost::function<void(Context*)>& local,
const boost::function<void(Context*)>& remote,
const std::set<int> &filter_error_codes,
Context *on_finish)
- : image_ctx(image_ctx), request_type(request_type),
+ : image_ctx(image_ctx), name(name), request_type(request_type),
permit_snapshot(permit_snapshot), local(local), remote(remote),
filter_error_codes(filter_error_codes), on_finish(on_finish) {
}
}
if (image_ctx.exclusive_lock->is_lock_owner() &&
- image_ctx.exclusive_lock->accept_requests()) {
+ image_ctx.exclusive_lock->accept_request(request_type, nullptr)) {
send_local_request();
owner_lock.put_read();
return;
ldout(cct, 20) << __func__ << ": r=" << r << dendl;
if (r == -EOPNOTSUPP) {
- ldout(cct, 5) << request_type << " not supported by current lock owner"
- << dendl;
+ ldout(cct, 5) << name << " not supported by current lock owner" << dendl;
request_lock = true;
send_refresh_image();
return;
return;
}
- ldout(cct, 5) << request_type << " timed out notifying lock owner"
- << dendl;
+ ldout(cct, 5) << name << " timed out notifying lock owner" << dendl;
send_refresh_image();
}
}
uint64_t request_id = ++m_async_request_seq;
- r = invoke_async_request("flatten", false,
+ r = invoke_async_request("flatten",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false,
boost::bind(&Operations<I>::execute_flatten, this,
boost::ref(prog_ctx), _1),
boost::bind(&ImageWatcher<I>::notify_flatten,
}
uint64_t request_id = ++m_async_request_seq;
- r = invoke_async_request("rebuild object map", true,
+ r = invoke_async_request("rebuild object map",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, true,
boost::bind(&Operations<I>::execute_rebuild_object_map,
this, boost::ref(prog_ctx), _1),
boost::bind(&ImageWatcher<I>::notify_rebuild_object_map,
return r;
}
- r = invoke_async_request("check object map", true,
+ r = invoke_async_request("check object map",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL, true,
boost::bind(&Operations<I>::check_object_map, this,
boost::ref(prog_ctx), _1),
[this](Context *c) {
}
if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
- r = invoke_async_request("rename", true,
+ r = invoke_async_request("rename",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true,
boost::bind(&Operations<I>::execute_rename, this,
dstname, _1),
boost::bind(&ImageWatcher<I>::notify_rename,
}
uint64_t request_id = ++m_async_request_seq;
- r = invoke_async_request("resize", false,
+ r = invoke_async_request("resize",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false,
boost::bind(&Operations<I>::execute_resize, this,
size, allow_shrink, boost::ref(prog_ctx), _1, 0),
boost::bind(&ImageWatcher<I>::notify_resize,
m_image_ctx.snap_lock.put_read();
C_InvokeAsyncRequest<I> *req = new C_InvokeAsyncRequest<I>(
- m_image_ctx, "snap_create", true,
+ m_image_ctx, "snap_create", exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true,
boost::bind(&Operations<I>::execute_snap_create, this, snap_namespace, snap_name,
_1, 0, false),
boost::bind(&ImageWatcher<I>::notify_snap_create, m_image_ctx.image_watcher,
}
}
- r = prepare_image_update(false);
+ r = prepare_image_update(exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false);
if (r < 0) {
return r;
}
m_image_ctx.snap_lock.put_read();
if (proxy_op) {
+ auto request_type = exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL;
+ if (cls::rbd::get_snap_namespace_type(snap_namespace) ==
+ cls::rbd::SNAPSHOT_NAMESPACE_TYPE_TRASH) {
+ request_type = exclusive_lock::OPERATION_REQUEST_TYPE_TRASH_SNAP_REMOVE;
+ }
C_InvokeAsyncRequest<I> *req = new C_InvokeAsyncRequest<I>(
- m_image_ctx, "snap_remove", true,
+ m_image_ctx, "snap_remove", request_type, true,
boost::bind(&Operations<I>::execute_snap_remove, this, snap_namespace, snap_name, _1),
boost::bind(&ImageWatcher<I>::notify_snap_remove, m_image_ctx.image_watcher,
snap_namespace, snap_name, _1),
}
if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
- r = invoke_async_request("snap_rename", true,
+ r = invoke_async_request("snap_rename",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true,
boost::bind(&Operations<I>::execute_snap_rename,
this, snap_id, dstname, _1),
boost::bind(&ImageWatcher<I>::notify_snap_rename,
}
if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
- r = invoke_async_request("snap_protect", true,
+ r = invoke_async_request("snap_protect",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true,
boost::bind(&Operations<I>::execute_snap_protect,
this, snap_namespace, snap_name, _1),
boost::bind(&ImageWatcher<I>::notify_snap_protect,
}
if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) {
- r = invoke_async_request("snap_unprotect", true,
+ r = invoke_async_request("snap_unprotect",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true,
boost::bind(&Operations<I>::execute_snap_unprotect,
this, snap_namespace, snap_name, _1),
boost::bind(&ImageWatcher<I>::notify_snap_unprotect,
C_SaferCond limit_ctx;
{
RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
- r = prepare_image_update(true);
+ r = prepare_image_update(exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true);
if (r < 0) {
return r;
}
C_SaferCond cond_ctx;
{
RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
- r = prepare_image_update(true);
+ r = prepare_image_update(exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true);
if (r < 0) {
return r;
}
r = cond_ctx.wait();
} else {
- r = invoke_async_request("update_features", false,
+ r = invoke_async_request("update_features",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false,
boost::bind(&Operations<I>::execute_update_features,
this, features, enabled, _1, 0),
boost::bind(&ImageWatcher<I>::notify_update_features,
C_SaferCond metadata_ctx;
{
RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
- r = prepare_image_update(true);
+ r = prepare_image_update(exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true);
if (r < 0) {
return r;
}
C_SaferCond metadata_ctx;
{
RWLock::RLocker owner_lock(m_image_ctx.owner_lock);
- r = prepare_image_update(true);
+ r = prepare_image_update(exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ true);
if (r < 0) {
return r;
}
}
uint64_t request_id = ++m_async_request_seq;
- r = invoke_async_request("migrate", false,
+ r = invoke_async_request("migrate",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false,
boost::bind(&Operations<I>::execute_migrate, this,
boost::ref(prog_ctx), _1),
boost::bind(&ImageWatcher<I>::notify_migrate,
int Operations<I>::sparsify(size_t sparse_size, ProgressContext &prog_ctx) {
CephContext *cct = m_image_ctx.cct;
ldout(cct, 20) << "sparsify" << dendl;
-
+
if (sparse_size < 4096 || sparse_size > m_image_ctx.get_object_size() ||
(sparse_size & (sparse_size - 1)) != 0) {
lderr(cct) << "sparse size should be power of two not less than 4096"
}
uint64_t request_id = ++m_async_request_seq;
- int r = invoke_async_request("sparsify", false,
+ int r = invoke_async_request("sparsify",
+ exclusive_lock::OPERATION_REQUEST_TYPE_GENERAL,
+ false,
boost::bind(&Operations<I>::execute_sparsify,
this, sparse_size,
boost::ref(prog_ctx), _1),
}
template <typename I>
-int Operations<I>::prepare_image_update(bool request_lock) {
+int Operations<I>::prepare_image_update(
+ exclusive_lock::OperationRequestType request_type, bool request_lock) {
ceph_assert(m_image_ctx.owner_lock.is_locked() &&
!m_image_ctx.owner_lock.is_wlocked());
if (m_image_ctx.image_watcher == nullptr) {
RWLock::WLocker owner_locker(m_image_ctx.owner_lock);
if (m_image_ctx.exclusive_lock != nullptr &&
(!m_image_ctx.exclusive_lock->is_lock_owner() ||
- !m_image_ctx.exclusive_lock->accept_requests())) {
+ !m_image_ctx.exclusive_lock->accept_request(request_type, nullptr))) {
attempting_lock = true;
m_image_ctx.exclusive_lock->block_requests(0);
}
template <typename I>
-int Operations<I>::invoke_async_request(const std::string& request_type,
- bool permit_snapshot,
- const boost::function<void(Context*)>& local_request,
- const boost::function<void(Context*)>& remote_request) {
+int Operations<I>::invoke_async_request(
+ const std::string& name, exclusive_lock::OperationRequestType request_type,
+ bool permit_snapshot, const boost::function<void(Context*)>& local_request,
+ const boost::function<void(Context*)>& remote_request) {
C_SaferCond ctx;
- C_InvokeAsyncRequest<I> *req = new C_InvokeAsyncRequest<I>(m_image_ctx,
+ C_InvokeAsyncRequest<I> *req = new C_InvokeAsyncRequest<I>(m_image_ctx, name,
request_type,
permit_snapshot,
local_request,