Skip to content

Commit

Permalink
mon/OSDMonitor: disallow pg_num changes until after pool is created
Browse files Browse the repository at this point in the history
The pg create handling OSD code does not handle races between a mon create
message and a split message.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Apr 3, 2018
1 parent e76d747 commit 5961672
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mon/CreatingPGs.h
Expand Up @@ -47,6 +47,17 @@ struct creating_pgs_t {
/// pools that exist in the osdmap for which at least one pg has been created
std::set<int64_t> created_pools;

bool is_creating_pool(int64_t poolid) {
if (queue.count(poolid)) {
return true;
}
for (auto& i : pgs) {
if ((int64_t)i.first.pool() == poolid) {
return true;
}
}
return false;
}
bool create_pool(int64_t poolid, uint32_t pg_num,
epoch_t created, utime_t modified) {
if (created_pools.count(poolid) == 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/mon/OSDMonitor.cc
Expand Up @@ -6065,6 +6065,10 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
<< " (you may adjust 'mon max pool pg num' for higher values)";
return -ERANGE;
}
if (creating_pgs.is_creating_pool(pool)) {
ss << "still creating initial PGs; cannot update pg_num yet";
return -EBUSY;
}
int r = check_pg_num(pool, n, p.get_size(), &ss);
if (r) {
return r;
Expand Down

0 comments on commit 5961672

Please sign in to comment.