]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
synclient: dump placement
authorEsteban Molina-Estolano <eestolan@lanl.gov>
Mon, 8 Sep 2008 19:48:20 +0000 (12:48 -0700)
committerSage Weil <sage@newdream.net>
Mon, 8 Sep 2008 19:48:20 +0000 (12:48 -0700)
src/client/SyntheticClient.cc
src/client/SyntheticClient.h

index eaba4dac21ef441da0f469262f51951d78912ed5..4713ef02e422f5931a3b05146e2a86c2567d3439 100644 (file)
@@ -111,7 +111,9 @@ void parse_syn_options(vector<const char*>& args)
         syn_modes.push_back( SYNCLIENT_MODE_READFILE );
         syn_iargs.push_back( a );
         syn_iargs.push_back( b );
-
+      } else if (strcmp(args[i],"dumpplacement") == 0) {
+       syn_modes.push_back( SYNCLIENT_MODE_DUMP );
+       syn_sargs.push_back( args[++i] );   
       } else if (strcmp(args[i],"makedirs") == 0) {
         syn_modes.push_back( SYNCLIENT_MODE_MAKEDIRS );
         syn_iargs.push_back( atoi(args[++i]) );
@@ -430,6 +432,19 @@ int SyntheticClient::run()
       }
       break;
 
+
+    case SYNCLIENT_MODE_DUMP:
+      {
+       string sarg1 = get_sarg(0);
+       if (run_me()) {
+         dout(2) << "placement dump " << sarg1 << dendl;
+         dump_placement(sarg1);
+       }
+       did_run_me();
+      }
+      break;
+
+
     case SYNCLIENT_MODE_MAKEDIRMESS:
       {
         string sarg1 = get_sarg(0);
@@ -1556,6 +1571,54 @@ int SyntheticClient::full_walk(string& basedir)
   return 0;
 }
 
+
+
+int SyntheticClient::dump_placement(string& fn) {
+
+  // open file
+  int fd = client->open(fn.c_str(), O_RDONLY);
+  dout(5) << "reading from " << fn << " fd " << fd << dendl;
+  if (fd < 0) return fd;
+
+
+  // How big is it?
+  struct stat stbuf;
+  int lstat_result = client->lstat(fn.c_str(), &stbuf);
+  if (lstat_result < 0) {
+    derr(0) << "lstat error for file " << fn << dendl;
+    return lstat_result;
+  }
+    
+  off_t filesize = stbuf.st_size;
+  // grab the placement info
+  list<ObjectExtent> extents;
+  off_t offset = 0;
+  client->enumerate_layout(fd, extents, filesize, offset);
+  client->close(fd);
+
+
+  // run through all the object extents
+  dout(0) << "file size is " << filesize << dendl;
+  dout(0) << "(osd, start, length) tuples for file " << fn << dendl;
+  for (list<ObjectExtent>::iterator i = extents.begin(); 
+       i != extents.end(); ++i) {
+    
+    int osd = client->osdmap->get_pg_primary(pg_t(i->layout.ol_pgid.v));
+
+    // run through all the buffer extents
+    for (map<size_t, size_t>::iterator j = i ->buffer_extents.begin();
+        j != i->buffer_extents.end(); ++j) {
+      
+      dout(0) << "OSD " << osd << ", offset " << (*j).first <<
+       ", length " << (*j).second << dendl;    
+    }
+  }
+  return 0;
+}
+
+
+
 int SyntheticClient::make_dirs(const char *basedir, int dirs, int files, int depth)
 {
   if (time_to_stop()) return 0;
index b128ce0f7f69e19170ac937e83d0bd9309478060..d02d0adb7fa6507c1f1708526012f1b16614a973 100644 (file)
@@ -69,6 +69,9 @@
 #define SYNCLIENT_MODE_RANDOMSLEEP  61
 #define SYNCLIENT_MODE_SLEEP        62
 
+#define SYNCLIENT_MODE_DUMP 63
+
+
 #define SYNCLIENT_MODE_TRUNCATE     200
 
 #define SYNCLIENT_MODE_FOO        100
@@ -213,6 +216,9 @@ class SyntheticClient {
   int full_walk(string& fromdir);
   int random_walk(int n);
 
+  int dump_placement(string& fn);
+
+
   int make_dirs(const char *basedir, int dirs, int files, int depth);
   int stat_dirs(const char *basedir, int dirs, int files, int depth);
   int read_dirs(const char *basedir, int dirs, int files, int depth);