Ensure we have a map so we don't simply complain that a pool doesn't
exists. Only take the lock and wait if we fail to lookup the pool,
though, so we avoid contending the lock in the general case.
Signed-off-by: Sage Weil <sage@redhat.com>
int librados::RadosClient::create_ioctx(const char *name, IoCtxImpl **io)
{
int64_t poolid = lookup_pool(name);
- if (poolid < 0)
- return (int)poolid;
+ if (poolid < 0) {
+ // hmm, first make sure we have *a* map
+ {
+ Mutex::Locker l(lock);
+ int r = wait_for_osdmap();
+ if (r < 0)
+ return r;
+ }
+
+ poolid = lookup_pool(name);
+ if (poolid < 0) {
+ // make sure we have the *latest* map
+ int r = wait_for_latest_osdmap();
+ if (r < 0)
+ return r;
+
+ poolid = lookup_pool(name);
+ if (poolid < 0) {
+ return (int)poolid;
+ }
+ }
+ }
*io = new librados::IoCtxImpl(this, objecter, &lock, poolid, name,
CEPH_NOSNAP);