From 125e6fe88c4a2e2fe8792c0f36e00fbc945ae325 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 21 Jun 2007 00:01:09 +0000 Subject: [PATCH] * some journal tidying git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1433 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/ebofs/Ebofs.cc | 30 +++++++++++++++++------------- trunk/ceph/ebofs/FileJournal.cc | 29 ++++++++++++++--------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/trunk/ceph/ebofs/Ebofs.cc b/trunk/ceph/ebofs/Ebofs.cc index 2ab5b1e0182df..f315d0385016f 100644 --- a/trunk/ceph/ebofs/Ebofs.cc +++ b/trunk/ceph/ebofs/Ebofs.cc @@ -2068,7 +2068,11 @@ unsigned Ebofs::apply_transaction(Transaction& t, Context *onsafe) unsigned r = _apply_transaction(t); - // set up commit waiter + // journal, wait for commit + if (r != 0 && onsafe) { + delete onsafe; // kill callback, but still journal below (in case transaction had side effects) + onsafe = 0; + } while (1) { if (journal) { bufferlist bl; @@ -2432,7 +2436,7 @@ int Ebofs::remove(object_t oid, Context *onsafe) // do it int r = _remove(oid); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2517,7 +2521,7 @@ int Ebofs::truncate(object_t oid, off_t size, Context *onsafe) int r = _truncate(oid, size); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2546,7 +2550,7 @@ int Ebofs::clone(object_t from, object_t to, Context *onsafe) int r = _clone(from, to); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2732,7 +2736,7 @@ int Ebofs::setattr(object_t oid, const char *name, const void *value, size_t siz ebofs_lock.Lock(); int r = _setattr(oid, name, value, size); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2775,7 +2779,7 @@ int Ebofs::setattrs(object_t oid, map& attrset, Context *onsaf ebofs_lock.Lock(); int r = _setattrs(oid, attrset); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2870,7 +2874,7 @@ int Ebofs::rmattr(object_t oid, const char *name, Context *onsafe) int r = _rmattr(oid, name); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -2957,7 +2961,7 @@ int Ebofs::create_collection(coll_t cid, Context *onsafe) int r = _create_collection(cid); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -3014,7 +3018,7 @@ int Ebofs::destroy_collection(coll_t cid, Context *onsafe) int r = _destroy_collection(cid); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -3078,7 +3082,7 @@ int Ebofs::collection_add(coll_t cid, object_t oid, Context *onsafe) int r = _collection_add(cid, oid); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -3129,7 +3133,7 @@ int Ebofs::collection_remove(coll_t cid, object_t oid, Context *onsafe) int r = _collection_remove(cid, oid); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -3202,7 +3206,7 @@ int Ebofs::collection_setattr(coll_t cid, const char *name, const void *value, s int r = _collection_setattr(cid, name, value, size); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { @@ -3270,7 +3274,7 @@ int Ebofs::collection_rmattr(coll_t cid, const char *name, Context *onsafe) int r = _collection_rmattr(cid, name); - // set up commit waiter + // journal, wait for commit if (r >= 0) { while (1) { if (journal) { diff --git a/trunk/ceph/ebofs/FileJournal.cc b/trunk/ceph/ebofs/FileJournal.cc index 5b7278b2f143a..74edecf41c71a 100644 --- a/trunk/ceph/ebofs/FileJournal.cc +++ b/trunk/ceph/ebofs/FileJournal.cc @@ -53,7 +53,9 @@ int FileJournal::create() header.max_size = st.st_size; write_header(); - read_pos = write_pos = queue_pos = sizeof(header); + // writeable. + read_pos = 0; + write_pos = queue_pos = sizeof(header); ::close(fd); @@ -73,37 +75,34 @@ int FileJournal::open() } assert(fd > 0); + // assume writeable, unless... + read_pos = 0; + write_pos = queue_pos = sizeof(header); + // read header? read_header(); - if (header.num == 0 || - header.fsid != ebofs->get_fsid()) { - // empty. - read_pos = 0; - write_pos = queue_pos = sizeof(header); - } else { - // pick an offset - read_pos = write_pos = queue_pos = 0; + if (header.num > 0 && header.fsid == ebofs->get_fsid()) { + // valid header, pick an offset for (int i=0; iget_super_epoch()) { dout(2) << "using read_pos header pointer " << header.epoch[i] << " at " << header.offset[i] << endl; read_pos = header.offset[i]; + write_pos = queue_pos = 0; break; } - if (header.epoch[i] < ebofs->get_super_epoch()) { + else if (header.epoch[i] < ebofs->get_super_epoch()) { dout(2) << "super_epoch is " << ebofs->get_super_epoch() - << ", skipping " << header.epoch[i] << " at " << header.offset[i] + << ", skipping old " << header.epoch[i] << " at " << header.offset[i] << endl; - continue; } - if (header.epoch[i] > ebofs->get_super_epoch()) { + else if (header.epoch[i] > ebofs->get_super_epoch()) { dout(2) << "super_epoch is " << ebofs->get_super_epoch() << ", but wtf, journal is later " << header.epoch[i] << " at " << header.offset[i] << endl; break; } - assert(0); } } @@ -257,7 +256,7 @@ void FileJournal::write_thread_entry() bool FileJournal::submit_entry(bufferlist& e, Context *oncommit) { - assert(queue_pos != 0); // bad create(), or journal didn't replay to completion. + assert(queue_pos != 0); // bad create(), or journal didn't replay to completion. // ** lock ** Mutex::Locker locker(write_lock); -- 2.39.5