MCPcopy Create free account
hub / github.com/ceph/ceph / detect_device

Function detect_device

src/extblkdev/ExtBlkDevPlugin.cc:237–272  ·  view source on GitHub ↗

scan extblkdev plugins for support of this device

Source from the content-addressed store, hash-verified

235
236 // scan extblkdev plugins for support of this device
237 int detect_device(CephContext *cct,
238 const std::string &logdevname,
239 ExtBlkDevInterfaceRef& ebd_impl)
240 {
241 int rc = -ENOENT;
242 std::string plg_name;
243 auto registry = cct->get_plugin_registry();
244 std::lock_guard l(registry->lock);
245 auto ptype = registry->plugins.find("extblkdev");
246 if (ptype == registry->plugins.end()) {
247 return -ENOENT;
248 }
249
250 for (auto& it : ptype->second) {
251
252 dout(10) << __func__ << " Trying to detect block device " << logdevname
253 << " using plugin " << it.first << dendl;
254 auto ebdplugin = dynamic_cast<ExtBlkDevPlugin*>(it.second);
255 if (ebdplugin == nullptr) {
256 derr << __func__ << " Is not an extblkdev plugin: " << it.first << dendl;
257 return -ENOENT;
258 }
259 rc = ebdplugin->factory(logdevname, ebd_impl);
260 if (rc == 0) {
261 plg_name = it.first;
262 break;
263 }
264 }
265 if (rc == 0) {
266 dout(1) << __func__ << " using plugin " << plg_name << ", volume " << ebd_impl->get_devname()
267 << " maps to " << logdevname << dendl;
268 } else {
269 dout(10) << __func__ << " no plugin volume maps to " << logdevname << dendl;
270 }
271 return rc;
272 }
273
274 // release device object
275 int release_device(ExtBlkDevInterfaceRef& ebd_impl)

Callers 1

detect_ebdMethod · 0.85

Calls 5

get_plugin_registryMethod · 0.80
findMethod · 0.45
endMethod · 0.45
factoryMethod · 0.45
get_devnameMethod · 0.45

Tested by

no test coverage detected