From 80a079640b73647c67aa8a25130305ba8517659e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 23 Jan 2008 10:49:54 -0800 Subject: [PATCH] streamtest.ebofs --- src/Makefile | 3 ++ src/ebofs/streamtest.cc | 82 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/ebofs/streamtest.cc diff --git a/src/Makefile b/src/Makefile index 6fb7c888ec8d7..6f383bcb49868 100644 --- a/src/Makefile +++ b/src/Makefile @@ -220,6 +220,9 @@ mkfs.ebofs: ebofs/mkfs.ebofs.cc config.cc common/Clock.o ebofs.o test.ebofs: ebofs/test.ebofs.cc config.cc common/Clock.o ebofs.o ${CXX} ${CFLAGS} ${LIBS} $^ -o $@ +streamtest.ebofs: ebofs/streamtest.cc config.cc common/Clock.o ebofs.o + ${CXX} ${CFLAGS} ${LIBS} $^ -o $@ + dupstore: dupstore.cc config.cc ebofs.o common/Clock.o common/Timer.o osd/FakeStore.o ${CXX} ${CFLAGS} ${LIBS} $^ -o $@ diff --git a/src/ebofs/streamtest.cc b/src/ebofs/streamtest.cc new file mode 100644 index 0000000000000..6ce7f843f1f9c --- /dev/null +++ b/src/ebofs/streamtest.cc @@ -0,0 +1,82 @@ +// -*- 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 + * + * 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 +#include "ebofs/Ebofs.h" + +map > writes; + +struct C_Commit : public Context { + off_t off; + C_Commit(off_t o) : off(o) {} + void finish(int r) { + utime_t now = g_clock.now(); + cout << off << "\t" + << (writes[off].second-writes[off].first) << "\t" + << (now - writes[off].first) << std::endl; + writes.erase(off); + } +}; + + +int main(int argc, const char **argv) +{ + vector args; + argv_to_vec(argc, argv, args); + parse_config_options(args); + + // args + if (args.size() != 3) return -1; + const char *filename = args[0]; + int seconds = atoi(args[1]); + int bytes = atoi(args[2]); + + buffer::ptr bp(bytes); + bp.zero(); + bufferlist bl; + bl.push_back(bp); + + + cout << "#dev " << filename + << seconds << " seconds, " << bytes << " bytes per write" << std::endl; + + Ebofs fs(filename); + if (fs.mkfs() < 0) { + cout << "mkfs failed" << std::endl; + return -1; + } + if (fs.mount() < 0) { + cout << "mount failed" << std::endl; + return -1; + } + + utime_t now = g_clock.now(); + utime_t end = now; + end += seconds; + off_t pos = 0; + //cout << "stop at " << end << std::endl; + cout << "# offset\tack\tcommit" << std::endl; + while (now < end) { + object_t oid(1,1); + writes[pos].first = now; + fs.write(oid, pos, bytes, bl, new C_Commit(pos)); + now = g_clock.now(); + writes[pos].second = now; + pos += bytes; + } + + fs.umount(); + +} + -- 2.39.5