From d321634414fa4b90c66474557ec990dfc935ae29 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 10 Jun 2016 08:15:19 -0400 Subject: [PATCH] rbd-mirror: do not propagate deletions when pool unavailable Fixes: http://tracker.ceph.com/issues/16229 Signed-off-by: Jason Dillaman --- src/tools/rbd_mirror/PoolWatcher.cc | 17 +++++++++++------ src/tools/rbd_mirror/PoolWatcher.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/tools/rbd_mirror/PoolWatcher.cc b/src/tools/rbd_mirror/PoolWatcher.cc index 184e947fd4cbe..21a2633775fe3 100644 --- a/src/tools/rbd_mirror/PoolWatcher.cc +++ b/src/tools/rbd_mirror/PoolWatcher.cc @@ -57,10 +57,12 @@ const PoolWatcher::ImageIds& PoolWatcher::get_images() const void PoolWatcher::refresh_images(bool reschedule) { ImageIds image_ids; - refresh(&image_ids); + int r = refresh(&image_ids); Mutex::Locker l(m_lock); - m_images = std::move(image_ids); + if (r >= 0) { + m_images = std::move(image_ids); + } if (!m_stopping && reschedule) { FunctionContext *ctx = new FunctionContext( @@ -72,7 +74,7 @@ void PoolWatcher::refresh_images(bool reschedule) // about new/removed mirrored images } -void PoolWatcher::refresh(ImageIds *image_ids) { +int PoolWatcher::refresh(ImageIds *image_ids) { dout(20) << "enter" << dendl; std::string pool_name = m_remote_io_ctx.get_pool_name(); @@ -81,11 +83,11 @@ void PoolWatcher::refresh(ImageIds *image_ids) { if (r < 0) { derr << "could not tell whether mirroring was enabled for " << pool_name << ": " << cpp_strerror(r) << dendl; - return; + return r; } if (mirror_mode == RBD_MIRROR_MODE_DISABLED) { dout(20) << "pool " << pool_name << " has mirroring disabled" << dendl; - return; + return 0; } std::map images_map; @@ -93,6 +95,7 @@ void PoolWatcher::refresh(ImageIds *image_ids) { if (r < 0) { derr << "error retrieving image names from pool " << pool_name << ": " << cpp_strerror(r) << dendl; + return r; } std::map image_id_to_name; @@ -109,7 +112,7 @@ void PoolWatcher::refresh(ImageIds *image_ids) { if (r < 0) { derr << "error listing mirrored image directory: " << cpp_strerror(r) << dendl; - continue; + return r; } for (auto it = mirror_images.begin(); it != mirror_images.end(); ++it) { boost::optional image_name(boost::none); @@ -124,6 +127,8 @@ void PoolWatcher::refresh(ImageIds *image_ids) { } r = mirror_images.size(); } while (r == max_read); + + return 0; } } // namespace mirror diff --git a/src/tools/rbd_mirror/PoolWatcher.h b/src/tools/rbd_mirror/PoolWatcher.h index 9983f9d56edfd..d29a6309e1ad9 100644 --- a/src/tools/rbd_mirror/PoolWatcher.h +++ b/src/tools/rbd_mirror/PoolWatcher.h @@ -64,7 +64,7 @@ private: ImageIds m_images; - void refresh(ImageIds *image_ids); + int refresh(ImageIds *image_ids); }; } // namespace mirror -- 2.39.5