]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_trans
authorSage Weil <sage@newdream.net>
Tue, 10 Nov 2009 16:23:38 +0000 (08:23 -0800)
committerSage Weil <sage@newdream.net>
Tue, 10 Nov 2009 16:23:38 +0000 (08:23 -0800)
src/Makefile.am
src/os/FileStore.cc
src/test_trans.cc [new file with mode: 0644]

index 385c89b07cb9ec3fe3f2ce8836bd7d1362505e10..d0262bd8002eaf3e8ced27174132893115dd8a37 100644 (file)
@@ -56,6 +56,10 @@ streamtest_SOURCES = streamtest.cc
 streamtest_LDADD = libos.a libcommon.a -lpthread -lm
 bin_PROGRAMS += dumpjournal dupstore streamtest
 
+test_trans_SOURCES = test_trans.cc
+test_trans_LDADD = libos.a libcommon.a -lpthread -lm
+bin_PROGRAMS += test_trans
+
 # synthetic client
 csyn_SOURCES = csyn.cc msg/SimpleMessenger.cc
 csyn_LDADD = libclient.a libosdc.a libcrush.a libcommon.a -lpthread -lm
index af2a0fd4d75a2bd1c9dae6a93e04b86b31388ff4..e21871be09b45873c1314846d7549526d2d21e66 100644 (file)
@@ -1207,16 +1207,17 @@ int FileStore::_do_usertrans(list<Transaction*>& ls)
   }
 
   ut.num_ops = ops.size();
-  ut.ops_ptr = (unsigned long long)&ops[0];
+  ut.ops_ptr = (__u64)&ops[0];
   ut.num_fds = 2;
   ut.metadata_ops = ops.size();
   ut.flags = 0;
 
   dout(20) << "USERTRANS ioctl on " << ops.size() << " ops" << dendl;
   int r = ::ioctl(op_fd, BTRFS_IOC_USERTRANS, &ut);
-  dout(10) << "USERTRANS ioctl on " << ops.size() << " ops = " << r << dendl;
+  dout(10) << "USERTRANS ioctl on " << ops.size() << " r = " << r
+          << ", completed " << ut.ops_completed << " ops" << dendl;
   if (r >= 0) {
-    for (unsigned i=0; i<ops.size(); i++)
+    for (unsigned i=0; i<ut.ops_completed; i++)
       dout(10) << "USERTRANS ioctl op[" << i << "] " << ops[i] << " = " << ops[i].rval << dendl;
     assert(ut.ops_completed == ops.size());
     r = 0;
diff --git a/src/test_trans.cc b/src/test_trans.cc
new file mode 100644 (file)
index 0000000..727e8a0
--- /dev/null
@@ -0,0 +1,72 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#include <iostream>
+//#include "ebofs/Ebofs.h"
+#include "os/FileStore.h"
+#include "common/common_init.h"
+
+#undef dout_prefix
+#define dout_prefix *_dout << dbeginl
+
+struct Foo : public Thread {
+  void *entry() {
+    dout(0) << "foo started" << dendl;
+    sleep(1);
+    dout(0) << "foo asserting 0" << dendl;
+    assert(0);
+  }
+} foo;
+
+int main(int argc, const char **argv)
+{
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+  common_init(args, NULL, false);
+
+  // args
+  if (args.size() < 2) return -1;
+  const char *filename = args[0];
+  int mb = atoi(args[1]);
+
+  cout << "#dev " << filename << std::endl;
+  cout << "#mb " << mb << std::endl;
+
+  ObjectStore *fs = new FileStore(filename);
+  if (fs->mount() < 0) {
+    cout << "mount failed" << std::endl;
+    return -1;
+  }
+
+  ObjectStore::Transaction t;
+  char buf[1 << 20];
+  bufferlist bl;
+  bl.append(buf, sizeof(buf));
+  t.create_collection(coll_t());
+
+  for (int i=0; i<mb; i++) {
+    char f[30];
+    sprintf(f, "foo%d\n", i);
+    sobject_t soid(f, CEPH_NOSNAP);
+    t.write(coll_t(), soid, 0, bl.length(), bl);
+  }
+  
+  dout(0) << "starting thread" << dendl;
+  foo.create();
+  dout(0) << "starting op" << dendl;
+  fs->apply_transaction(t);
+
+}
+