From 0abee472e3db44cae4965cd897fae6d89e87a0a0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 15 Jul 2017 13:12:55 +0800 Subject: [PATCH] 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 --- doc/man/8/ceph.rst | 15 ++++++----- .../troubleshooting/troubleshooting-pg.rst | 2 +- src/mon/MonCommands.h | 4 +++ src/mon/OSDMonitor.cc | 26 +++++++++++++++++++ src/test/pybind/test_ceph_argparse.py | 3 --- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/doc/man/8/ceph.rst b/doc/man/8/ceph.rst index fa3d126fb11..339d5c3d192 100644 --- a/doc/man/8/ceph.rst +++ b/doc/man/8/ceph.rst @@ -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 { [...]} +Subcommand ``force-create-pg`` forces creation of pg . + +Usage:: + + ceph osd force-create-pg + + 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...]} {} -Subcommand ``force_create_pg`` forces creation of pg . - -Usage:: - - ceph pg force_create_pg - Subcommand ``getmap`` gets binary pg map to -o/stdout. Usage:: diff --git a/doc/rados/troubleshooting/troubleshooting-pg.rst b/doc/rados/troubleshooting/troubleshooting-pg.rst index e221344d171..0c99294e94c 100644 --- a/doc/rados/troubleshooting/troubleshooting-pg.rst +++ b/doc/rados/troubleshooting/troubleshooting-pg.rst @@ -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 + ceph osd force-create-pg CRUSH Map Errors diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index bd255fe5b2e..b2666f5757c 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -766,6 +766,10 @@ COMMAND("osd reweightn " \ "name=weights,type=CephString", "reweight osds with {: ,...})", "osd", "rw", "cli,rest") +COMMAND("osd force-create-pg " \ + "name=pgid,type=CephPgid ", + "force creation of pg ", + "osd", "rw", "cli,rest") COMMAND("osd pg-temp " \ "name=pgid,type=CephPgid " \ "name=id,type=CephOsdName,n=N,req=false", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4f05449bc11..e576bbd432e 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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 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; } diff --git a/src/test/pybind/test_ceph_argparse.py b/src/test/pybind/test_ceph_argparse.py index 7220c91c6a2..bc9f2d929fc 100755 --- a/src/test/pybind/test_ceph_argparse.py +++ b/src/test/pybind/test_ceph_argparse.py @@ -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): -- 2.39.5