From 9c46520d8a2a68737d7d16106f43ece680c521bf Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Nov 2009 08:23:38 -0800 Subject: [PATCH] test_trans --- src/Makefile.am | 4 +++ src/os/FileStore.cc | 7 +++-- src/test_trans.cc | 72 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 src/test_trans.cc diff --git a/src/Makefile.am b/src/Makefile.am index 385c89b07cb9e..d0262bd8002ea 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index af2a0fd4d75a2..e21871be09b45 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1207,16 +1207,17 @@ int FileStore::_do_usertrans(list& 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 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; iapply_transaction(t); + +} + -- 2.39.5