From b8ffe5c2dcfc107974b04e394b27011f668a81e9 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 16 Jan 2015 00:02:00 +0000 Subject: [PATCH] mds: give MDSTables a `rank` attribute ...so that they (like the new SessionMapStore) can be used outside of a live MDS in tool code. Signed-off-by: John Spray --- src/mds/InoTable.cc | 4 ++-- src/mds/MDS.cc | 4 ++++ src/mds/MDSTable.cc | 2 +- src/mds/MDSTable.h | 8 +++++++- src/mds/MDSTableServer.cc | 2 +- src/mds/SnapServer.cc | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/mds/InoTable.cc b/src/mds/InoTable.cc index 518569511244b..d8363e60ea6a6 100644 --- a/src/mds/InoTable.cc +++ b/src/mds/InoTable.cc @@ -21,14 +21,14 @@ #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << mds->get_nodeid() << "." << table_name << ": " +#define dout_prefix *_dout << "mds." << rank << "." << table_name << ": " void InoTable::reset_state() { // use generic range. FIXME THIS IS CRAP free.clear(); //#ifdef __LP64__ - uint64_t start = (uint64_t)(mds->get_nodeid()+1) << 40; + uint64_t start = (uint64_t)(rank+1) << 40; uint64_t len = (uint64_t)1 << 40; //#else //# warning this looks like a 32-bit system, using small inode numbers. diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index fc00797d20ed0..387eda18ffa34 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1768,6 +1768,8 @@ void MDS::boot_create() mdcache->init_layouts(); + snapserver->set_rank(whoami); + inotable->set_rank(whoami); sessionmap.set_rank(whoami); // start with a fresh journal @@ -1851,6 +1853,7 @@ void MDS::boot_start(BootStep step, int r) MDSGatherBuilder gather(g_ceph_context, new C_MDS_BootStart(this, MDS_BOOT_OPEN_ROOT)); dout(2) << "boot_start " << step << ": opening inotable" << dendl; + inotable->set_rank(whoami); inotable->load(gather.new_sub()); dout(2) << "boot_start " << step << ": opening sessionmap" << dendl; @@ -1862,6 +1865,7 @@ void MDS::boot_start(BootStep step, int r) if (mdsmap->get_tableserver() == whoami) { dout(2) << "boot_start " << step << ": opening snap table" << dendl; + snapserver->set_rank(whoami); snapserver->load(gather.new_sub()); } diff --git a/src/mds/MDSTable.cc b/src/mds/MDSTable.cc index 8e159d7c9df63..a1712dcd9edfa 100644 --- a/src/mds/MDSTable.cc +++ b/src/mds/MDSTable.cc @@ -29,7 +29,7 @@ #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << (mds ? mds->get_nodeid() : -1) << "." << table_name << ": " +#define dout_prefix *_dout << "mds." << rank << "." << table_name << ": " class MDSTableIOContext : public MDSIOContextBase diff --git a/src/mds/MDSTable.h b/src/mds/MDSTable.h index c68a615ea2a23..392f4fd19acff 100644 --- a/src/mds/MDSTable.h +++ b/src/mds/MDSTable.h @@ -29,6 +29,7 @@ public: protected: const char *table_name; bool per_mds; + mds_rank_t rank; object_t get_object_name(); @@ -44,11 +45,16 @@ protected: public: MDSTable(MDS *m, const char *n, bool is_per_mds) : - mds(m), table_name(n), per_mds(is_per_mds), + mds(m), table_name(n), per_mds(is_per_mds), rank(MDS_RANK_NONE), state(STATE_UNDEF), version(0), committing_version(0), committed_version(0), projected_version(0) {} virtual ~MDSTable() {} + void set_rank(mds_rank_t r) + { + rank = r; + } + version_t get_version() { return version; } version_t get_committed_version() { return committed_version; } version_t get_committing_version() { return committing_version; } diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc index 42f421351796b..7c91a888e915d 100644 --- a/src/mds/MDSTableServer.cc +++ b/src/mds/MDSTableServer.cc @@ -22,7 +22,7 @@ #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".tableserver(" << get_mdstable_name(table) << ") " +#define dout_prefix *_dout << "mds." << rank << ".tableserver(" << get_mdstable_name(table) << ") " /* This function DOES put the passed message before returning */ void MDSTableServer::handle_request(MMDSTableRequest *req) diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 2e211d9f89401..ac0407393edec 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -29,7 +29,7 @@ #define dout_subsys ceph_subsys_mds #undef dout_prefix -#define dout_prefix *_dout << "mds." << mds->get_nodeid() << ".snap " +#define dout_prefix *_dout << "mds." << rank << ".snap " void SnapServer::reset_state() -- 2.39.5