From 324f1e9345b6484a06da342a3e4143e8438269dd Mon Sep 17 00:00:00 2001 From: sage Date: Mon, 13 Jun 2005 04:22:29 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@299 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/config.cc | 2 +- ceph/fakefuse.cc | 7 +++- ceph/mds/MDCache.cc | 86 +++++++++++++++++++++++------------------- ceph/mds/MDStore.cc | 9 ++--- ceph/messages/MOSDOp.h | 15 +++++--- ceph/osd/OSD.cc | 21 +++++++++++ ceph/osdc/Filer.h | 3 ++ ceph/test/fakemds.cc | 14 +++---- 8 files changed, 98 insertions(+), 59 deletions(-) diff --git a/ceph/config.cc b/ceph/config.cc index 5e34c027b162d..0925e8570a942 100644 --- a/ceph/config.cc +++ b/ceph/config.cc @@ -46,11 +46,11 @@ md_config_t g_conf = { mds_bal_interval: 200, mds_commit_on_shutdown: true, + mds_verify_export_dirauth: true, // --- osd --- - osd_fsync: true, diff --git a/ceph/fakefuse.cc b/ceph/fakefuse.cc index 3223cd1e820dd..9e5315f497542 100644 --- a/ceph/fakefuse.cc +++ b/ceph/fakefuse.cc @@ -41,9 +41,14 @@ public: -int main(int argc, char **argv) { +int main(int oargc, char **oargv) { cerr << "fakefuse starting" << endl; + int argc; + char **argv; + parse_config_options(oargc, oargv, + argc, argv); + MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // start messenger thread diff --git a/ceph/mds/MDCache.cc b/ceph/mds/MDCache.cc index 69dc3d9eadf08..cc0ccc31de792 100644 --- a/ceph/mds/MDCache.cc +++ b/ceph/mds/MDCache.cc @@ -98,9 +98,9 @@ bool MDCache::shutdown() { if (lru.lru_get_size() > 0) { dout(7) << "WARNING: mdcache shutodwn with non-empty cache" << endl; - show_cache(); + //show_cache(); show_imports(); - dump(); + //dump(); } } @@ -570,7 +570,7 @@ bool MDCache::shutdown_pass() // commits? if (g_conf.mds_commit_on_shutdown && shutdown_commits > 0) { - dout(7) << "shutdown_commits = " << shutdown_commits << endl; + dout(7) << "shutdown_commits still waiting for " << shutdown_commits << endl; return false; } @@ -586,6 +586,7 @@ bool MDCache::shutdown_pass() dout(7) << "log is empty. flushing cache" << endl; trim(0); } + dout(5) << "cache size now " << lru.lru_get_size() << endl; // send all imports back to 0. @@ -603,48 +604,57 @@ bool MDCache::shutdown_pass() } } - // shut down root? - if (lru.lru_get_size() == 1) { - if (root && - root->dir && - root->dir->is_import() && - root->dir->get_ref() == 1) { // 1 is the import! - // un-import - dout(7) << "removing root import" << endl; - imports.erase(root->dir); - root->dir->state_clear(CDIR_STATE_IMPORT); - root->dir->put(CDIR_PIN_IMPORT); - trim(0); + // filer active? + if (mds->filer->is_active()) { + dout(7) << "filer still active" << endl; + return false; + } + + if (g_conf.mds_log_flush_on_shutdown || + g_conf.mds_commit_on_shutdown) { + + // shut down root? + if (lru.lru_get_size() == 1) { + if (root && + root->dir && + root->dir->is_import() && + root->dir->get_ref() == 1) { // 1 is the import! + // un-import + dout(7) << "removing root import" << endl; + imports.erase(root->dir); + root->dir->state_clear(CDIR_STATE_IMPORT); + root->dir->put(CDIR_PIN_IMPORT); + trim(0); + } + + if (root && root->is_pinned_by(CINODE_PIN_DIRTY)) { + dout(7) << "clearing root dirty flag" << endl; + root->put(CINODE_PIN_DIRTY); + trim(0); + } } + + // sanity + assert(inode_map.size() == lru.lru_get_size()); - if (root && root->is_pinned_by(CINODE_PIN_DIRTY)) { - dout(7) << "clearing root dirty flag" << endl; - root->put(CINODE_PIN_DIRTY); - trim(0); + // done? + if (lru.lru_get_size() > 0) { + dout(7) << "there's still stuff in the cache: " << lru.lru_get_size() << endl; + //show_cache(); + //dump(); + return false; } } - // sanity - assert(inode_map.size() == lru.lru_get_size()); - - // done? - if ((lru.lru_get_size() == 0 || - (g_conf.mds_commit_on_shutdown == false && g_conf.mds_log_flush_on_shutdown == false)) && - !mds->filer->is_active()) { - if (mds->get_nodeid() != 0) { - dout(7) << "done, sending shutdown_finish" << endl; - mds->messenger->send_message(new MGenericMessage(MSG_MDS_SHUTDOWNFINISH), - MSG_ADDR_MDS(0), MDS_PORT_MAIN, MDS_PORT_MAIN); - } else { - mds->handle_shutdown_finish(NULL); - } - return true; + // done! + if (mds->get_nodeid() != 0) { + dout(7) << "done, sending shutdown_finish" << endl; + mds->messenger->send_message(new MGenericMessage(MSG_MDS_SHUTDOWNFINISH), + MSG_ADDR_MDS(0), MDS_PORT_MAIN, MDS_PORT_MAIN); } else { - dout(7) << "filer active, or there's still stuff in the cache: " << lru.lru_get_size() << endl; - //show_cache(); - //dump(); + mds->handle_shutdown_finish(NULL); } - return false; + return true; } diff --git a/ceph/mds/MDStore.cc b/ceph/mds/MDStore.cc index f729130557f23..c04925446c3b4 100644 --- a/ceph/mds/MDStore.cc +++ b/ceph/mds/MDStore.cc @@ -419,7 +419,7 @@ void MDStore::do_commit_dir( CDir *dir, mds->filer->write( dir->ino(), fin->bl.length(), 0, fin->bl, - 0, // flags + 0, //OSD_OP_FLAGS_TRUNCATE, // truncate file/object after end of this write fin ); } @@ -603,13 +603,12 @@ void MDStore::do_fetch_dir_2( bufferlist& bl, // do it dout(7) << *mds << "do_fetch_dir_2 hashcode " << hashcode << " dir " << *dir << endl; - + // parse buffer contents into cache + cout << "bl is " << bl << endl; size_t size; bl.copy(0, sizeof(size), (char*)&size); - assert(bl.length() == size + sizeof(size)); - - //cout << "bl is " << bl << endl; + assert(bl.length() >= size + sizeof(size)); int n; bl.copy(sizeof(size), sizeof(n), (char*)&n); diff --git a/ceph/messages/MOSDOp.h b/ceph/messages/MOSDOp.h index b30ea0c5deef4..5a351eff9e400 100644 --- a/ceph/messages/MOSDOp.h +++ b/ceph/messages/MOSDOp.h @@ -11,12 +11,15 @@ * */ -#define OSD_OP_STAT 1 -#define OSD_OP_DELETE 2 -#define OSD_OP_ZERORANGE 3 -#define OSD_OP_MKFS 10 -#define OSD_OP_READ 20 -#define OSD_OP_WRITE 21 +#define OSD_OP_READ 1 +#define OSD_OP_WRITE 2 +#define OSD_OP_STAT 10 +#define OSD_OP_DELETE 11 +#define OSD_OP_TRUNCATE 12 +#define OSD_OP_ZERORANGE 13 +#define OSD_OP_MKFS 20 + +#define OSD_OP_FLAG_TRUNCATE 1 // truncate object after end of write typedef struct { long tid; diff --git a/ceph/osd/OSD.cc b/ceph/osd/OSD.cc index 40ee79bbb6a25..dda5d72b27e6c 100644 --- a/ceph/osd/OSD.cc +++ b/ceph/osd/OSD.cc @@ -242,6 +242,18 @@ void OSD::handle_op(MOSDOp *op) delete op; break; + case OSD_OP_TRUNCATE: + { + int r = store->truncate(op->get_oid(), op->get_offset()); + dout(3) << "truncate on " << op->get_oid() << " at " << op->get_offset() << " r = " << r << endl; + + // "ack" + messenger->send_message(new MOSDOpReply(op, r, osdcluster), + op->get_asker()); + } + delete op; + break; + case OSD_OP_STAT: { struct stat st; @@ -322,6 +334,15 @@ void OSD::op_write(MOSDOp *m) assert(r >= 0); } } + + // trucnate after? + /* + if (m->get_flags() & OSD_OP_FLAG_TRUNCATE) { + size_t at = m->get_offset() + m->get_length(); + int r = store->truncate(m->get_oid(), at); + dout(7) << "truncating object after tail of write at " << at << ", r = " << r << endl; + } + */ // assume success. FIXME. diff --git a/ceph/osdc/Filer.h b/ceph/osdc/Filer.h index cbb0bf5a2a7ae..edda0b7a851b1 100644 --- a/ceph/osdc/Filer.h +++ b/ceph/osdc/Filer.h @@ -29,8 +29,11 @@ class Context; class Messenger; class OSDCluster; +/*** types ***/ typedef __uint64_t tid_t; +#define FILER_FLAG_TRUNCATE_AFTER_WRITE 1 + /*** track pending operations ***/ typedef struct { diff --git a/ceph/test/fakemds.cc b/ceph/test/fakemds.cc index 3564477909efe..ebd2b737b99ed 100644 --- a/ceph/test/fakemds.cc +++ b/ceph/test/fakemds.cc @@ -30,16 +30,14 @@ __uint64_t ino = 1; // this parses find output int play(); -int main(int argc, char **argv) { +int main(int oargc, char **oargv) { cerr << "hi there" << endl; - - if (argc > 1) { - int d = atoi(argv[1]); - if (d > 0) - g_conf.debug = d; - cerr << " debug level " << d << endl; - } + int argc; + char **argv; + parse_config_options(oargc, oargv, + argc, argv); + MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // local config settings -- 2.39.5