]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
psim crush placement sim
authorSage Weil <sage@newdream.net>
Tue, 15 Apr 2008 17:07:23 +0000 (10:07 -0700)
committerSage Weil <sage@newdream.net>
Tue, 15 Apr 2008 17:07:23 +0000 (10:07 -0700)
src/Makefile.am
src/psim.cc [new file with mode: 0644]

index 28b0955f71e13bf51510314b3fe8cc1379c7dd79..52978ffcde34e74ec9ab097c4ba821648cf3d800 100644 (file)
@@ -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 (file)
index 0000000..deab7c8
--- /dev/null
@@ -0,0 +1,47 @@
+
+#include <iostream>
+
+#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<n; i++) {
+    osdmap.mark_up(i);
+    osdmap.mark_in(i);
+    count[i] = 0;
+  }
+
+  for (int f = 1; f < 1000; f++) {  // files
+    for (int b = 0; b < 4; b++) {   // blocks
+      object_t oid(f, b);
+      //cout << "oid " << oid << std::endl;
+      ceph_object_layout l = osdmap.file_to_object_layout(oid, g_default_file_layout);
+      vector<int> osds;
+      osdmap.pg_to_osds(pg_t(le64_to_cpu(l.ol_pgid)), osds);
+      for (unsigned i=0; i<osds.size(); i++) {
+       //cout << " rep " << i << " on " << osds[i] << std::endl;
+       count[osds[i]]++;
+      }
+    }
+  }
+
+  for (int i=0; i<n; i++) {
+    cout << "osd" << i << "\t" << count[i] << std::endl;
+  }
+  
+  return 0;
+}