void unset_osdmap_full_try();
int application_enable(const std::string& app_name, bool force);
+ int application_enable_async(const std::string& app_name,
+ bool force, PoolAsyncCompletion *c);
int application_list(std::set<std::string> *app_names);
int application_metadata_get(const std::string& app_name,
const std::string &key,
int librados::IoCtxImpl::application_enable(const std::string& app_name,
bool force)
+{
+ auto c = new PoolAsyncCompletionImpl();
+ application_enable_async(app_name, force, c);
+
+ int r = c->wait();
+ assert(r == 0);
+
+ r = c->get_return_value();
+ c->release();
+ if (r < 0) {
+ return r;
+ }
+
+ return client->wait_for_latest_osdmap();
+}
+
+void librados::IoCtxImpl::application_enable_async(const std::string& app_name,
+ bool force,
+ PoolAsyncCompletionImpl *c)
{
// pre-Luminous clusters will return -EINVAL and application won't be
// preserved until Luminous is configured as minimim version.
if (!client->get_required_monitor_features().contains_all(
ceph::features::mon::FEATURE_LUMINOUS)) {
- return -EOPNOTSUPP;
+ client->finisher.queue(new C_PoolAsync_Safe(c), -EOPNOTSUPP);
+ return;
}
std::stringstream cmd;
std::vector<std::string> cmds;
cmds.push_back(cmd.str());
bufferlist inbl;
- int r = client->mon_command(cmds, inbl, nullptr, nullptr);
- if (r < 0) {
- return r;
- }
-
- // ensure we have the latest osd map epoch before proceeding
- return client->wait_for_latest_osdmap();
+ client->mon_command_async(cmds, inbl, nullptr, nullptr,
+ new C_PoolAsync_Safe(c));
}
int librados::IoCtxImpl::application_list(std::set<std::string> *app_names)
int cache_unpin(const object_t& oid);
int application_enable(const std::string& app_name, bool force);
+ void application_enable_async(const std::string& app_name, bool force,
+ PoolAsyncCompletionImpl *c);
int application_list(std::set<std::string> *app_names);
int application_metadata_get(const std::string& app_name,
const std::string &key,
const bufferlist &inbl,
bufferlist *outbl, string *outs)
{
- Mutex mylock("RadosClient::mon_command::mylock");
- Cond cond;
- bool done;
- int rval;
+ C_SaferCond ctx;
+ mon_command_async(cmd, inbl, outbl, outs, &ctx);
+ return ctx.wait();
+}
+
+void librados::RadosClient::mon_command_async(const vector<string>& cmd,
+ const bufferlist &inbl,
+ bufferlist *outbl, string *outs,
+ Context *on_finish)
+{
lock.Lock();
- monclient.start_mon_command(cmd, inbl, outbl, outs,
- new C_SafeCond(&mylock, &cond, &done, &rval));
+ monclient.start_mon_command(cmd, inbl, outbl, outs, on_finish);
lock.Unlock();
- mylock.Lock();
- while (!done)
- cond.Wait(mylock);
- mylock.Unlock();
- return rval;
}
-
int librados::RadosClient::mgr_command(const vector<string>& cmd,
const bufferlist &inbl,
bufferlist *outbl, string *outs)
#include "IoCtxImpl.h"
struct AuthAuthorizer;
+struct Context;
class CephContext;
struct Connection;
struct md_config_t;
int mon_command(const vector<string>& cmd, const bufferlist &inbl,
bufferlist *outbl, string *outs);
+ void mon_command_async(const vector<string>& cmd, const bufferlist &inbl,
+ bufferlist *outbl, string *outs, Context *on_finish);
int mon_command(int rank,
const vector<string>& cmd, const bufferlist &inbl,
bufferlist *outbl, string *outs);
return io_ctx_impl->application_enable(app_name, force);
}
+int librados::IoCtx::application_enable_async(const std::string& app_name,
+ bool force,
+ PoolAsyncCompletion *c)
+{
+ io_ctx_impl->application_enable_async(app_name, force, c->pc);
+ return 0;
+}
+
int librados::IoCtx::application_list(std::set<std::string> *app_names)
{
return io_ctx_impl->application_list(app_names);