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: add force-create-pg back #16353

Merged
merged 1 commit into from Jul 18, 2017
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
15 changes: 8 additions & 7 deletions doc/man/8/ceph.rst
Expand Up @@ -39,7 +39,7 @@ Synopsis

| **ceph** **mon_status**

| **ceph** **osd** [ *blacklist* \| *blocked-by* \| *create* \| *new* \| *deep-scrub* \| *df* \| *down* \| *dump* \| *erasure-code-profile* \| *find* \| *getcrushmap* \| *getmap* \| *getmaxosd* \| *in* \| *lspools* \| *map* \| *metadata* \| *out* \| *pause* \| *perf* \| *pg-temp* \| *primary-affinity* \| *primary-temp* \| *repair* \| *reweight* \| *reweight-by-pg* \| *rm* \| *destroy* \| *purge* \| *scrub* \| *set* \| *setcrushmap* \| *setmaxosd* \| *stat* \| *tree* \| *unpause* \| *unset* ] ...
| **ceph** **osd** [ *blacklist* \| *blocked-by* \| *create* \| *new* \| *deep-scrub* \| *df* \| *down* \| *dump* \| *erasure-code-profile* \| *find* \| *getcrushmap* \| *getmap* \| *getmaxosd* \| *in* \| *lspools* \| *map* \| *metadata* \| *out* \| *pause* \| *perf* \| *pg-temp* \| *force-create-pg* \| *primary-affinity* \| *primary-temp* \| *repair* \| *reweight* \| *reweight-by-pg* \| *rm* \| *destroy* \| *purge* \| *scrub* \| *set* \| *setcrushmap* \| *setmaxosd* \| *stat* \| *tree* \| *unpause* \| *unset* ] ...

| **ceph** **osd** **crush** [ *add* \| *add-bucket* \| *create-or-move* \| *dump* \| *get-tunable* \| *link* \| *move* \| *remove* \| *rename-bucket* \| *reweight* \| *reweight-all* \| *reweight-subtree* \| *rm* \| *rule* \| *set* \| *set-tunable* \| *show-tunables* \| *tunables* \| *unlink* ] ...

Expand Down Expand Up @@ -826,6 +826,13 @@ Usage::

ceph osd pg-temp <pgid> {<id> [<id>...]}

Subcommand ``force-create-pg`` forces creation of pg <pgid>.

Usage::

ceph osd force-create-pg <pgid>


Subcommand ``pool`` is used for managing data pools. It uses some additional
subcommands.

Expand Down Expand Up @@ -1130,12 +1137,6 @@ Usage::
ceph pg dump_stuck {inactive|unclean|stale|undersized|degraded [inactive|unclean|stale|undersized|degraded...]}
{<int>}

Subcommand ``force_create_pg`` forces creation of pg <pgid>.

Usage::

ceph pg force_create_pg <pgid>

Subcommand ``getmap`` gets binary pg map to -o/stdout.

Usage::
Expand Down
2 changes: 1 addition & 1 deletion doc/rados/troubleshooting/troubleshooting-pg.rst
Expand Up @@ -76,7 +76,7 @@ that copy. For each placement group mapped to the first OSD (see
``ceph pg dump``), you can force the first OSD to notice the placement groups
it needs by running::

ceph pg force_create_pg <pgid>
ceph osd force-create-pg <pgid>


CRUSH Map Errors
Expand Down
4 changes: 4 additions & 0 deletions src/mon/MonCommands.h
Expand Up @@ -766,6 +766,10 @@ COMMAND("osd reweightn " \
"name=weights,type=CephString",
"reweight osds with {<id>: <weight>,...})",
"osd", "rw", "cli,rest")
COMMAND("osd force-create-pg " \
"name=pgid,type=CephPgid ",
"force creation of pg <pgid>",
"osd", "rw", "cli,rest")
COMMAND("osd pg-temp " \
"name=pgid,type=CephPgid " \
"name=id,type=CephOsdName,n=N,req=false", \
Expand Down
26 changes: 26 additions & 0 deletions src/mon/OSDMonitor.cc
Expand Up @@ -10438,6 +10438,32 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op,
new Monitor::C_Command(mon, op, 0, rs, rdata, get_last_committed() + 1));
return true;
}
} else if (prefix == "osd force-create-pg") {
pg_t pgid;
string pgidstr;
cmd_getval(g_ceph_context, cmdmap, "pgid", pgidstr);
if (!pgid.parse(pgidstr.c_str())) {
ss << "invalid pgid '" << pgidstr << "'";
err = -EINVAL;
goto reply;
}
bool creating_now;
{
std::lock_guard<std::mutex> l(creating_pgs_lock);
auto emplaced = creating_pgs.pgs.emplace(pgid,
make_pair(osdmap.get_epoch(),
ceph_clock_now()));
creating_now = emplaced.second;
}
if (creating_now) {
ss << "pg " << pgidstr << " now creating, ok";
err = 0;
goto update;
} else {
ss << "pg " << pgid << " already creating";
err = 0;
goto reply;
}
} else {
err = -EINVAL;
}
Expand Down
3 changes: 0 additions & 3 deletions src/test/pybind/test_ceph_argparse.py
Expand Up @@ -180,9 +180,6 @@ def test_debug(self):
assert_equal({}, validate_command(sigdict, ['pg', 'debug',
'invalid']))

def test_force_create_pg(self):
self.one_pgid('force_create_pg')


class TestAuth(TestArgparse):

Expand Down