]> 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>
Wed, 25 Mar 2026 09:35:04 +0000 (09:35 +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>
src/blk/BlockDevice.h
src/blk/kernel/KernelDevice.cc
src/blk/kernel/KernelDevice.h
src/extblkdev/ExtBlkDevInterface.h
src/extblkdev/vdo/ExtBlkDevVdo.h

index 43c37c9b2802b779f7b17d9f474316059b12f137..ee7bccb6e13f9c6fee11e1256febdf695c6922d3 100644 (file)
@@ -249,6 +249,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 0931281d33aa755a9812db0fcb599d78f858b6ed..444cf6b47dbcb28ac2a21a97d68136eb00deb031 100644 (file)
@@ -477,6 +477,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 b906edc805870a317d65e34282f5d12a0b8ef4c1..d95bffdbe7bdb19dbc7d95e05fc03b128b1317ad 100644 (file)
@@ -148,6 +148,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 9bc02b975d22d638b82aab0634d200aa4d7ccdaa..b9e553c8c1f1cafc2723c8e30f7faaa4dfbfb5ec 100644 (file)
@@ -100,6 +100,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 3da622c500a9e195ca31eb1b288fffeb410fa7e6..90763f88c9b7a6c1ff7d35447303745a57b1cd9b 100644 (file)
@@ -48,6 +48,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