mon: add force-create-pg back

and now it's "ceph osd force-create-pg'

Fixes: http://tracker.ceph.com/issues/20605
Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-07-15 13:12:55 +08:00
parent 7aabdc01eb
commit 0abee472e3
5 changed files with 39 additions and 11 deletions

View File

@ -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* ] ...
@ -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.
@ -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::

View File

@ -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

View File

@ -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", \

View File

@ -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;
}

View File

@ -180,9 +180,6 @@ class TestPG(TestArgparse):
assert_equal({}, validate_command(sigdict, ['pg', 'debug',
'invalid']))
def test_force_create_pg(self):
self.one_pgid('force_create_pg')
class TestAuth(TestArgparse):