});
}
- const std::map<fs_cluster_id_t, std::shared_ptr<Filesystem> > &get_filesystems() const
- {
- return filesystems;
- }
- bool any_filesystems() const {return !filesystems.empty(); }
+ size_t filesystem_count() const {return filesystems.size();}
bool filesystem_exists(fs_cluster_id_t fscid) const
{return filesystems.count(fscid) > 0;}
epoch_t get_epoch() const { return epoch; }
void inc_epoch() { epoch++; }
- std::shared_ptr<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const
- {
- return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));
- }
+ std::shared_ptr<const Filesystem> get_filesystem(fs_cluster_id_t fscid) const {return std::const_pointer_cast<const Filesystem>(filesystems.at(fscid));}
+ std::shared_ptr<const Filesystem> get_filesystem(void) const {return std::const_pointer_cast<const Filesystem>(filesystems.begin()->second);}
int parse_filesystem(
std::string const &ns_str,
}
}
- if (pending_fsmap.any_filesystems()
+ if (pending_fsmap.filesystem_count() > 0
&& !pending_fsmap.get_enable_multiple()) {
ss << "Creation of multiple filesystems is disabled. To enable "
"this experimental feature, use 'ceph fs flag set enable_multiple "
// that doesn't correspond to an existing filesystem, especially
// if we loaded from a version with a bug (#17466)
if (info.standby_for_fscid != FS_CLUSTER_ID_NONE
- && pending_fsmap.get_filesystems().count(
- info.standby_for_fscid) == 0) {
+ && !pending_fsmap.filesystem_exists(info.standby_for_fscid)) {
derr << "gid " << gid << " has invalid standby_for_fscid "
<< info.standby_for_fscid << dendl;
continue;
ss << " monmap " << *monmap << "\n";
ss << " election epoch " << get_epoch()
<< ", quorum " << get_quorum() << " " << get_quorum_names() << "\n";
- if (mdsmon()->fsmap.any_filesystems()) {
+ if (mdsmon()->fsmap.filesystem_count() > 0) {
ss << " fsmap " << mdsmon()->fsmap << "\n";
}
// If caller didn't specify a namespace, try to pick
// one if only one exists
if (fscid == FS_CLUSTER_ID_NONE) {
- if (fsmap->get_filesystems().size() == 1) {
- fscid = fsmap->get_filesystems().begin()->first;
+ if (fsmap->filesystem_count() == 1) {
+ fscid = fsmap->get_filesystem()->fscid;
} else {
std::cerr << "Specify a filesystem with --filesystem" << std::endl;
return -EINVAL;
if (colon_pos == std::string::npos) {
// An unqualified rank. Only valid if there is only one
// namespace.
- if (fsmap.get_filesystems().size() == 1) {
- fscid = fsmap.get_filesystems().begin()->first;
+ if (fsmap.filesystem_count() == 1) {
+ fscid = fsmap.get_filesystem()->fscid;
return parse_rank(fsmap, str);
} else {
return -EINVAL;