]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
extblkdev: Expand interface, add plugin id retrieval
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 22 Jan 2026 13:55:51 +0000 (13:55 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Mon, 4 May 2026 16:05:18 +0000 (16:05 +0000)
Plugin identification is a tool to implement two features:
1) Check the plugin is initialized
2) Verify that the plugin initialzied is the proper one

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
(cherry picked from commit f4a002a06492e98c1d4468e7d202b249c5d7ea1a)

src/blk/BlockDevice.h
src/blk/kernel/KernelDevice.cc
src/blk/kernel/KernelDevice.h
src/extblkdev/ExtBlkDevInterface.h
src/extblkdev/vdo/ExtBlkDevVdo.h

index cb795eaa5e5b5122e9e01c943b50d6f2ef220f3a..cedb4ba747ec5113bd36f1989cfe22888e457036 100644 (file)
@@ -248,6 +248,9 @@ public:
   virtual int get_ebd_state(ExtBlkDevState &state) const {
     return -ENOENT;
   }
+  virtual int get_ebd_id(std::string& id) const {
+    return -ENOENT;
+  }
 
   virtual int collect_metadata(const std::string& prefix, std::map<std::string,std::string> *pm) const = 0;
 
index 80b771fa7cce266fef036e6b178aa2bdbb03fef6..261f854f59b9a10505a08e6ed98a4e4c423b6afa 100644 (file)
@@ -475,6 +475,13 @@ int KernelDevice::get_ebd_state(ExtBlkDevState &state) const
   return -ENOENT;
 }
 
+int KernelDevice::get_ebd_id(std::string& id) const {
+  if (ebd_impl) {
+    return ebd_impl->get_plugin_id(id);
+  }
+  return -ENOENT;
+}
+
 int KernelDevice::choose_fd(bool buffered, int write_hint) const
 {
 #if defined(F_SET_FILE_RW_HINT)
index f10458b4aff7717e39963bf0516a819aabda96ec..da44e37f7ad3773130379c6659d77567916ea6f6 100644 (file)
@@ -145,6 +145,7 @@ public:
   int get_devices(std::set<std::string> *ls) const override;
 
   int get_ebd_state(ExtBlkDevState &state) const override;
+  int get_ebd_id(std::string& id) const override;
 
   int read(uint64_t off, uint64_t len, ceph::buffer::list *pbl,
           IOContext *ioc,
index 219780fcd686bb4c3f503f6f3150907239110c8f..66121190ce654f6eba140b8532a42747609a3906 100644 (file)
@@ -99,6 +99,18 @@ namespace ceph {
      * @return 0 on success or a negative errno on error.
      */
     virtual int collect_metadata(const std::string& prefix, std::map<std::string,std::string> *pm) = 0;
+
+    /**
+     * Retrieve the identification string of the plugin.
+     * This can be used to verify that proper plugin is loaded.
+     * It is best if id is printable string.
+     *
+     * Return 0 on success or a negative errno on error.
+     *
+     * @param [out] id_str identification of current plugin
+     * @return 0 on success or a negative errno on error.
+     */
+    virtual int get_plugin_id(std::string& id_str) = 0;
   };
 
   typedef std::shared_ptr<ExtBlkDevInterface> ExtBlkDevInterfaceRef;
index 09865a27e036130f646abe98b32cb8d126e0427b..d8fb3e0894c585774711080d1d5fc9a4bdedf2f8 100644 (file)
@@ -47,6 +47,10 @@ public:
   virtual const std::string& get_devname() const {return name;}
   virtual int get_state(ceph::ExtBlkDevState& state);
   virtual int collect_metadata(const std::string& prefix, std::map<std::string,std::string> *pm);
+  int get_plugin_id(std::string& id_str) override {
+    id_str = "vdo";
+    return 0;
+  };
 };
 
 #endif