Skip to content

Commit

Permalink
rbd: open images in read-only mode for "rbd mirror pool status --verb…
Browse files Browse the repository at this point in the history
…ose"

This is cleaner and makes the command run a bit faster because watches
won't be established.

Fixes: https://tracker.ceph.com/issues/69319
Signed-off-by: Ilya Dryomov <[email protected]>
  • Loading branch information
idryomov committed Dec 19, 2024
1 parent 862ed6e commit 650e21d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/tools/rbd/action/MirrorPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ class ImageRequestBase {
virtual ~ImageRequestBase() {
}

virtual bool open_read_only() const {
return false;
}

virtual bool skip_get_info() const {
return false;
}
Expand Down Expand Up @@ -429,8 +433,13 @@ class ImageRequestBase {
librbd::RBD rbd;
auto aio_completion = utils::create_aio_completion<
ImageRequestBase, &ImageRequestBase::handle_open_image>(this);
rbd.aio_open(m_io_ctx, m_image, m_image_name.c_str(), nullptr,
aio_completion);
if (open_read_only()) {
rbd.aio_open_read_only(m_io_ctx, m_image, m_image_name.c_str(), nullptr,
aio_completion);
} else {
rbd.aio_open(m_io_ctx, m_image, m_image_name.c_str(), nullptr,
aio_completion);
}
}

void handle_open_image(int r) {
Expand Down Expand Up @@ -604,6 +613,10 @@ class StatusImageRequest : public ImageRequestBase {
}

protected:
bool open_read_only() const override {
return true;
}

bool skip_get_info() const override {
return true;
}
Expand Down

0 comments on commit 650e21d

Please sign in to comment.