Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mon/OSDMonitor: filter out pgs that shouldn't exist from force-create-pg #20267

Merged
merged 2 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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