]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Mon, 13 Jun 2005 04:22:29 +0000 (04:22 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Mon, 13 Jun 2005 04:22:29 +0000 (04:22 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@299 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/config.cc
ceph/fakefuse.cc
ceph/mds/MDCache.cc
ceph/mds/MDStore.cc
ceph/messages/MOSDOp.h
ceph/osd/OSD.cc
ceph/osdc/Filer.h
ceph/test/fakemds.cc

index 5e34c027b162d7c688b2d81043684c30995b8a33..0925e8570a9429f8380475271259893d04e2114e 100644 (file)
@@ -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,
 
 
index 3223cd1e820dd150ae666ec0e0ca562195899a2b..9e5315f49754241607548300feb6c5d28fca7512 100644 (file)
@@ -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
index 69dc3d9eadf080c58206df2f42195b3148660f51..cc0ccc31de792882925d38aac1441eb1bcfd044b 100644 (file)
@@ -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;
 }
 
 
index f729130557f23471163287d7f8fea8ed99917c6a..c04925446c3b4840583792784b5f8c0134d25e58 100644 (file)
@@ -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);
index b30ea0c5deef48022d08255ccee6565f29d2d7d5..5a351eff9e400d4c366951698b593a8c512833e6 100644 (file)
  *
  */
 
-#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;
index 40ee79bbb6a25a02c6b23109bb85335eb2bae1d6..dda5d72b27e6c3c16cbbb38f1ce4f42a9ea38213 100644 (file)
@@ -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.
 
index cbb0bf5a2a7ae2ddae464f53e259828b74c89697..edda0b7a851b198431b8fd0b0e849bbf97f3bc7a 100644 (file)
@@ -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 {
index 3564477909efe63123becf7d25da369ac346bf8e..ebd2b737b99edd696f253141fab4e5ae36043867 100644 (file)
@@ -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