Skip to content

Commit

Permalink
Merge pull request #20267 from liewegas/wip-22847
Browse files Browse the repository at this point in the history
mon/OSDMonitor: filter out pgs that shouldn't exist from force-create-pg

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Feb 6, 2018
2 parents 12e3cbd + cd013ed commit 797b7c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
29 changes: 27 additions & 2 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ void OSDMonitor::create_pending()
}

creating_pgs_t
OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc)
OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc,
const OSDMap& nextmap)
{
dout(10) << __func__ << dendl;
creating_pgs_t pending_creatings;
Expand Down Expand Up @@ -687,6 +688,20 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc)
pending_creatings.last_scan_epoch = osdmap.get_epoch();
}

// filter out any pgs that shouldn't exist.
{
auto i = pending_creatings.pgs.begin();
while (i != pending_creatings.pgs.end()) {
if (!nextmap.pg_exists(i->first)) {
dout(10) << __func__ << " removing pg " << i->first
<< " which should not exist" << dendl;
i = pending_creatings.pgs.erase(i);
} else {
++i;
}
}
}

// process queue
unsigned max = std::max<int64_t>(1, g_conf->mon_osd_max_creating_pgs);
const auto total = pending_creatings.pgs.size();
Expand Down Expand Up @@ -1288,7 +1303,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
pending_metadata_rm.clear();

// and pg creating, also!
auto pending_creatings = update_pending_pgs(pending_inc);
auto pending_creatings = update_pending_pgs(pending_inc, tmp);
bufferlist creatings_bl;
encode(pending_creatings, creatings_bl);
t->put(OSD_PG_CREATING_PREFIX, "creating", creatings_bl);
Expand Down Expand Up @@ -3282,6 +3297,11 @@ void OSDMonitor::update_creating_pgs()
for (const auto& pg : creating_pgs.pgs) {
int acting_primary = -1;
auto pgid = pg.first;
if (!osdmap.pg_exists(pgid)) {
dout(20) << __func__ << " ignoring " << pgid << " which should not exist"
<< dendl;
continue;
}
auto mapped = pg.second.first;
dout(20) << __func__ << " looking up " << pgid << "@" << mapped << dendl;
mapping.get(pgid, nullptr, nullptr, nullptr, &acting_primary);
Expand Down Expand Up @@ -10927,6 +10947,11 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
err = -EINVAL;
goto reply;
}
if (!osdmap.pg_exists(pgid)) {
ss << "pg " << pgid << " should not exist";
err = -ENOENT;
goto reply;
}
bool creating_now;
{
std::lock_guard<std::mutex> l(creating_pgs_lock);
Expand Down
3 changes: 2 additions & 1 deletion src/mon/OSDMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ class OSDMonitor : public PaxosService {
creating_pgs_t creating_pgs;
mutable std::mutex creating_pgs_lock;

creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc);
creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc,
const OSDMap& nextmap);
void trim_creating_pgs(creating_pgs_t *creating_pgs,
const ceph::unordered_map<pg_t,pg_stat_t>& pgm);
unsigned scan_for_creating_pgs(
Expand Down

0 comments on commit 797b7c0

Please sign in to comment.