From 237f76b6b455bbcfacb9f964643c79a839545e42 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 11 May 2015 13:03:36 +0100 Subject: [PATCH] mds: expose static default file layout methods So that tools can invoke these to get the defaults without a fully baked MDCache. Signed-off-by: John Spray --- src/mds/MDCache.cc | 28 ++++++++++++++++++++-------- src/mds/MDCache.h | 4 ++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 43825b55623b5..c644b3fdaa311 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -320,19 +320,31 @@ void MDCache::remove_inode(CInode *o) delete o; } +ceph_file_layout MDCache::gen_default_file_layout(const MDSMap &mdsmap) +{ + ceph_file_layout result = g_default_file_layout; + result.fl_pg_pool = mdsmap.get_first_data_pool(); + return result; +} -void MDCache::init_layouts() +ceph_file_layout MDCache::gen_default_log_layout(const MDSMap &mdsmap) { - default_file_layout = g_default_file_layout; - default_file_layout.fl_pg_pool = mds->mdsmap->get_first_data_pool(); - - default_log_layout = g_default_file_layout; - default_log_layout.fl_pg_pool = mds->mdsmap->get_metadata_pool(); + ceph_file_layout result = g_default_file_layout; + result.fl_pg_pool = mdsmap.get_metadata_pool(); if (g_conf->mds_log_segment_size > 0) { - default_log_layout.fl_object_size = g_conf->mds_log_segment_size; - default_log_layout.fl_stripe_unit = g_conf->mds_log_segment_size; + result.fl_object_size = g_conf->mds_log_segment_size; + result.fl_stripe_unit = g_conf->mds_log_segment_size; } + + return result; +} + +void MDCache::init_layouts() +{ + default_file_layout = gen_default_file_layout(*(mds->mdsmap)); + default_log_layout = gen_default_log_layout(*(mds->mdsmap)); + } void MDCache::create_unlinked_system_inode(CInode *in, inodeno_t ino, diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 1141ebef4fab0..086e1abad1a45 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -29,6 +29,7 @@ #include "RecoveryQueue.h" #include "StrayManager.h" #include "MDSContext.h" +#include "MDSMap.h" #include "messages/MClientRequest.h" #include "messages/MMDSSlaveRequest.h" @@ -163,6 +164,9 @@ public: unsigned max_dir_commit_size; + static ceph_file_layout gen_default_file_layout(const MDSMap &mdsmap); + static ceph_file_layout gen_default_log_layout(const MDSMap &mdsmap); + ceph_file_layout default_file_layout; ceph_file_layout default_log_layout; -- 2.39.5