Skip to content

Commit

Permalink
librados: check latest osdmap for pool_get_name
Browse files Browse the repository at this point in the history
Signed-off-by: Li Wang <[email protected]>
  • Loading branch information
dragonylffly committed May 7, 2018
1 parent 5c4f8c7 commit 95182a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/librados/RadosClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ int librados::RadosClient::pool_get_auid(uint64_t pool_id,
return r;
}

int librados::RadosClient::pool_get_name(uint64_t pool_id, std::string *s)
int librados::RadosClient::pool_get_name(uint64_t pool_id, std::string *s, bool wait_latest_map)
{
int r = wait_for_osdmap();
if (r < 0)
return r;
retry:
objecter->with_osdmap([&](const OSDMap& o) {
if (!o.have_pg_pool(pool_id)) {
r = -ENOENT;
Expand All @@ -201,6 +202,14 @@ int librados::RadosClient::pool_get_name(uint64_t pool_id, std::string *s)
*s = o.get_pool_name(pool_id);
}
});
if (r == -ENOENT && wait_latest_map) {
r = wait_for_latest_osdmap();
if (r < 0)
return r;
wait_latest_map = false;
goto retry;
}

return r;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librados/RadosClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class librados::RadosClient : public Dispatcher
uint64_t pool_required_alignment(int64_t pool_id);
int pool_required_alignment2(int64_t pool_id, uint64_t *alignment);
int pool_get_auid(uint64_t pool_id, unsigned long long *auid);
int pool_get_name(uint64_t pool_id, std::string *auid);
int pool_get_name(uint64_t pool_id, std::string *auid, bool wait_latest_map = false);

int pool_list(std::list<std::pair<int64_t, string> >& ls);
int get_pool_stats(std::list<string>& ls, map<string,::pool_stat_t>& result);
Expand Down

0 comments on commit 95182a8

Please sign in to comment.