From: John Spray Date: Wed, 17 Feb 2016 15:19:10 +0000 (+0000) Subject: mds: introduce fs_cluster_id_t type X-Git-Tag: v10.1.0~144^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ce37bbfe72473a57873d73f90a73e115f15d7c1a;p=ceph.git mds: introduce fs_cluster_id_t type Unique identifier for a filesystem within the ceph cluster. Abbreviated to `fscid`, deliberately chosen to not conflict with legacy "fsid" identifiers. Additionally add mds_role_t type which is a more general form of rank: ranks are now only unique within a particular fscid. Roles are a fscid plus a rank. Signed-off-by: John Spray --- diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 5deec00cc2839..066b26b3536fa 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -1099,3 +1099,9 @@ void MDSCacheObject::dump_states(Formatter *f) const } +ostream& operator<<(ostream &out, const mds_role_t &role) +{ + out << role.fscid << ":" << role.rank; + return out; +} + diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index c42d621100294..e789856b36d7c 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -76,10 +76,46 @@ typedef int32_t mds_rank_t; +typedef int32_t fs_cluster_id_t; + + + BOOST_STRONG_TYPEDEF(uint64_t, mds_gid_t) extern const mds_gid_t MDS_GID_NONE; +constexpr fs_cluster_id_t FS_CLUSTER_ID_NONE = {-1}; +// The namespace ID of the anonymous default filesystem from legacy systems +constexpr fs_cluster_id_t FS_CLUSTER_ID_ANONYMOUS = {0}; extern const mds_rank_t MDS_RANK_NONE; +class mds_role_t +{ + public: + mds_rank_t rank; + fs_cluster_id_t fscid; + mds_role_t(fs_cluster_id_t fscid_, mds_rank_t rank_) + : rank(rank_), fscid(fscid_) + {} + mds_role_t() + : rank(MDS_RANK_NONE), fscid(FS_CLUSTER_ID_NONE) + {} + bool operator<(mds_role_t const &rhs) const + { + if (fscid < rhs.fscid) { + return true; + } else if (fscid == rhs.fscid) { + return rank < rhs.rank; + } else { + return false; + } + } + + bool is_none() const + { + return (rank == MDS_RANK_NONE); + } +}; +std::ostream& operator<<(std::ostream &out, const mds_role_t &role); + extern long g_num_ino, g_num_dir, g_num_dn, g_num_cap; extern long g_num_inoa, g_num_dira, g_num_dna, g_num_capa;