]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix idempotent FS creation 23529/head
authorJohn Spray <john.spray@redhat.com>
Thu, 9 Aug 2018 11:03:51 +0000 (07:03 -0400)
committerJohn Spray <john.spray@redhat.com>
Fri, 10 Aug 2018 10:25:05 +0000 (06:25 -0400)
In the case that our creation is a no-op, we should tolerate
objects in the metadata pool -- since we're not performing
any action, we can't do harm.

This case comes up if you have MDS daemons starting immediately
on filesystem creation: running the `fs new` command twice will fail
the second time because of the objects the MDS created.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mon/FSCommands.cc

index 6c0bab874b00c82a64b7bc7b041e1985ee50b948..ca1e227b003cb706ca635b427252e7ba6291ba70 100644 (file)
@@ -105,19 +105,6 @@ class FsNewHandler : public FileSystemCommandHandler
       return -ENOENT;
     }
 
-    string force_str;
-    cmd_getval_throws(g_ceph_context,cmdmap, "force", force_str);
-    bool force = (force_str == "--force");
-    const pool_stat_t *stat = mon->mgrstatmon()->get_pool_stat(metadata);
-    if (stat) {
-      int64_t metadata_num_objects = stat->stats.sum.num_objects;
-      if (!force && metadata_num_objects > 0) {
-       ss << "pool '" << metadata_name
-          << "' already contains some objects. Use an empty pool instead.";
-       return -EINVAL;
-      }
-    }
-
     string data_name;
     cmd_getval_throws(g_ceph_context, cmdmap, "data", data_name);
     int64_t data = mon->osdmon()->osdmap.lookup_pg_pool_name(data_name);
@@ -152,6 +139,19 @@ class FsNewHandler : public FileSystemCommandHandler
       }
     }
 
+    string force_str;
+    cmd_getval_throws(g_ceph_context,cmdmap, "force", force_str);
+    bool force = (force_str == "--force");
+    const pool_stat_t *stat = mon->mgrstatmon()->get_pool_stat(metadata);
+    if (stat) {
+      int64_t metadata_num_objects = stat->stats.sum.num_objects;
+      if (!force && metadata_num_objects > 0) {
+       ss << "pool '" << metadata_name
+          << "' already contains some objects. Use an empty pool instead.";
+       return -EINVAL;
+      }
+    }
+
     if (fsmap.filesystem_count() > 0
         && !fsmap.get_enable_multiple()) {
       ss << "Creation of multiple filesystems is disabled.  To enable "