From 38319f8300ebf4a48b6910790467bad96d29941e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 23 Feb 2018 08:52:42 -0600 Subject: [PATCH] mon/OSDMonitor: disallow pg_num changes until after pool is created The pg create handling OSD code does not handle races between a mon create message and a split message. Signed-off-by: Sage Weil --- src/mon/CreatingPGs.h | 11 +++++++++++ src/mon/OSDMonitor.cc | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/mon/CreatingPGs.h b/src/mon/CreatingPGs.h index fae7e6f2ce5ab..d0c695d9f604f 100644 --- a/src/mon/CreatingPGs.h +++ b/src/mon/CreatingPGs.h @@ -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 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) { diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a76b4870a24ab..3e7eceebc8859 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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; -- 2.39.5