Merge PR #23529 into master

* refs/pull/23529/head:
	mon: fix idempotent FS creation

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: João Eduardo Luís <joao@suse.de>
This commit is contained in:
Patrick Donnelly 2018-08-20 15:11:23 -07:00
commit dbaa32b412
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB

View 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 "