From: Adam Kupczyk Date: Thu, 22 Jan 2026 13:55:51 +0000 (+0000) Subject: extblkdev: Expand interface, add plugin id retrieval X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4a002a06492e98c1d4468e7d202b249c5d7ea1a;p=ceph.git extblkdev: Expand interface, add plugin id retrieval 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 --- diff --git a/src/blk/BlockDevice.h b/src/blk/BlockDevice.h index 43c37c9b2802..ee7bccb6e13f 100644 --- a/src/blk/BlockDevice.h +++ b/src/blk/BlockDevice.h @@ -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 *pm) const = 0; diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 0931281d33aa..444cf6b47dbc 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -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) diff --git a/src/blk/kernel/KernelDevice.h b/src/blk/kernel/KernelDevice.h index b906edc80587..d95bffdbe7bd 100644 --- a/src/blk/kernel/KernelDevice.h +++ b/src/blk/kernel/KernelDevice.h @@ -148,6 +148,7 @@ public: int get_devices(std::set *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, diff --git a/src/extblkdev/ExtBlkDevInterface.h b/src/extblkdev/ExtBlkDevInterface.h index 9bc02b975d22..b9e553c8c1f1 100644 --- a/src/extblkdev/ExtBlkDevInterface.h +++ b/src/extblkdev/ExtBlkDevInterface.h @@ -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 *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 ExtBlkDevInterfaceRef; diff --git a/src/extblkdev/vdo/ExtBlkDevVdo.h b/src/extblkdev/vdo/ExtBlkDevVdo.h index 3da622c500a9..90763f88c9b7 100644 --- a/src/extblkdev/vdo/ExtBlkDevVdo.h +++ b/src/extblkdev/vdo/ExtBlkDevVdo.h @@ -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 *pm); + int get_plugin_id(std::string& id_str) override { + id_str = "vdo"; + return 0; + }; }; #endif