Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rbd-mirror: removed dedicated thread from image deleter #19000

Merged
merged 7 commits into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 26 additions & 12 deletions src/cls/rbd/cls_rbd_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,28 +517,42 @@ namespace librbd {
op->exec("rbd", "snapshot_rename", bl);
}

int get_snapcontext(librados::IoCtx *ioctx, const std::string &oid,
::SnapContext *snapc)
void get_snapcontext_start(librados::ObjectReadOperation *op)
{
bufferlist inbl, outbl;

int r = ioctx->exec(oid, "rbd", "get_snapcontext", inbl, outbl);
if (r < 0)
return r;
bufferlist bl;
op->exec("rbd", "get_snapcontext", bl);
}

int get_snapcontext_finish(bufferlist::iterator *it,
::SnapContext *snapc)
{
try {
bufferlist::iterator iter = outbl.begin();
::decode(*snapc, iter);
::decode(*snapc, *it);
} catch (const buffer::error &err) {
return -EBADMSG;
}

if (!snapc->is_valid())
if (!snapc->is_valid()) {
return -EBADMSG;

}
return 0;
}

int get_snapcontext(librados::IoCtx *ioctx, const std::string &oid,
::SnapContext *snapc)
{
librados::ObjectReadOperation op;
get_snapcontext_start(&op);

bufferlist out_bl;
int r = ioctx->operate(oid, &op, &out_bl);
if (r < 0) {
return r;
}

auto bl_it = out_bl.begin();
return get_snapcontext_finish(&bl_it, snapc);
}

void snapshot_list_start(librados::ObjectReadOperation *op,
const std::vector<snapid_t> &ids) {
for (auto snap_id : ids) {
Expand Down
3 changes: 3 additions & 0 deletions src/cls/rbd/cls_rbd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ namespace librbd {
void snapshot_rename(librados::ObjectWriteOperation *op,
snapid_t src_snap_id,
const std::string &dst_name);
void get_snapcontext_start(librados::ObjectReadOperation *op);
int get_snapcontext_finish(bufferlist::iterator *it,
::SnapContext *snapc);
int get_snapcontext(librados::IoCtx *ioctx, const std::string &oid,
::SnapContext *snapc);

Expand Down
7 changes: 6 additions & 1 deletion src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5870,9 +5870,14 @@ static std::vector<Option> get_rbd_mirror_options() {
.set_default(30)
.set_description("interval to refresh peers in rbd-mirror daemon"),

Option("rbd_mirror_concurrent_image_deletions", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(1)
.set_min(1)
.set_description("maximum number of image deletions in parallel"),

Option("rbd_mirror_delete_retry_interval", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
.set_default(30)
.set_description("interval to check and retry the failed requests in deleter"),
.set_description("interval to check and retry the failed deletion requests"),

Option("rbd_mirror_image_state_check_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(30)
Expand Down
11 changes: 11 additions & 0 deletions src/librbd/deep_copy/SnapshotCopyRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ void SnapshotCopyRequest<I>::handle_snap_unprotect(int r) {
finish(r);
return;
}

{
// avoid the need to refresh to delete the newly unprotected snapshot
RWLock::RLocker snap_locker(m_dst_image_ctx->snap_lock);
auto snap_info_it = m_dst_image_ctx->snap_info.find(m_prev_snap_id);
if (snap_info_it != m_dst_image_ctx->snap_info.end()) {
snap_info_it->second.protection_status =
RBD_PROTECTION_STATUS_UNPROTECTED;
}
}

if (handle_cancellation()) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/rbd_mirror/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ add_executable(unittest_rbd_mirror
test_mock_InstanceWatcher.cc
test_mock_LeaderWatcher.cc
test_mock_PoolWatcher.cc
image_deleter/test_mock_RemoveRequest.cc
image_deleter/test_mock_SnapshotPurgeRequest.cc
image_replayer/test_mock_BootstrapRequest.cc
image_replayer/test_mock_CreateImageRequest.cc
image_replayer/test_mock_EventPreprocessor.cc
Expand Down