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

Function preload

src/extblkdev/ExtBlkDevPlugin.cc:185–233  ·  view source on GitHub ↗

preload set of extblkdev plugins defined in config

Source from the content-addressed store, hash-verified

183
184 // preload set of extblkdev plugins defined in config
185 int preload(CephContext *cct)
186 {
187 static bool preload_executed = false;
188 static int preload_result = -1;
189 if (preload_executed) {
190 auto registry = cct->get_plugin_registry();
191 std::lock_guard l(registry->lock);
192 dout(10) << "plugins preload done, extblkdev plugins ="
193 << registry->plugins["extblkdev"].size()
194 << " previous_result = " << preload_result << dendl;
195 return preload_result;
196 }
197 preload_executed = true;
198 const auto& conf = cct->_conf;
199 string plugins = conf.get_val<std::string>("osd_extblkdev_plugins");
200 dout(10) << "starting preload of extblkdev plugins: " << plugins << dendl;
201
202 list<string> plugins_list;
203 get_str_list(plugins, plugins_list);
204
205 auto registry = cct->get_plugin_registry();
206 {
207 std::lock_guard l(registry->lock);
208 for (auto& plg : plugins_list) {
209 dout(10) << "starting load of extblkdev plugin: " << plg << dendl;
210 int rc = registry->load("extblkdev", std::string("ebd_") + plg);
211 if (rc) {
212 derr << __func__ << " failed preloading extblkdev plugin: " << plg << dendl;
213 preload_result = rc;
214 return rc;
215 } else {
216 dout(10) << "successful load of extblkdev plugin: " << plg << dendl;
217 }
218 }
219 }
220#ifdef __linux__
221 // if we are still running as root, we do not need to trim capabilities
222 // as we are intended to use the privileges
223 if (geteuid() == 0) {
224 preload_result = 0;
225 return 0;
226 }
227 preload_result = limit_caps(cct);
228 return preload_result;
229#else
230 preload_result = 0;
231 return 0;
232#endif
233 }
234
235
236 // scan extblkdev plugins for support of this device

Callers 1

_open_bdevMethod · 0.85

Calls 6

geteuidFunction · 0.85
limit_capsFunction · 0.85
get_plugin_registryMethod · 0.80
get_str_listFunction · 0.50
sizeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected