From a1abca48facaddd6720b91d92fd362ee1e173584 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 15 Apr 2008 10:07:23 -0700 Subject: [PATCH] psim crush placement sim --- src/Makefile.am | 7 ++++++- src/psim.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/psim.cc diff --git a/src/Makefile.am b/src/Makefile.am index 28b0955f71e13..52978ffcde34e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,6 +20,9 @@ crushtool_LDADD = libcommon.a libcrush.a osdmaptool_SOURCES = osdmaptool.cc osdmaptool_LDADD = libmon.a libcommon.a libcrush.a +psim_SOURCES = psim.cc +psim_LDADD = libcommon.a libcrush.a + # mds cmds_SOURCES = cmds.cc msg/SimpleMessenger.cc cmds_LDADD = libmds.a libosdc.a libcrush.a libcommon.a @@ -116,6 +119,8 @@ libhadoopcephfs.so: client/hadoop/CephFSInterface.cc libcephclient_so.a #BUILT_SOURCES += libhadoopcephfs.so + + ## INCLUDES = LDADD = -lpthread @@ -129,7 +134,7 @@ bin_PROGRAMS = \ cmonctl \ mkmonfs monmaptool osdmaptool crushtool \ fakesyn \ - streamtest dupstore \ + streamtest dupstore psim \ $(FUSEBIN) $(NEWSYN) noinst_LIBRARIES = \ libcommon.a libcrush.a \ diff --git a/src/psim.cc b/src/psim.cc new file mode 100644 index 0000000000000..deab7c8aa0dd0 --- /dev/null +++ b/src/psim.cc @@ -0,0 +1,47 @@ + +#include + +#include "crush/CrushWrapper.h" +#include "osd/OSDMap.h" +#include "config.h" +#include "include/buffer.h" + +int main() +{ + /* + * you need to create a suitable osdmap first. e.g., for 40 osds, + * $ ./osdmaptool --createsimple .ceph_monmap 40 --clobber .ceph_osdmap + */ + bufferlist bl; + bl.read_file(".ceph_osdmap"); + OSDMap osdmap; + osdmap.decode(bl); + + int n = osdmap.get_max_osd(); + int count[n]; + for (int i=0; i osds; + osdmap.pg_to_osds(pg_t(le64_to_cpu(l.ol_pgid)), osds); + for (unsigned i=0; i