Skip to content

Commit

Permalink
Merge pull request #9630 from dillaman/wip-16233
Browse files Browse the repository at this point in the history
jewel: rbd-mirror: do not propagate deletions when pool unavailable

Reviewed-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Jun 12, 2016
2 parents 39f530a + bc658ed commit 7edf393
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/tools/rbd_mirror/PoolWatcher.cc
Expand Up @@ -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(
Expand All @@ -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();
Expand All @@ -81,18 +83,19 @@ 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<std::string, std::string> images_map;
r = librbd::list_images_v2(m_remote_io_ctx, images_map);
if (r < 0) {
derr << "error retrieving image names from pool " << pool_name << ": "
<< cpp_strerror(r) << dendl;
return r;
}

std::map<std::string, std::string> image_id_to_name;
Expand All @@ -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<std::string> image_name(boost::none);
Expand All @@ -124,6 +127,8 @@ void PoolWatcher::refresh(ImageIds *image_ids) {
}
r = mirror_images.size();
} while (r == max_read);

return 0;
}

} // namespace mirror
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rbd_mirror/PoolWatcher.h
Expand Up @@ -64,7 +64,7 @@ class PoolWatcher {

ImageIds m_images;

void refresh(ImageIds *image_ids);
int refresh(ImageIds *image_ids);
};

} // namespace mirror
Expand Down

0 comments on commit 7edf393

Please sign in to comment.