From: Patrick Donnelly Date: Fri, 17 Feb 2017 02:26:12 +0000 (-0500) Subject: mon: detect existing fs and duplicate name earlier X-Git-Tag: v12.0.1~311^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=848fd1f4af3c98e14dfb407f64a304c4a4a5e960;p=ceph.git mon: detect existing fs and duplicate name earlier Detecting creation of an equivalent fs was made impossible by 052c3d3f681017d56b5b0ee5cf6f65bffc952a4c, as an existing file system will obviously have objects in its pool. This commit moves the pool with objects check later and uses a more helpful errno (EEXIST) for the case where a fs with the same name already exists (but uses different pools). Fixes: http://tracker.ceph.com/issues/18964 Signed-off-by: Patrick Donnelly --- diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 4dbce27162c..e834678f6eb 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1582,27 +1582,17 @@ int MDSMonitor::management_command( return -ENOENT; } - string force; - cmd_getval(g_ceph_context,cmdmap, "force", force); - int64_t metadata_num_objects = mon->pgmon()->pg_map.pg_pool_sum[metadata].stats.sum.num_objects; - if (force != "--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(g_ceph_context, cmdmap, "data", data_name); int64_t data = mon->osdmon()->osdmap.lookup_pg_pool_name(data_name); if (data < 0) { ss << "pool '" << data_name << "' does not exist"; return -ENOENT; - } - if (data == 0) { + } else if (data == 0) { ss << "pool '" << data_name << "' has id 0, which CephFS does not allow. Use another pool or recreate it to get a non-zero pool id."; return -EINVAL; } - + string fs_name; cmd_getval(g_ceph_context, cmdmap, "fs_name", fs_name); if (fs_name.empty()) { @@ -1610,9 +1600,7 @@ int MDSMonitor::management_command( // commmands that refer to FS by name in future. ss << "Filesystem name may not be empty"; return -EINVAL; - } - - if (pending_fsmap.get_filesystem(fs_name)) { + } else if (pending_fsmap.get_filesystem(fs_name)) { auto fs = pending_fsmap.get_filesystem(fs_name); if (*(fs->mds_map.data_pools.begin()) == data && fs->mds_map.metadata_pool == metadata) { @@ -1621,10 +1609,19 @@ int MDSMonitor::management_command( return 0; } else { ss << "filesystem already exists with name '" << fs_name << "'"; - return -EINVAL; + return -EEXIST; } } + string force; + cmd_getval(g_ceph_context,cmdmap, "force", force); + int64_t metadata_num_objects = mon->pgmon()->pg_map.pg_pool_sum[metadata].stats.sum.num_objects; + if (force != "--force" && metadata_num_objects > 0) { + ss << "pool '" << metadata_name + << "' already contains some objects. Use an empty pool instead."; + return -EINVAL; + } + if (pending_fsmap.filesystem_count() > 0 && !pending_fsmap.get_enable_multiple()) { ss << "Creation of multiple filesystems is disabled. To enable "