From 6b77d2268e7b17911f0a6809045d356d97d1621a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 8 Jun 2016 12:03:33 -0400 Subject: [PATCH] rbd-mirror: consistently use dout/derr for debug logging Signed-off-by: Jason Dillaman (cherry picked from commit 03f5e4a917b3c18f8ccdaa5ce676ed9731dd2a8f) --- src/tools/rbd_mirror/ImageSync.cc | 68 ++++------- .../rbd_mirror/image_sync/ImageCopyRequest.cc | 45 +++---- .../image_sync/ObjectCopyRequest.cc | 91 +++++++------- .../image_sync/SnapshotCopyRequest.cc | 111 ++++++++---------- .../image_sync/SnapshotCreateRequest.cc | 59 ++++------ .../image_sync/SyncPointCreateRequest.cc | 29 ++--- .../image_sync/SyncPointPruneRequest.cc | 31 ++--- 7 files changed, 179 insertions(+), 255 deletions(-) diff --git a/src/tools/rbd_mirror/ImageSync.cc b/src/tools/rbd_mirror/ImageSync.cc index 629d1ba62c2bf..2f28fd46890c9 100644 --- a/src/tools/rbd_mirror/ImageSync.cc +++ b/src/tools/rbd_mirror/ImageSync.cc @@ -56,8 +56,7 @@ template void ImageSync::cancel() { Mutex::Locker locker(m_lock); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; m_canceled = true; @@ -79,8 +78,7 @@ void ImageSync::send_prune_catch_up_sync_point() { return; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< ImageSync, &ImageSync::handle_prune_catch_up_sync_point>(this); @@ -91,12 +89,11 @@ void ImageSync::send_prune_catch_up_sync_point() { template void ImageSync::handle_prune_catch_up_sync_point(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to prune catch-up sync point: " - << cpp_strerror(r) << dendl; + derr << ": failed to prune catch-up sync point: " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -115,8 +112,7 @@ void ImageSync::send_create_sync_point() { return; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< ImageSync, &ImageSync::handle_create_sync_point>(this); @@ -127,12 +123,11 @@ void ImageSync::send_create_sync_point() { template void ImageSync::handle_create_sync_point(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to create sync point: " << cpp_strerror(r) - << dendl; + derr << ": failed to create sync point: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -149,8 +144,7 @@ void ImageSync::send_copy_snapshots() { return; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< ImageSync, &ImageSync::handle_copy_snapshots>(this); @@ -167,8 +161,7 @@ void ImageSync::send_copy_snapshots() { template void ImageSync::handle_copy_snapshots(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; { Mutex::Locker locker(m_lock); @@ -180,12 +173,11 @@ void ImageSync::handle_copy_snapshots(int r) { } if (r == -ECANCELED) { - ldout(cct, 10) << ": snapshot copy canceled" << dendl; + dout(10) << ": snapshot copy canceled" << dendl; finish(r); return; } else if (r < 0) { - lderr(cct) << ": failed to copy snapshot metadata: " - << cpp_strerror(r) << dendl; + derr << ": failed to copy snapshot metadata: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -202,8 +194,7 @@ void ImageSync::send_copy_image() { return; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< ImageSync, &ImageSync::handle_copy_image>(this); @@ -221,8 +212,7 @@ void ImageSync::send_copy_image() { template void ImageSync::handle_copy_image(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; { Mutex::Locker locker(m_lock); @@ -234,11 +224,11 @@ void ImageSync::handle_copy_image(int r) { } if (r == -ECANCELED) { - ldout(cct, 10) << ": image copy canceled" << dendl; + dout(10) << ": image copy canceled" << dendl; finish(r); return; } else if (r < 0) { - lderr(cct) << ": failed to copy image: " << cpp_strerror(r) << dendl; + derr << ": failed to copy image: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -267,9 +257,8 @@ void ImageSync::send_copy_object_map() { assert(snap_id_it != m_local_image_ctx->snap_ids.end()); librados::snap_t snap_id = snap_id_it->second; - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": snap_id=" << snap_id << ", " - << "snap_name=" << sync_point.snap_name << dendl; + dout(20) << ": snap_id=" << snap_id << ", " + << "snap_name=" << sync_point.snap_name << dendl; // rollback the object map (copy snapshot object map to HEAD) RWLock::WLocker object_map_locker(m_local_image_ctx->object_map_lock); @@ -281,8 +270,7 @@ void ImageSync::send_copy_object_map() { template void ImageSync::handle_copy_object_map(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; assert(r == 0); send_refresh_object_map(); @@ -290,8 +278,7 @@ void ImageSync::handle_copy_object_map(int r) { template void ImageSync::send_refresh_object_map() { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; update_progress("REFRESH_OBJECT_MAP"); @@ -303,8 +290,7 @@ void ImageSync::send_refresh_object_map() { template void ImageSync::handle_refresh_object_map(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; assert(r == 0); { @@ -318,8 +304,7 @@ void ImageSync::handle_refresh_object_map(int r) { template void ImageSync::send_prune_sync_points() { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; update_progress("PRUNE_SYNC_POINTS"); @@ -332,12 +317,11 @@ void ImageSync::send_prune_sync_points() { template void ImageSync::handle_prune_sync_points(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to prune sync point: " - << cpp_strerror(r) << dendl; + derr << ": failed to prune sync point: " + << cpp_strerror(r) << dendl; finish(r); return; } diff --git a/src/tools/rbd_mirror/image_sync/ImageCopyRequest.cc b/src/tools/rbd_mirror/image_sync/ImageCopyRequest.cc index 1cd582ab1fdb8..e037f8812608b 100644 --- a/src/tools/rbd_mirror/image_sync/ImageCopyRequest.cc +++ b/src/tools/rbd_mirror/image_sync/ImageCopyRequest.cc @@ -56,8 +56,7 @@ template void ImageCopyRequest::cancel() { Mutex::Locker locker(m_lock); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; m_canceled = true; } @@ -81,8 +80,7 @@ void ImageCopyRequest::send_update_max_object_count() { update_progress("UPDATE_MAX_OBJECT_COUNT"); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": sync_object_count=" << max_objects << dendl; + dout(20) << ": sync_object_count=" << max_objects << dendl; m_client_meta_copy = *m_client_meta; m_client_meta_copy.sync_object_count = max_objects; @@ -99,21 +97,19 @@ void ImageCopyRequest::send_update_max_object_count() { template void ImageCopyRequest::handle_update_max_object_count(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r == 0) { Mutex::Locker locker(m_lock); if (m_canceled) { - ldout(cct, 10) << ": image copy canceled" << dendl; + dout(10) << ": image copy canceled" << dendl; r = -ECANCELED; } } if (r < 0) { if (r != -ECANCELED) { - lderr(cct) << ": failed to update client data: " << cpp_strerror(r) - << dendl; + derr << ": failed to update client data: " << cpp_strerror(r) << dendl; } finish(r); return; @@ -159,10 +155,9 @@ void ImageCopyRequest::send_object_copies() { template void ImageCopyRequest::send_next_object_copy() { assert(m_lock.is_locked()); - CephContext *cct = m_local_image_ctx->cct; if (m_canceled && m_ret_val == 0) { - ldout(cct, 10) << ": image copy canceled" << dendl; + dout(10) << ": image copy canceled" << dendl; m_ret_val = -ECANCELED; } @@ -172,7 +167,7 @@ void ImageCopyRequest::send_next_object_copy() { uint64_t ono = m_object_no++; - ldout(cct, 20) << ": object_num=" << ono << dendl; + dout(20) << ": object_num=" << ono << dendl; ++m_current_ops; @@ -185,8 +180,7 @@ void ImageCopyRequest::send_next_object_copy() { template void ImageCopyRequest::handle_object_copy(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; int percent; bool complete; @@ -198,7 +192,7 @@ void ImageCopyRequest::handle_object_copy(int r) { percent = 100 * m_object_no / m_end_object_no; if (r < 0) { - lderr(cct) << ": object copy failed: " << cpp_strerror(r) << dendl; + derr << ": object copy failed: " << cpp_strerror(r) << dendl; if (m_ret_val == 0) { m_ret_val = r; } @@ -231,8 +225,7 @@ void ImageCopyRequest::send_flush_sync_point() { m_sync_point->object_number = boost::none; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": sync_point=" << *m_sync_point << dendl; + dout(20) << ": sync_point=" << *m_sync_point << dendl; bufferlist client_data_bl; librbd::journal::ClientData client_data(m_client_meta_copy); @@ -246,14 +239,13 @@ void ImageCopyRequest::send_flush_sync_point() { template void ImageCopyRequest::handle_flush_sync_point(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { *m_client_meta = m_client_meta_copy; - lderr(cct) << ": failed to update client data: " << cpp_strerror(r) - << dendl; + derr << ": failed to update client data: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -263,7 +255,6 @@ void ImageCopyRequest::handle_flush_sync_point(int r) { template int ImageCopyRequest::compute_snap_map() { - CephContext *cct = m_local_image_ctx->cct; librados::snap_t snap_id_start = 0; librados::snap_t snap_id_end; @@ -271,8 +262,8 @@ int ImageCopyRequest::compute_snap_map() { RWLock::RLocker snap_locker(m_remote_image_ctx->snap_lock); snap_id_end = m_remote_image_ctx->get_snap_id(m_sync_point->snap_name); if (snap_id_end == CEPH_NOSNAP) { - lderr(cct) << ": failed to locate snapshot: " - << m_sync_point->snap_name << dendl; + derr << ": failed to locate snapshot: " + << m_sync_point->snap_name << dendl; return -ENOENT; } @@ -280,8 +271,8 @@ int ImageCopyRequest::compute_snap_map() { snap_id_start = m_remote_image_ctx->get_snap_id( m_sync_point->from_snap_name); if (snap_id_start == CEPH_NOSNAP) { - lderr(cct) << ": failed to locate from snapshot: " - << m_sync_point->from_snap_name << dendl; + derr << ": failed to locate from snapshot: " + << m_sync_point->from_snap_name << dendl; return -ENOENT; } } @@ -301,7 +292,7 @@ int ImageCopyRequest::compute_snap_map() { } if (m_snap_map.empty()) { - lderr(cct) << ": failed to map snapshots within boundary" << dendl; + derr << ": failed to map snapshots within boundary" << dendl; return -EINVAL; } diff --git a/src/tools/rbd_mirror/image_sync/ObjectCopyRequest.cc b/src/tools/rbd_mirror/image_sync/ObjectCopyRequest.cc index 38567ce77de1d..89acd037a6c76 100644 --- a/src/tools/rbd_mirror/image_sync/ObjectCopyRequest.cc +++ b/src/tools/rbd_mirror/image_sync/ObjectCopyRequest.cc @@ -36,10 +36,9 @@ ObjectCopyRequest::ObjectCopyRequest(I *local_image_ctx, I *remote_image_ctx, m_remote_io_ctx.dup(m_remote_image_ctx->data_ctx); m_remote_oid = m_remote_image_ctx->get_object_name(object_number); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": " - << "remote_oid=" << m_remote_oid << ", " - << "local_oid=" << m_local_oid << dendl; + dout(20) << ": " + << "remote_oid=" << m_remote_oid << ", " + << "local_oid=" << m_local_oid << dendl; } template @@ -49,8 +48,7 @@ void ObjectCopyRequest::send() { template void ObjectCopyRequest::send_list_snaps() { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; librados::AioCompletion *rados_completion = create_rados_ack_callback< ObjectCopyRequest, &ObjectCopyRequest::handle_list_snaps>(this); @@ -71,15 +69,14 @@ void ObjectCopyRequest::handle_list_snaps(int r) { r = m_snap_ret; } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r == -ENOENT) { finish(0); return; } if (r < 0) { - lderr(cct) << ": failed to list snaps: " << cpp_strerror(r) << dendl; + derr << ": failed to list snaps: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -90,7 +87,6 @@ void ObjectCopyRequest::handle_list_snaps(int r) { template void ObjectCopyRequest::send_read_object() { - CephContext *cct = m_local_image_ctx->cct; if (m_snap_sync_ops.empty()) { // no more snapshot diffs to read from remote finish(0); @@ -111,12 +107,12 @@ void ObjectCopyRequest::send_read_object() { switch (std::get<0>(sync_op)) { case SYNC_OP_TYPE_WRITE: if (!read_required) { - ldout(cct, 20) << ": remote_snap_seq=" << remote_snap_seq << dendl; + dout(20) << ": remote_snap_seq=" << remote_snap_seq << dendl; read_required = true; } - ldout(cct, 20) << ": read op: " << std::get<1>(sync_op) << "~" - << std::get<2>(sync_op) << dendl; + dout(20) << ": read op: " << std::get<1>(sync_op) << "~" + << std::get<2>(sync_op) << dendl; op.read(std::get<1>(sync_op), std::get<2>(sync_op), &std::get<3>(sync_op), nullptr); break; @@ -140,12 +136,11 @@ void ObjectCopyRequest::send_read_object() { template void ObjectCopyRequest::handle_read_object(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to read from remote object: " << cpp_strerror(r) - << dendl; + derr << ": failed to read from remote object: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -172,10 +167,9 @@ void ObjectCopyRequest::send_write_object() { } } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": " - << "local_snap_seq=" << local_snap_seq << ", " - << "local_snaps=" << local_snap_ids << dendl; + dout(20) << ": " + << "local_snap_seq=" << local_snap_seq << ", " + << "local_snaps=" << local_snap_ids << dendl; auto &sync_ops = m_snap_sync_ops.begin()->second; assert(!sync_ops.empty()); @@ -184,16 +178,16 @@ void ObjectCopyRequest::send_write_object() { for (auto &sync_op : sync_ops) { switch (std::get<0>(sync_op)) { case SYNC_OP_TYPE_WRITE: - ldout(cct, 20) << ": write op: " << std::get<1>(sync_op) << "~" - << std::get<3>(sync_op).length() << dendl; + dout(20) << ": write op: " << std::get<1>(sync_op) << "~" + << std::get<3>(sync_op).length() << dendl; op.write(std::get<1>(sync_op), std::get<3>(sync_op)); break; case SYNC_OP_TYPE_TRUNC: - ldout(cct, 20) << ": trunc op: " << std::get<1>(sync_op) << dendl; + dout(20) << ": trunc op: " << std::get<1>(sync_op) << dendl; op.truncate(std::get<1>(sync_op)); break; case SYNC_OP_TYPE_REMOVE: - ldout(cct, 20) << ": remove op" << dendl; + dout(20) << ": remove op" << dendl; op.remove(); break; default: @@ -211,15 +205,14 @@ void ObjectCopyRequest::send_write_object() { template void ObjectCopyRequest::handle_write_object(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r == -ENOENT) { r = 0; } if (r < 0) { - lderr(cct) << ": failed to write to local object: " << cpp_strerror(r) - << dendl; + derr << ": failed to write to local object: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -249,12 +242,10 @@ void ObjectCopyRequest::send_update_object_map() { auto snap_object_state = *m_snap_object_states.begin(); m_snap_object_states.erase(m_snap_object_states.begin()); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": " - << "local_snap_id=" << snap_object_state.first << ", " - << "object_state=" << static_cast( - snap_object_state.second) - << dendl; + dout(20) << ": " + << "local_snap_id=" << snap_object_state.first << ", " + << "object_state=" << static_cast(snap_object_state.second) + << dendl; RWLock::WLocker object_map_locker(m_local_image_ctx->object_map_lock); Context *ctx = create_context_callback< @@ -270,8 +261,7 @@ void ObjectCopyRequest::send_update_object_map() { template void ObjectCopyRequest::handle_update_object_map(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; assert(r == 0); if (!m_snap_object_states.empty()) { @@ -299,13 +289,13 @@ void ObjectCopyRequest::compute_diffs() { calc_snap_set_diff(cct, m_snap_set, start_remote_snap_id, end_remote_snap_id, &diff, &end_size, &exists); - ldout(cct, 20) << ": " - << "start_remote_snap=" << start_remote_snap_id << ", " - << "end_remote_snap_id=" << end_remote_snap_id << ", " - << "end_local_snap_id=" << end_local_snap_id << ", " - << "diff=" << diff << ", " - << "end_size=" << end_size << ", " - << "exists=" << exists << dendl; + dout(20) << ": " + << "start_remote_snap=" << start_remote_snap_id << ", " + << "end_remote_snap_id=" << end_remote_snap_id << ", " + << "end_local_snap_id=" << end_local_snap_id << ", " + << "diff=" << diff << ", " + << "end_size=" << end_size << ", " + << "exists=" << exists << dendl; if (exists) { // clip diff to size of object (in case it was truncated) @@ -314,7 +304,7 @@ void ObjectCopyRequest::compute_diffs() { trunc.insert(end_size, prev_end_size); trunc.intersection_of(diff); diff.subtract(trunc); - ldout(cct, 20) << ": clearing truncate diff: " << trunc << dendl; + dout(20) << ": clearing truncate diff: " << trunc << dendl; } // prepare the object map state @@ -331,15 +321,15 @@ void ObjectCopyRequest::compute_diffs() { // object write/zero, or truncate for (auto it = diff.begin(); it != diff.end(); ++it) { - ldout(cct, 20) << ": read/write op: " << it.get_start() << "~" - << it.get_len() << dendl; + dout(20) << ": read/write op: " << it.get_start() << "~" + << it.get_len() << dendl; m_snap_sync_ops[end_remote_snap_id].emplace_back(SYNC_OP_TYPE_WRITE, it.get_start(), it.get_len(), bufferlist()); } if (end_size < prev_end_size) { - ldout(cct, 20) << ": trunc op: " << end_size << dendl; + dout(20) << ": trunc op: " << end_size << dendl; m_snap_sync_ops[end_remote_snap_id].emplace_back(SYNC_OP_TYPE_TRUNC, end_size, 0U, bufferlist()); @@ -347,7 +337,7 @@ void ObjectCopyRequest::compute_diffs() { } else { if (prev_exists) { // object remove - ldout(cct, 20) << ": remove op" << dendl; + dout(20) << ": remove op" << dendl; m_snap_sync_ops[end_remote_snap_id].emplace_back(SYNC_OP_TYPE_REMOVE, 0U, 0U, bufferlist()); } @@ -361,8 +351,7 @@ void ObjectCopyRequest::compute_diffs() { template void ObjectCopyRequest::finish(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; m_on_finish->complete(r); delete this; diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc index 671bc0a060587..026e72f9c0faa 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SnapshotCopyRequest.cc @@ -85,14 +85,12 @@ template void SnapshotCopyRequest::cancel() { Mutex::Locker locker(m_lock); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; m_canceled = true; } template void SnapshotCopyRequest::send_snap_unprotect() { - CephContext *cct = m_local_image_ctx->cct; SnapIdSet::iterator snap_id_it = m_local_snap_ids.begin(); if (m_prev_snap_id != CEPH_NOSNAP) { @@ -107,8 +105,8 @@ void SnapshotCopyRequest::send_snap_unprotect() { int r = m_local_image_ctx->is_snap_unprotected(local_snap_id, &local_unprotected); if (r < 0) { - lderr(cct) << "failed to retrieve local snap unprotect status: " - << cpp_strerror(r) << dendl; + derr << "failed to retrieve local snap unprotect status: " + << cpp_strerror(r) << dendl; m_local_image_ctx->snap_lock.put_read(); finish(r); return; @@ -134,8 +132,8 @@ void SnapshotCopyRequest::send_snap_unprotect() { r = m_remote_image_ctx->is_snap_unprotected(snap_seq_it->first, &remote_unprotected); if (r < 0) { - lderr(cct) << "failed to retrieve remote snap unprotect status: " - << cpp_strerror(r) << dendl; + derr << "failed to retrieve remote snap unprotect status: " + << cpp_strerror(r) << dendl; m_remote_image_ctx->snap_lock.put_read(); finish(r); return; @@ -162,9 +160,9 @@ void SnapshotCopyRequest::send_snap_unprotect() { m_prev_snap_id = *snap_id_it; m_snap_name = get_snapshot_name(m_local_image_ctx, m_prev_snap_id); - ldout(cct, 20) << ": " - << "snap_name=" << m_snap_name << ", " - << "snap_id=" << m_prev_snap_id << dendl; + dout(20) << ": " + << "snap_name=" << m_snap_name << ", " + << "snap_id=" << m_prev_snap_id << dendl; Context *ctx = create_context_callback< SnapshotCopyRequest, &SnapshotCopyRequest::handle_snap_unprotect>( @@ -176,12 +174,11 @@ void SnapshotCopyRequest::send_snap_unprotect() { template void SnapshotCopyRequest::handle_snap_unprotect(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to unprotect snapshot '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to unprotect snapshot '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -195,8 +192,6 @@ void SnapshotCopyRequest::handle_snap_unprotect(int r) { template void SnapshotCopyRequest::send_snap_remove() { - CephContext *cct = m_local_image_ctx->cct; - SnapIdSet::iterator snap_id_it = m_local_snap_ids.begin(); if (m_prev_snap_id != CEPH_NOSNAP) { snap_id_it = m_local_snap_ids.upper_bound(m_prev_snap_id); @@ -227,9 +222,9 @@ void SnapshotCopyRequest::send_snap_remove() { m_prev_snap_id = *snap_id_it; m_snap_name = get_snapshot_name(m_local_image_ctx, m_prev_snap_id); - ldout(cct, 20) << ": " - << "snap_name=" << m_snap_name << ", " - << "snap_id=" << m_prev_snap_id << dendl; + dout(20) << ": " + << "snap_name=" << m_snap_name << ", " + << "snap_id=" << m_prev_snap_id << dendl; Context *ctx = create_context_callback< SnapshotCopyRequest, &SnapshotCopyRequest::handle_snap_remove>( @@ -240,12 +235,11 @@ void SnapshotCopyRequest::send_snap_remove() { template void SnapshotCopyRequest::handle_snap_remove(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to remove snapshot '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to remove snapshot '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -259,8 +253,6 @@ void SnapshotCopyRequest::handle_snap_remove(int r) { template void SnapshotCopyRequest::send_snap_create() { - CephContext *cct = m_local_image_ctx->cct; - SnapIdSet::iterator snap_id_it = m_remote_snap_ids.begin(); if (m_prev_snap_id != CEPH_NOSNAP) { snap_id_it = m_remote_snap_ids.upper_bound(m_prev_snap_id); @@ -289,8 +281,8 @@ void SnapshotCopyRequest::send_snap_create() { auto snap_info_it = m_remote_image_ctx->snap_info.find(m_prev_snap_id); if (snap_info_it == m_remote_image_ctx->snap_info.end()) { m_remote_image_ctx->snap_lock.put_read(); - lderr(cct) << "failed to retrieve remote snap info: " << m_snap_name - << dendl; + derr << "failed to retrieve remote snap info: " << m_snap_name + << dendl; finish(-ENOENT); return; } @@ -305,15 +297,15 @@ void SnapshotCopyRequest::send_snap_create() { m_remote_image_ctx->snap_lock.put_read(); - ldout(cct, 20) << ": " - << "snap_name=" << m_snap_name << ", " - << "snap_id=" << m_prev_snap_id << ", " - << "size=" << size << ", " - << "parent_info=[" - << "pool_id=" << parent_spec.pool_id << ", " - << "image_id=" << parent_spec.image_id << ", " - << "snap_id=" << parent_spec.snap_id << ", " - << "overlap=" << parent_overlap << "]" << dendl; + dout(20) << ": " + << "snap_name=" << m_snap_name << ", " + << "snap_id=" << m_prev_snap_id << ", " + << "size=" << size << ", " + << "parent_info=[" + << "pool_id=" << parent_spec.pool_id << ", " + << "image_id=" << parent_spec.image_id << ", " + << "snap_id=" << parent_spec.snap_id << ", " + << "overlap=" << parent_overlap << "]" << dendl; Context *ctx = create_context_callback< SnapshotCopyRequest, &SnapshotCopyRequest::handle_snap_create>( @@ -325,12 +317,11 @@ void SnapshotCopyRequest::send_snap_create() { template void SnapshotCopyRequest::handle_snap_create(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to create snapshot '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to create snapshot '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -345,8 +336,8 @@ void SnapshotCopyRequest::handle_snap_create(int r) { assert(snap_it != m_local_image_ctx->snap_ids.end()); librados::snap_t local_snap_id = snap_it->second; - ldout(cct, 20) << ": mapping remote snap id " << m_prev_snap_id << " to " - << local_snap_id << dendl; + dout(20) << ": mapping remote snap id " << m_prev_snap_id << " to " + << local_snap_id << dendl; m_snap_seqs[m_prev_snap_id] = local_snap_id; send_snap_create(); @@ -354,8 +345,6 @@ void SnapshotCopyRequest::handle_snap_create(int r) { template void SnapshotCopyRequest::send_snap_protect() { - CephContext *cct = m_local_image_ctx->cct; - SnapIdSet::iterator snap_id_it = m_remote_snap_ids.begin(); if (m_prev_snap_id != CEPH_NOSNAP) { snap_id_it = m_remote_snap_ids.upper_bound(m_prev_snap_id); @@ -369,8 +358,8 @@ void SnapshotCopyRequest::send_snap_protect() { int r = m_remote_image_ctx->is_snap_protected(remote_snap_id, &remote_protected); if (r < 0) { - lderr(cct) << "failed to retrieve remote snap protect status: " - << cpp_strerror(r) << dendl; + derr << "failed to retrieve remote snap protect status: " + << cpp_strerror(r) << dendl; m_remote_image_ctx->snap_lock.put_read(); finish(r); return; @@ -391,8 +380,8 @@ void SnapshotCopyRequest::send_snap_protect() { r = m_local_image_ctx->is_snap_protected(snap_seq_it->second, &local_protected); if (r < 0) { - lderr(cct) << "failed to retrieve local snap protect status: " - << cpp_strerror(r) << dendl; + derr << "failed to retrieve local snap protect status: " + << cpp_strerror(r) << dendl; m_local_image_ctx->snap_lock.put_read(); finish(r); return; @@ -414,9 +403,9 @@ void SnapshotCopyRequest::send_snap_protect() { m_prev_snap_id = *snap_id_it; m_snap_name = get_snapshot_name(m_remote_image_ctx, m_prev_snap_id); - ldout(cct, 20) << ": " - << "snap_name=" << m_snap_name << ", " - << "snap_id=" << m_prev_snap_id << dendl; + dout(20) << ": " + << "snap_name=" << m_snap_name << ", " + << "snap_id=" << m_prev_snap_id << dendl; Context *ctx = create_context_callback< SnapshotCopyRequest, &SnapshotCopyRequest::handle_snap_protect>( @@ -427,12 +416,11 @@ void SnapshotCopyRequest::send_snap_protect() { template void SnapshotCopyRequest::handle_snap_protect(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to protect snapshot '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to protect snapshot '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -446,8 +434,7 @@ void SnapshotCopyRequest::handle_snap_protect(int r) { template void SnapshotCopyRequest::send_update_client() { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; compute_snap_map(); @@ -466,12 +453,11 @@ void SnapshotCopyRequest::send_update_client() { template void SnapshotCopyRequest::handle_update_client(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to update client data: " << cpp_strerror(r) - << dendl; + derr << ": failed to update client data: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -493,8 +479,7 @@ bool SnapshotCopyRequest::handle_cancellation() { return false; } } - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 10) << ": snapshot copy canceled" << dendl; + dout(10) << ": snapshot copy canceled" << dendl; finish(-ECANCELED); return true; } diff --git a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc index e15ca958e4828..ee0c80fbad24b 100644 --- a/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.cc @@ -48,8 +48,7 @@ void SnapshotCreateRequest::send_set_size() { } m_local_image_ctx->snap_lock.put_read(); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; // Change the image size on disk so that the snapshot picks up // the expected size. We can do this because the last snapshot @@ -69,12 +68,11 @@ void SnapshotCreateRequest::send_set_size() { template void SnapshotCreateRequest::handle_set_size(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to update image size '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to update image size '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -99,8 +97,7 @@ void SnapshotCreateRequest::send_remove_parent() { } m_local_image_ctx->parent_lock.put_read(); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; librados::ObjectWriteOperation op; librbd::cls_client::remove_parent(&op); @@ -116,12 +113,11 @@ void SnapshotCreateRequest::send_remove_parent() { template void SnapshotCreateRequest::handle_remove_parent(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to remove parent '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to remove parent '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -147,8 +143,7 @@ void SnapshotCreateRequest::send_set_parent() { } m_local_image_ctx->parent_lock.put_read(); - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; librados::ObjectWriteOperation op; librbd::cls_client::set_parent(&op, m_parent_spec, m_parent_overlap); @@ -164,12 +159,11 @@ void SnapshotCreateRequest::send_set_parent() { template void SnapshotCreateRequest::handle_set_parent(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to set parent '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to set parent '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -186,8 +180,7 @@ void SnapshotCreateRequest::handle_set_parent(int r) { template void SnapshotCreateRequest::send_snap_create() { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": snap_name=" << m_snap_name << dendl; + dout(20) << ": snap_name=" << m_snap_name << dendl; Context *ctx = create_context_callback< SnapshotCreateRequest, &SnapshotCreateRequest::handle_snap_create>( @@ -199,12 +192,11 @@ void SnapshotCreateRequest::send_snap_create() { template void SnapshotCreateRequest::handle_snap_create(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to create snapshot '" << m_snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to create snapshot '" << m_snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -213,7 +205,6 @@ void SnapshotCreateRequest::handle_snap_create(int r) { } template void SnapshotCreateRequest::send_create_object_map() { - CephContext *cct = m_local_image_ctx->cct; if (!m_local_image_ctx->test_features(RBD_FEATURE_OBJECT_MAP)) { finish(0); @@ -223,7 +214,7 @@ void SnapshotCreateRequest::send_create_object_map() { m_local_image_ctx->snap_lock.get_read(); auto snap_it = m_local_image_ctx->snap_ids.find(m_snap_name); if (snap_it == m_local_image_ctx->snap_ids.end()) { - lderr(cct) << "failed to locate snap: " << m_snap_name << dendl; + derr << "failed to locate snap: " << m_snap_name << dendl; m_local_image_ctx->snap_lock.put_read(); finish(-ENOENT); return; @@ -235,9 +226,9 @@ void SnapshotCreateRequest::send_create_object_map() { m_local_image_ctx->id, local_snap_id)); uint64_t object_count = Striper::get_num_objects(m_local_image_ctx->layout, m_size); - ldout(cct, 20) << ": " - << "object_map_oid=" << object_map_oid << ", " - << "object_count=" << object_count << dendl; + dout(20) << ": " + << "object_map_oid=" << object_map_oid << ", " + << "object_count=" << object_count << dendl; // initialize an empty object map of the correct size (object sync // will populate the object map) @@ -254,12 +245,11 @@ void SnapshotCreateRequest::send_create_object_map() { template void SnapshotCreateRequest::handle_create_object_map(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to create object map: " << cpp_strerror(r) - << dendl; + derr << ": failed to create object map: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -269,8 +259,7 @@ void SnapshotCreateRequest::handle_create_object_map(int r) { template void SnapshotCreateRequest::finish(int r) { - CephContext *cct = m_local_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; m_on_finish->complete(r); delete this; diff --git a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc index 589f532fd2c29..102d48908ddad 100644 --- a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc @@ -60,8 +60,7 @@ void SyncPointCreateRequest::send_update_client() { sync_point.snap_name = SNAP_NAME_PREFIX + "." + m_mirror_uuid + "." + uuid_gen.to_string(); - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": sync_point=" << sync_point << dendl; + dout(20) << ": sync_point=" << sync_point << dendl; bufferlist client_data_bl; librbd::journal::ClientData client_data(m_client_meta_copy); @@ -75,12 +74,11 @@ void SyncPointCreateRequest::send_update_client() { template void SyncPointCreateRequest::handle_update_client(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to update client data: " << cpp_strerror(r) - << dendl; + derr << ": failed to update client data: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -93,8 +91,7 @@ void SyncPointCreateRequest::handle_update_client(int r) { template void SyncPointCreateRequest::send_refresh_image() { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< SyncPointCreateRequest, &SyncPointCreateRequest::handle_refresh_image>( @@ -104,11 +101,10 @@ void SyncPointCreateRequest::send_refresh_image() { template void SyncPointCreateRequest::handle_refresh_image(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": remote image refresh failed: " << cpp_strerror(r) << dendl; + derr << ": remote image refresh failed: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -118,8 +114,7 @@ void SyncPointCreateRequest::handle_refresh_image(int r) { template void SyncPointCreateRequest::send_create_snap() { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; MirrorPeerSyncPoint &sync_point = m_client_meta_copy.sync_points.back(); @@ -132,14 +127,13 @@ void SyncPointCreateRequest::send_create_snap() { template void SyncPointCreateRequest::handle_create_snap(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r == -EEXIST) { send_update_client(); return; } else if (r < 0) { - lderr(cct) << ": failed to create snapshot: " << cpp_strerror(r) << dendl; + derr << ": failed to create snapshot: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -149,8 +143,7 @@ void SyncPointCreateRequest::handle_create_snap(int r) { template void SyncPointCreateRequest::finish(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; m_on_finish->complete(r); delete this; diff --git a/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc b/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc index 7e6ab2e2b159d..d9b5e8ebdc14a 100644 --- a/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc @@ -91,8 +91,7 @@ void SyncPointPruneRequest::send_remove_snap() { const std::string &snap_name = m_snap_names.front(); - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": snap_name=" << snap_name << dendl; + dout(20) << ": snap_name=" << snap_name << dendl; Context *ctx = create_context_callback< SyncPointPruneRequest, &SyncPointPruneRequest::handle_remove_snap>( @@ -102,8 +101,7 @@ void SyncPointPruneRequest::send_remove_snap() { template void SyncPointPruneRequest::handle_remove_snap(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; assert(!m_snap_names.empty()); std::string snap_name = m_snap_names.front(); @@ -113,8 +111,8 @@ void SyncPointPruneRequest::handle_remove_snap(int r) { r = 0; } if (r < 0) { - lderr(cct) << ": failed to remove snapshot '" << snap_name << "': " - << cpp_strerror(r) << dendl; + derr << ": failed to remove snapshot '" << snap_name << "': " + << cpp_strerror(r) << dendl; finish(r); return; } @@ -124,8 +122,7 @@ void SyncPointPruneRequest::handle_remove_snap(int r) { template void SyncPointPruneRequest::send_refresh_image() { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; Context *ctx = create_context_callback< SyncPointPruneRequest, &SyncPointPruneRequest::handle_refresh_image>( @@ -135,11 +132,10 @@ void SyncPointPruneRequest::send_refresh_image() { template void SyncPointPruneRequest::handle_refresh_image(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": remote image refresh failed: " << cpp_strerror(r) << dendl; + derr << ": remote image refresh failed: " << cpp_strerror(r) << dendl; finish(r); return; } @@ -149,8 +145,7 @@ void SyncPointPruneRequest::handle_refresh_image(int r) { template void SyncPointPruneRequest::send_update_client() { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << dendl; + dout(20) << dendl; if (m_sync_complete) { m_client_meta_copy.sync_points.pop_front(); @@ -175,12 +170,11 @@ void SyncPointPruneRequest::send_update_client() { template void SyncPointPruneRequest::handle_update_client(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; if (r < 0) { - lderr(cct) << ": failed to update client data: " << cpp_strerror(r) - << dendl; + derr << ": failed to update client data: " << cpp_strerror(r) + << dendl; finish(r); return; } @@ -192,8 +186,7 @@ void SyncPointPruneRequest::handle_update_client(int r) { template void SyncPointPruneRequest::finish(int r) { - CephContext *cct = m_remote_image_ctx->cct; - ldout(cct, 20) << ": r=" << r << dendl; + dout(20) << ": r=" << r << dendl; m_on_finish->complete(r); delete this; -- 2.39.5