]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: add force-create-pg back
authorKefu Chai <kchai@redhat.com>
Sat, 15 Jul 2017 05:12:55 +0000 (13:12 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 17 Jul 2017 13:18:06 +0000 (21:18 +0800)
and now it's "ceph osd force-create-pg'

Fixes: http://tracker.ceph.com/issues/20605
Signed-off-by: Kefu Chai <kchai@redhat.com>
doc/man/8/ceph.rst
doc/rados/troubleshooting/troubleshooting-pg.rst
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/test/pybind/test_ceph_argparse.py

index fa3d126fb11bd96d35840e386f6f5fe28bd3e576..339d5c3d192992d5fa59c0d93a4d47b10c38e1f1 100644 (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::
index e221344d171a51ee1abcb4d328bc2ec4f1eb2bb6..0c99294e94c359a4fce7ae3dc163c6931c1800e0 100644 (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
index bd255fe5b2e5470774f7876893f801ee825f4a69..b2666f5757c203d3d6f93e3b15d5e227034c48de 100644 (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", \
index 4f05449bc11b7ab6d0b23c6ac30460f2fbb06e85..e576bbd432ec885c10ebb79f9a8a5fb77b78d53a 100644 (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;
   }
index 7220c91c6a2dca7365cbe55ca8c9e7210de08846..bc9f2d929fc9f5e77232edc604b2b01f3f32934a 100755 (executable)
@@ -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):