int cluster_stat(cluster_stat_t& result);
int cluster_fsid(std::string *fsid);
+ /// get/wait for the most recent osdmap
+ int wait_for_latest_osdmap();
+
/*
* pool aio
*
}
}
+int librados::RadosClient::wait_for_latest_osdmap()
+{
+ Mutex mylock("RadosClient::wait_for_latest_osdmap");
+ Cond cond;
+ bool done;
+
+ lock.Lock();
+ objecter->wait_for_latest_osdmap(new C_SafeCond(&mylock, &cond, &done));
+ lock.Unlock();
+
+ mylock.Lock();
+ while (!done)
+ cond.Wait(mylock);
+ mylock.Unlock();
+
+ return 0;
+}
+
int librados::RadosClient::pool_list(std::list<std::string>& v)
{
Mutex::Locker l(lock);
uint64_t get_instance_id();
+ int wait_for_latest_osdmap();
+
int create_ioctx(const char *name, IoCtxImpl **io);
int get_fsid(std::string *s);
return client->get_fsid(fsid);
}
+int librados::Rados::wait_for_latest_osdmap()
+{
+ return client->wait_for_latest_osdmap();
+}
+
librados::PoolAsyncCompletion *librados::Rados::pool_async_create_completion()
{
PoolAsyncCompletionImpl *c = new PoolAsyncCompletionImpl;
lock.Unlock();
}
+struct C_Objecter_GetVersion : public Context {
+ Objecter *objecter;
+ uint64_t oldest, newest;
+ Context *fin;
+ C_Objecter_GetVersion(Objecter *o, Context *c)
+ : objecter(o), oldest(0), newest(0), fin(c) {}
+ void finish(int r) {
+ if (r >= 0)
+ objecter->_get_latest_version(oldest, newest, fin);
+ else if (r == -EAGAIN) { // try again as instructed
+ objecter->wait_for_latest_osdmap(fin);
+ } else {
+ // it doesn't return any other error codes!
+ assert(0);
+ }
+ }
+};
+
+void Objecter::wait_for_latest_osdmap(Context *fin)
+{
+ ldout(cct, 10) << __func__ << dendl;
+ C_Objecter_GetVersion *c = new C_Objecter_GetVersion(this, fin);
+ monc->get_version("osdmap", &c->newest, &c->oldest, c);
+}
+
+void Objecter::_get_latest_version(epoch_t oldest, epoch_t newest, Context *fin)
+{
+ if (osdmap->get_epoch() >= newest) {
+ ldout(cct, 10) << __func__ << " latest " << newest << ", have it" << dendl;
+ if (fin)
+ fin->complete(0);
+ return;
+ }
+
+ ldout(cct, 10) << __func__ << " latest " << newest << ", waiting" << dendl;
+ wait_for_new_map(fin, newest, 0);
+}
void Objecter::maybe_request_map()
{
void set_client_incarnation(int inc) { client_inc = inc; }
void wait_for_new_map(Context *c, epoch_t epoch, int err=0);
+ void wait_for_latest_osdmap(Context *fin);
+ void _get_latest_version(epoch_t oldest, epoch_t neweset, Context *fin);
/** Get the current set of global op flags */
int get_global_op_flags() { return global_op_flags; }
ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}
+TEST(LibRadosMisc, WaitOSDMapPP) {
+ Rados cluster;
+ std::string pool_name = get_temp_pool_name();
+ ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+
+ ASSERT_EQ(0, cluster.wait_for_latest_osdmap());
+
+ ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}
+
static std::string read_key_from_tmap(IoCtx& ioctx, const std::string &obj,
const std::string &key)
{