Permalink
Browse files

Merge remote branch 'gh/wip-filestore-misc'

Conflicts:
	src/test/filestore/run_seed_to.sh
  • Loading branch information...
2 parents 6bb3e84 + 96108c6 commit c24c9e3a551ab4af96931b8635f90231c16d7902 @liewegas liewegas committed Apr 28, 2012
View
@@ -744,11 +744,11 @@ test_filestore_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} \
-I$(top_srcdir)/src/leveldb/include
bin_DEBUGPROGRAMS += test_filestore
-test_filestore_workloadgen_SOURCES = test/filestore/workload_generator.cc
+test_filestore_workloadgen_SOURCES = \
+ test/filestore/workload_generator.cc \
+ test/filestore/TestFileStoreState.cc
test_filestore_workloadgen_LDFLAGS = ${AM_LDFLAGS}
-test_filestore_workloadgen_LDADD = ${UNITTEST_STATIC_LDADD} libos.la leveldb/libleveldb.a $(LIBGLOBAL_LDA)
-test_filestore_workloadgen_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} \
- -I$(top_srcdir)/src/leveldb/include
+test_filestore_workloadgen_LDADD = libos.la leveldb/libleveldb.a $(LIBGLOBAL_LDA)
bin_DEBUGPROGRAMS += test_filestore_workloadgen
test_filestore_idempotent_SOURCES = test/filestore/test_idempotent.cc test/filestore/FileStoreTracker.cc test/common/ObjectContents.cc
@@ -142,6 +142,7 @@ void DeterministicOpSequence::do_touch(rngen_t& gen)
int obj_id = _gen_obj_id(gen);
coll_entry_t *entry = get_coll_at(coll_id);
+ ceph_assert(entry != NULL);
hobject_t *obj = entry->touch_obj(obj_id);
dout(0) << "do_touch " << entry->m_coll.to_str() << "/" << obj->oid.name << dendl;
@@ -155,6 +156,7 @@ void DeterministicOpSequence::do_remove(rngen_t& gen)
int obj_id = _gen_obj_id(gen);
coll_entry_t *entry = get_coll_at(coll_id);
+ ceph_assert(entry != NULL);
hobject_t *obj = entry->touch_obj(obj_id);
// ENOENT ok here.
@@ -62,12 +62,12 @@ void TestFileStoreState::init(int colls, int objs)
m_store->queue_transaction(&(entry->m_osr), t,
new C_OnFinished(this, t));
- m_in_flight++;
+ inc_in_flight();
m_collections.insert(make_pair(coll_id, entry));
m_next_coll_nr++;
}
- dout(5) << "init has " << m_in_flight << "in-flight transactions" << dendl;
+ dout(5) << "init has " << m_in_flight.read() << "in-flight transactions" << dendl;
wait_for_done();
dout(5) << "init finished" << dendl;
}
@@ -83,16 +83,20 @@ TestFileStoreState::coll_entry_t *TestFileStoreState::coll_create(int id)
return (new coll_entry_t(id, buf, meta_buf));
}
-TestFileStoreState::coll_entry_t *TestFileStoreState::get_coll_at(int pos)
+TestFileStoreState::coll_entry_t*
+TestFileStoreState::get_coll(int key, bool erase)
{
- dout(5) << "get_coll_at pos " << pos << dendl;
+ dout(5) << "get_coll id " << key << dendl;
coll_entry_t *entry = NULL;
- map<int, coll_entry_t*>::iterator it = m_collections.find(pos);
- if (it != m_collections.end())
+ map<int, coll_entry_t*>::iterator it = m_collections.find(key);
+ if (it != m_collections.end()) {
entry = it->second;
+ if (erase)
+ m_collections.erase(it);
+ }
- dout(5) << "get_coll_at pos " << pos;
+ dout(5) << "get_coll id " << key;
if (!entry)
*_dout << " non-existent";
else
@@ -101,20 +105,51 @@ TestFileStoreState::coll_entry_t *TestFileStoreState::get_coll_at(int pos)
return entry;
}
+TestFileStoreState::coll_entry_t*
+TestFileStoreState::get_coll_at(int pos, bool erase)
+{
+ dout(5) << "get_coll_at pos " << pos << dendl;
+
+ if (m_collections.empty())
+ return NULL;
+
+ coll_entry_t *entry = NULL;
+ map<int, coll_entry_t*>::iterator it = m_collections.begin();
+ for (int i = 0; it != m_collections.end(); it++, i++) {
+ if (i == pos) {
+ entry = it->second;
+ break;
+ }
+ }
+
+ if (entry == NULL) {
+ dout(5) << "get_coll_at pos " << pos << " non-existent" << dendl;
+ return NULL;
+ }
+
+ if (erase)
+ m_collections.erase(it);
+
+ dout(5) << "get_coll_at pos " << pos << ": "
+ << entry->m_coll << "(removed: " << erase << ")" << dendl;
+
+ return entry;
+}
+
TestFileStoreState::coll_entry_t::~coll_entry_t()
{
- /*
if (m_objects.size() > 0) {
- for (set<hobject_t*>::iterator it = m_objects.begin();
- it != m_objects.end(); it++) {
- hobject_t *obj = *it;
+// for (set<hobject_t*>::iterator it = m_objects.begin();
+// it != m_objects.end(); it++) {
+ map<int, hobject_t*>::iterator it = m_objects.begin();
+ for (; it != m_objects.end(); it++) {
+ hobject_t *obj = it->second;
m_objects.erase(it);
if (obj) {
delete obj;
}
}
}
- */
}
hobject_t *TestFileStoreState::coll_entry_t::touch_obj(int id)
@@ -59,18 +59,19 @@ class TestFileStoreState {
int m_num_objs_per_coll;
int m_max_in_flight;
- int m_in_flight;
+ atomic_t m_in_flight;
Mutex m_finished_lock;
Cond m_finished_cond;
void wait_for_ready() {
- while ((m_max_in_flight > 0) && (m_in_flight >= m_max_in_flight))
+ Mutex::Locker locker(m_finished_lock);
+ while ((m_max_in_flight > 0) && ((int)m_in_flight.read() >= m_max_in_flight))
m_finished_cond.Wait(m_finished_lock);
}
void wait_for_done() {
Mutex::Locker locker(m_finished_lock);
- while (m_in_flight)
+ while (m_in_flight.read())
m_finished_cond.Wait(m_finished_lock);
}
@@ -81,37 +82,55 @@ class TestFileStoreState {
m_num_objs_per_coll = val;
}
- coll_entry_t *get_coll_at(int pos);
+ coll_entry_t *get_coll(int key, bool erase = false);
+ coll_entry_t *get_coll_at(int pos, bool erase = false);
private:
static const int m_default_num_colls = 30;
public:
TestFileStoreState(FileStore *store) :
m_next_coll_nr(0), m_num_objs_per_coll(10),
- m_max_in_flight(0), m_in_flight(0), m_finished_lock("Finished Lock") {
+ m_max_in_flight(0), m_finished_lock("Finished Lock") {
+ m_in_flight.set(0);
m_store.reset(store);
}
- ~TestFileStoreState() { }
+ ~TestFileStoreState() {
+ map<int, coll_entry_t*>::iterator it = m_collections.begin();
+ for (; it != m_collections.end(); it++) {
+ if (it->second)
+ delete it->second;
+ m_collections.erase(it);
+ }
+ }
void init(int colls, int objs);
void init() {
init(m_default_num_colls, 0);
}
+ int inc_in_flight() {
+ return ((int) m_in_flight.inc());
+ }
+
+ int dec_in_flight() {
+ return ((int) m_in_flight.dec());
+ }
+
coll_entry_t *coll_create(int id);
class C_OnFinished: public Context {
+ protected:
TestFileStoreState *m_state;
ObjectStore::Transaction *m_tx;
- public:
+ public:
C_OnFinished(TestFileStoreState *state,
ObjectStore::Transaction *t) : m_state(state), m_tx(t) { }
void finish(int r) {
Mutex::Locker locker(m_state->m_finished_lock);
- m_state->m_in_flight--;
+ m_state->dec_in_flight();
m_state->m_finished_cond.Signal();
delete m_tx;
@@ -43,6 +43,7 @@ usage() {
echo " -b, --btrfs <VAL> seq number for btrfs stores"
echo " --no-journal-test don't perform journal replay tests"
echo " -e, --exit-on-error exit with 1 on error"
+ echo " -v, --valgrind run commands through valgrind"
echo
echo "env vars:"
echo " OPTS_STORE additional opts for both stores"
@@ -70,7 +71,11 @@ journal_test=1
min_sync_interval="36000" # ten hours, yes.
max_sync_interval="36001"
exit_on_error=0
+<<<<<<< HEAD
+=======
+v=""
+>>>>>>> gh/wip-filestore-misc
do_rm() {
if [[ $on_btrfs -eq 0 ]]; then
@@ -121,6 +126,13 @@ do
exit_on_error=1
shift
;;
+<<<<<<< HEAD
+=======
+ -v | --valgrind)
+ v="valgrind --leak-check=full"
+ shift
+ ;;
+>>>>>>> gh/wip-filestore-misc
--)
shift
break
@@ -239,11 +251,16 @@ do
fi
do_rm $tmp_name_a $tmp_name_a.fail $tmp_name_a.recover
+<<<<<<< HEAD
test_filestore_idempotent_sequence run-sequence-to $to \
+=======
+ $v test_filestore_idempotent_sequence run-sequence-to $to \
+>>>>>>> gh/wip-filestore-misc
$tmp_name_a $tmp_name_a/journal \
--filestore-xattr-use-omap --test-seed $seed --osd-journal-size 100 \
--filestore-kill-at $killat $tmp_opts_a \
--log-file $tmp_name_a.fail --debug-filestore 20 || true
+<<<<<<< HEAD
stop_at=`test_filestore_idempotent_sequence get-last-op \
$tmp_name_a $tmp_name_a/journal \
@@ -259,11 +276,32 @@ do
do_rm $tmp_name_b $tmp_name_b.clean
test_filestore_idempotent_sequence run-sequence-to \
+=======
+
+ stop_at=`test_filestore_idempotent_sequence get-last-op \
+ $tmp_name_a $tmp_name_a/journal \
+ --filestore-xattr-use-omap --log-file $tmp_name_a.recover \
+ --debug-filestore 20 --debug-journal 20`
+
+ if [[ "`expr $stop_at - $stop_at 2>/dev/null`" != "0" ]]; then
+ echo "error: get-last-op returned '$stop_at'"
+ exit 1
+ fi
+
+ echo stopped at $stop_at
+
+ do_rm $tmp_name_b $tmp_name_b.clean
+ $v test_filestore_idempotent_sequence run-sequence-to \
+>>>>>>> gh/wip-filestore-misc
$stop_at $tmp_name_b $tmp_name_b/journal \
--filestore-xattr-use-omap --test-seed $seed --osd-journal-size 100 \
--log-file $tmp_name_b.clean --debug-filestore 20 $tmp_opts_b
+<<<<<<< HEAD
if test_filestore_idempotent_sequence diff \
+=======
+ if $v test_filestore_idempotent_sequence diff \
+>>>>>>> gh/wip-filestore-misc
$tmp_name_a $tmp_name_a/journal $tmp_name_b $tmp_name_b/journal \
--filestore-xattr-use-omap; then
echo OK
Oops, something went wrong.

0 comments on commit c24c9e3

Please sign in to comment.