]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: open images in read-only mode for "rbd mirror pool status --verbose"
authorIlya Dryomov <idryomov@gmail.com>
Tue, 17 Dec 2024 12:31:09 +0000 (13:31 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 22 Dec 2024 15:46:31 +0000 (16:46 +0100)
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 <idryomov@gmail.com>
(cherry picked from commit 650e21dd4930116d1cece4974a81ee46e248cae7)

src/tools/rbd/action/MirrorPool.cc

index a7877870a04aee47c7a5451f7e01a4cee7b14e09..1a16e58d3e999f5a36a77d326ddbd7498aa26d4e 100644 (file)
@@ -354,6 +354,10 @@ protected:
   virtual ~ImageRequestBase() {
   }
 
+  virtual bool open_read_only() const {
+    return false;
+  }
+
   virtual bool skip_get_info() const {
     return false;
   }
@@ -428,8 +432,13 @@ private:
     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) {
@@ -603,6 +612,10 @@ public:
   }
 
 protected:
+  bool open_read_only() const override {
+    return true;
+  }
+
   bool skip_get_info() const override {
     return true;
   }