From: John Spray Date: Thu, 9 Aug 2018 11:03:51 +0000 (-0400) Subject: mon: fix idempotent FS creation X-Git-Tag: v14.0.1~548^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9d4d2ccc1a46346b10d5ee820a6bd992ed56fe23;p=ceph.git mon: fix idempotent FS creation 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 --- diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index 6c0bab874b00c..ca1e227b003cb 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -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 "