]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 30 Apr 2005 05:26:32 +0000 (05:26 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Sat, 30 Apr 2005 05:26:32 +0000 (05:26 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@184 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/Makefile
ceph/client/Client.cc
ceph/client/Client.h
ceph/config.cc
ceph/mds/CDir.cc
ceph/mds/MDCache.cc
ceph/msg/CheesySerializer.cc
ceph/msg/FakeMessenger.cc
ceph/msg/MPIMessenger.h
ceph/msg/Messenger.h
ceph/msg/Semaphore.h

index 0e9320240acb5bdb1a1b706a6802f4d2d6fc5139..586e8865354d52416570746558e9d5838ba59aaa 100644 (file)
@@ -49,8 +49,8 @@ import: pmds.o msg/FakeMessenger.o import.cc
 mpitest: mpitest.o msg/MPIMessenger.cc pmds.o
        ${MPICC} ${CFLAGS} ${MPILIBS} mpitest.o msg/MPIMessenger.cc pmds.o  -o mpitest
 
-singleclient: pmds.o fakesingleclient.o client/Client.o msg/CheesySerializer.o msg/FakeMessenger.o 
-       ${CC} ${CFLAGS} ${LIBS} pmds.o client/Client.o msg/FakeMessenger.o msg/CheesySerializer.o fakesingleclient.o ${LEAKTRACER} -o singleclient
+singleclient: pmds.o fakesingleclient.o client/Client.o msg/CheesySerializer.o msg/FakeMessenger.o fsck.o
+       ${CC} ${CFLAGS} ${LIBS} pmds.o client/Client.o msg/FakeMessenger.o msg/CheesySerializer.o fakesingleclient.o fsck.o ${LEAKTRACER} -o singleclient
 
 fuseclient: client/Client.o client/fuse.o msg/CheesySerializer.o msg/FakeMessenger.o 
        ${CC} ${CFLAGS} ${LIBS} pmds.o client/fuse.o client/Client.o msg/FakeMessenger.o msg/CheesySerializer.o ${LEAKTRACER} -o fuseclient
index 0e8d07ce45e83a321a01a4c93ee4a66ae1c34b71..b62983f0b3aa1033200a7441e182ea84a79402b3 100644 (file)
@@ -262,18 +262,33 @@ int Client::utime(const char *path, struct utimbuf *buf)
 
 // fyi: typedef int (*dirfillerfunc_t) (void *handle, const char *name, int type, inodeno_t ino);
 
-int Client::getdir(const char *path, map<string,inode_t*> contents) 
+int Client::getdir(const char *path, map<string,inode_t*>& contents) 
 {
+  MClientRequest *req = new MClientRequest(MDS_OP_READDIR, whoami);
+  req->set_path(path); 
+
+  // FIXME where does FUSE maintain user information
+  req->set_caller_uid(getuid());
+  req->set_caller_gid(getgid());
+
+  //FIXME enforce caller uid rights?
+   
+  MClientReply *reply = (MClientReply*)serial_messenger->sendrecv(req, MSG_ADDR_MDS(0), MDS_PORT_SERVER);
+  int res = reply->get_result();
 
-  // ...
-  int res; 
+  // dir contents to caller!
+  vector<c_inode_info*>::iterator it;
+  for (it = reply->get_dir_contents().begin(); 
+          it != reply->get_dir_contents().end(); 
+          it++) {
+       // put in cache
 
-  // return contents to caller
-  /*
-  for (...) {
-    
-    contents[dentryname] = inodeptr;   // ptr to inode_t in our cache
+    contents[(*it)->ref_dn] = &(*it)->inode;   // FIXME don't use one from reply!
   }
-  */
+
+  //delete reply;     fix thing above first
   return res;
 }
+
+
+
index 6247d101444a58ab3d3e2a2a2094018e54810030..d8af0896757467f48b5797dcfdee811924183449 100644 (file)
@@ -206,7 +206,7 @@ class Client : public Dispatcher {
   int statfs(const char *path, struct statfs *stbuf);
 
   // namespace ops
-  int getdir(const char *path, map<string,inode_t*> contents);
+  int getdir(const char *path, map<string,inode_t*>& contents);
   int link(const char *existing, const char *newname);
   int unlink(const char *path);
   int rename(const char *from, const char *to);
index a9c200b2ac55cddaf8a17ccf9036226a2045e7ad..4dafcd1d505f25b0fa87112640d0100b3922ff6b 100644 (file)
@@ -33,7 +33,7 @@ md_config_t g_conf = {
   fake_clock: true,
   fakemessenger_serialize: true,// false,
 
-  debug: 14,
+  debug: 10,
 
   mdcache_size: 500, //MDS_CACHE_SIZE,
   mdcache_mid: .8,
@@ -56,12 +56,12 @@ md_config_t g_conf = {
   client_op_chown:    10,   // untested
 
   client_op_readdir:  10,
-  client_op_mknod:    10,
+  client_op_mknod:    100,
   client_op_link:       false,
   client_op_unlink:   10,
-  client_op_rename:   100,
+  client_op_rename:   00,
 
-  client_op_mkdir:    10,
+  client_op_mkdir:    100,
   client_op_rmdir:    10,
   client_op_symlink:  10,
 
index dcb8b403ea74fd9eccdf370fcfc52d9a3ec0a74a..f78ed7cb7a76bc3d8704ccf7013bfe9069ae7aee 100644 (file)
@@ -154,7 +154,7 @@ CDentry* CDir::add_dentry( const string& dname, CInode *in )
        nnull++;
   }
 
-  dout(10) << "add_dentry " << *dn << endl;
+  dout(12) << "add_dentry " << *dn << endl;
 
   // pin?
   if (nnull + nitems == 1) get(CDIR_PIN_CHILD);
@@ -168,7 +168,7 @@ CDentry* CDir::add_dentry( const string& dname, CInode *in )
 
 void CDir::remove_dentry(CDentry *dn) 
 {
-  dout(10) << "remove_dentry " << *dn << endl;
+  dout(12) << "remove_dentry " << *dn << endl;
 
   if (dn->inode) {
        // detach inode and dentry
@@ -197,7 +197,7 @@ void CDir::remove_dentry(CDentry *dn)
 void CDir::link_inode( CDentry *dn, CInode *in )
 {
   link_inode_work(dn,in);
-  dout(10) << "link_inode " << *dn << " " << *in << endl;
+  dout(12) << "link_inode " << *dn << " " << *in << endl;
   
   // remove from null list
   assert(null_items.count(dn->name) == 1);
@@ -231,7 +231,7 @@ void CDir::link_inode_work( CDentry *dn, CInode *in )
 
 void CDir::unlink_inode( CDentry *dn )
 {
-  dout(10) << "unlink_inode " << *dn << " " << *dn->inode << endl;
+  dout(12) << "unlink_inode " << *dn << " " << *dn->inode << endl;
 
   unlink_inode_work(dn);
 
index 25b9e59aaa9f7fd652e1aba4eae6bdec87c82e98..35211f10a0c2124dc54d631b730c39ca42d514ff 100644 (file)
@@ -770,7 +770,7 @@ class C_MDC_TraverseDiscover : public Context {
        this->onfinish = onfinish;
   }
   void finish(int r) {
-       cout << "TraverseDiscover r = " << r << endl;
+       //dout(10) << "TraverseDiscover r = " << r << endl;
        if (r < 0) {            // ENOENT on discover, pass back to caller.
          onfinish->finish(r);
        } else {
index 5e389bd74cb7b8f79174d6bfb248db7773b33620..6d01c8db6567a94ae1d73dc2cc09fc37ba91eb69 100644 (file)
@@ -6,6 +6,11 @@
 #include <iostream>
 using namespace std;
 
+#include "include/config.h"
+#undef dout
+#define  dout(l)    if (l<=g_conf.debug) cout << "serializer: "
+
+#define DEBUGLVL  13    // debug level of output
 
 // ---------
 // incoming messages
@@ -19,14 +24,15 @@ void CheesySerializer::dispatch(Message *m)
   // was i expecting it?
   if (call_sem.count(tid)) {
        // yes, this is a reply to a pending call.
-       cout << "serializer: dispatch got reply for " << tid << " " << m << endl;
+       dout(DEBUGLVL) << "dispatch got reply for " << tid << " " << m << endl;
        call_reply[tid] = m;     // set reply
-       call_sem[tid]->Post();
+       int r = call_sem[tid]->Post();
+       //cout << "post = " << r << endl;
        lock.Unlock();
   } else {
        // no, this is an unsolicited message.
        lock.Unlock();  
-       cout << "serializer: dispatch got unsolicited message" << m << endl;
+       dout(DEBUGLVL) << "dispatch got unsolicited message" << m << endl;
        dispatcher->dispatch(m);
   }
 }
@@ -38,13 +44,14 @@ void CheesySerializer::dispatch(Message *m)
 void CheesySerializer::send(Message *m, msg_addr_t dest, int port, int fromport)
 {
   // just pass it on to the messenger
-  cout << "serializer: send " << m << endl;
+  dout(DEBUGLVL) << "send " << m << endl;
   messenger->send_message(m, dest, port, fromport);
 }
 
 Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port, int fromport)
 {
-  Semaphore *sem = new Semaphore();
+  static Semaphore stsem;
+  Semaphore *sem = &stsem;//new Semaphore();
 
   // make up a transaction number that is unique (to me!)
   /* NOTE: since request+replies are matched up on tid's alone, it means that
@@ -56,7 +63,7 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port, int f
   long tid = ++last_tid;
   m->set_tid(tid);
 
-  cout << "serializer: sendrecv sending " << m << " on tid " << tid << endl;
+  dout(DEBUGLVL) << "sendrecv sending " << m << " on tid " << tid << endl;
 
   // add call records
   lock.Lock();
@@ -69,9 +76,11 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port, int f
   messenger->send_message(m, dest, port, fromport);
   
   // wait
-  cout << "serializer: sendrecv waiting for reply on tid " << tid << endl;
+  dout(DEBUGLVL) << "sendrecv waiting for reply on tid " << tid << endl;
+  //cout << "wait start, value = " << sem->Value() << endl;
   sem->Wait();
 
+
   // pick up reply
   lock.Lock();
   Message *reply = call_reply[tid];
@@ -80,9 +89,9 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port, int f
   call_sem.erase(tid);
   lock.Unlock();
 
-  delete sem;
+  dout(DEBUGLVL) << "sendrecv got reply " << reply << " on tid " << tid << endl;
+  //delete sem;
   
-  cout << "serializer: sendrecv got reply " << reply << " on tid " << tid << endl;
   return reply;
 }
 
index 43f02975924f82619099939af0e9562c7aa37c07..dc73b81e4c5bc23e538ee377e8bdd8820d20a3d9 100644 (file)
@@ -32,7 +32,7 @@ map<int, FakeMessenger*> directory;
 hash_map<int, Logger*>        loggers;
 LogType fakemsg_logtype;
 
-
+Mutex lock;
 Semaphore sem;
 Semaphore shutdownsem;
 bool      awake = false;
@@ -81,6 +81,8 @@ int fakemessenger_do_loop()
        
        dout(11) << "do_loop top" << endl;
 
+       lock.Lock();
+
        map<int, FakeMessenger*>::iterator it = directory.begin();
        while (it != directory.end()) {
          Message *m = it->second->get_message();
@@ -109,15 +111,24 @@ int fakemessenger_do_loop()
                  }
                }
                
+               lock.Unlock();
+
                didone = true;
                it->second->dispatch(m);
+
+               lock.Lock();
          }
          it++;
        }
 
+       lock.Unlock();
+
+
        if (!didone)
          break;
   }
+
+
   dout(1) << "do_loop end (no more messages)." << endl;
   return 0;
 }
@@ -177,6 +188,8 @@ int FakeMessenger::send_message(Message *m, msg_addr_t dest, int port, int fromp
   m->set_source(whoami, fromport);
   m->set_dest(dest, port);
 
+  lock.Lock();
+
   // deliver
   try {
 #ifdef LOG_MESSAGES
@@ -209,6 +222,8 @@ int FakeMessenger::send_message(Message *m, msg_addr_t dest, int port, int fromp
        awake = true;
        sem.Post();
   }
+
+  lock.Unlock();
 }
 
 int FakeMessenger::wait_message(time_t seconds)
index ac7175f2e4b6aa7938f90ba3252b7ba7997b4698..cc4a743a914a188b72731e2bafc3e23c3c0ffaa4 100644 (file)
@@ -8,7 +8,7 @@
 #define NUMOSD g_conf.num_osd
 #define MPI_DEST_TO_RANK(dest,world)    ((dest)<(NUMMDS+NUMOSD) ? \
                                                                                 (dest) : \
-                                                                                ((NUMMDS+NUMOSD)+(((dest)-NUMMDS-NUMOSD) % (world-NUMMDS-NUMOSD))))
+                                                                                ((NUMMDS+NUMOSD)+(((dest)-NUMMDS-NUMOSD) % ((world)-NUMMDS-NUMOSD))))
 
 
 class MPIMessenger : public Messenger {
index 1ccb9374d20be89ff6c715275ca55b816482eb51..9add1211630315a8a25d2930a9bec2406bcd52b4 100644 (file)
@@ -57,7 +57,7 @@ class Messenger {
   // incoming queue
   Message *get_message() {
        if (incoming.size() > 0) {
-         cout << incoming.size() << " messages, taking first" << endl;
+         //cout << incoming.size() << " messages, taking first" << endl;
          Message *m = incoming.front();
          incoming.pop_front();
          return m;
index 9ca414ada1cff414786b49c4eaf139d82f5b605e..b15d47309adaf25a94dcb53e775a6bbebe5fec94 100755 (executable)
 
 #include <semaphore.h>
 #include <errno.h>
+#include <iostream>
+using namespace std;
 
 class Semaphore
 {
   sem_t S;
 
   public:
-  Semaphore( int init = 0 )
-  { sem_init(&S,0,init); }
-
-  virtual ~Semaphore()
-  { sem_destroy(&S); }
-
-  void Wait() const
-  { sem_wait((sem_t *)&S); }
+  Semaphore( int init = 0 ) { 
+       int r = sem_init(&S,0,init); 
+       //cout << "sem_init = " << r << endl;
+  }
+
+  virtual ~Semaphore() { 
+       int r = sem_destroy(&S); 
+       //cout << "sem_destroy = " << r << endl;
+  }
+
+  void Wait() const {
+       while (1) {
+         int r = sem_wait((sem_t *)&S); 
+         if (r == 0) break;
+         cout << "sem_wait returned " << r << ", trying again" << endl;
+       }
+  }
 
   int Wait_Try() const
   { return (sem_trywait((sem_t *)&S)?errno:0); }