]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 24 Feb 2006 19:54:08 +0000 (19:54 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Fri, 24 Feb 2006 19:54:08 +0000 (19:54 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@673 29311d96-e01e-0410-9327-a35deaab8ce9

16 files changed:
ceph/Makefile
ceph/TODO
ceph/client/Client.cc
ceph/client/Client.h
ceph/client/ldceph.cc
ceph/common/Timer.cc
ceph/common/Timer.h
ceph/config.cc
ceph/config.h
ceph/mds/CInode.h
ceph/messages/MClientReply.h
ceph/msg/TCPDirectory.h
ceph/msg/TCPMessenger.cc
ceph/msg/TCPMessenger.h
ceph/osd/OSD.cc
ceph/tcpfuse.cc

index 8f55f9af229610c44987b125e5d89b3769dd41f0..93f70f39ec683884a6a41e2d26d3f60f47e19eba 100644 (file)
@@ -39,7 +39,6 @@ MDS_OBJS= \
        mds/LogStream.o\
        mds/IdAllocator.o\
        mds/MDLog.o\
-       mds/MDCluster.o\
        mds/OSDMonitor.o
 
 COMMON_OBJS= \
@@ -52,6 +51,7 @@ COMMON_OBJS= \
        osd/OSDMap.o\
        osd/PG.o\
        osd/ObjectStore.o\
+       mds/MDCluster.o\
        ebofs.o\
        common/Logger.o\
        common/Clock.o\
@@ -66,7 +66,7 @@ TCP_OBJS = \
        msg/TCPMessenger.o\
        msg/TCPDirectory.o
 
-TARGETS = fakefuse fakesyn tcpsyn tcpfuse client/ldceph.o
+TARGETS = fakefuse fakesyn tcpsyn tcpfuse libceph.o
 
 SRCS=*.cc */*.cc
 
@@ -146,6 +146,10 @@ test.ebofs: ebofs/test.ebofs.cc config.cc common/Clock.o ebofs.o
 ebofs: mkfs.ebofs test.ebofs
 
 
+# libceph
+libceph.o: client/ldceph.o client/Client.o client/Buffercache.o ${TCP_OBJS} ${COMMON_OBJS} ${SYN_OBJS}
+       ld -i ${LIBS} $^ -o $@
+
 #
 
 %.so: %.cc
@@ -168,6 +172,9 @@ mds.o: ${MDS_OBJS}
 %.o: %.cc
        ${CC} ${CFLAGS} -c $< -o $@
 
+%.po: %.cc
+       ${CC} -fPIC ${CFLAGS} -c $< -o $@
+
 count:
        cat *.cc */*.cc */*.h */*/*.h | wc -l
        cat *.cc */*.cc */*.h */*/*.h | grep -c \;
index f85d7269f7d59156180b790db9ca94d907f34cf1..67916fd21e885286e161b2b9fa7077d85223dcd5 100644 (file)
--- a/ceph/TODO
+++ b/ceph/TODO
@@ -10,6 +10,10 @@ llnl direct deposit  fax 925 424 2663
 
 MAR 1
 
+- aged object stores on googoo
+
+- confirm block dev versus big file
+
 - ldceph + mdtest
 
 - stability
index 3fbb46aa0fa715477068b7ae4ae08363e0ae8f24..424936dfc7c5f1cb8d092b97ee28bb1bd1534bc8 100644 (file)
@@ -328,6 +328,7 @@ void Client::insert_trace(const vector<c_inode_info*>& trace)
          root->last_updated = now;
 
          root->dir_auth = in_info->dir_auth;
+         assert(root->dir_auth == 0);
          root->dir_hashed = in_info->hashed;  
          root->dir_replicated = in_info->replicated;  
          if (in_info->spec_defined) 
@@ -446,6 +447,7 @@ MClientReply *Client::make_request(MClientRequest *req,
                mds = diri->pick_replica(mdcluster);
        }
   }
+  //cout << "mds is " << mds << endl;
 
   // force use of a particular mds?
   if (use_mds >= 0) mds = use_mds;
index 207a49c5c136ec4800e0ccf7e804d0450958ce56..31bed051a9f35b4e9b6e7425e444c7f2cb89ca2d 100644 (file)
@@ -184,6 +184,7 @@ class Inode {
   }
 
   int authority(MDCluster *mdcluster) {
+       //cout << "authority on " << inode.ino << " .. dir_auth is " << dir_auth<< endl;
        // parent?
        if (dn && dn->dir && dn->dir->parent_inode) {
          // parent hashed?
@@ -213,6 +214,7 @@ class Inode {
   int pick_replica(MDCluster *mdcluster) {
        // replicas?
        if (dir_contacts.size()) {
+         cout << "dir_contacts if " << dir_contacts << endl;
          set<int>::iterator it = dir_contacts.begin();
          if (dir_contacts.size() == 1)
                return *it;
@@ -223,8 +225,10 @@ class Inode {
          }
        }
 
-       if (dir_replicated) 
+       if (dir_replicated) {
+         cout << "num_mds is " << mdcluster->get_num_mds() << endl;
          return rand() % mdcluster->get_num_mds();  // huh.. pick a random mds!
+       }
        else
          return authority(mdcluster);
   }
index 9af26b9445f75b14fed6ba9ae359c6fd74300b91..1f29bfa38104aaf35e11cd64f84b5be224bea53e 100644 (file)
@@ -123,7 +123,20 @@ public:
        mount_point(0), mount_point_parent(0),
        mount_point_len(0),
        cwd_above_mp(false), cwd_in_mp(false) {
-       
+
+       // args
+       vector<char *> args;
+       env_to_vec(args);
+       parse_config_options(args);
+  
+
+       tcpaddr_t nsa;
+       if (tcpmessenger_findns(nsa) < 0) 
+         return;
+       tcpmessenger_init();
+       tcpmessenger_start();
+       tcpmessenger_start_rankserver(nsa);
+
        client = new Client(new TCPMessenger(MSG_ADDR_CLIENT_NEW));
        client->init();
        int r = client->mount();
@@ -142,10 +155,20 @@ public:
          fp_mount_point = mount_point;
 
          cerr << "ldceph mounted on " << mount_point << " as " << client->get_myaddr() << endl;
+
+         refresh_cwd();
        }
   }
   ~LdCeph() {
        cout << "ldceph fini" << endl;
+       if (false && client) {   // no unmount for now..
+         client->unmount();
+         client->shutdown();
+         delete client;
+         client = 0;
+         tcpmessenger_wait();
+         tcpmessenger_shutdown(); 
+       }
   }    
 
 } ldceph;
@@ -215,7 +238,7 @@ extern "C" {
   }
   int mkdir(const char *pathname, mode_t mode) {
        char buf[255];
-       if (const char *c = ldceph.get_ceph_path(pathname, buf))
+       if (const char *c = ldceph.get_ceph_path(pathname, buf)) 
          return ldceph.client->mkdir(c, mode);
        else
          return syscall(SYS_mkdir, pathname, mode);
@@ -228,8 +251,9 @@ extern "C" {
          return syscall(SYS_unlink, pathname);
   }
 
-  //int stat(const char *pathname, struct stat *st) {
-  int __xstat(int __ver, const char *pathname, struct stat *st) {  // stoopid GLIBC
+  int stat(const char *pathname, struct stat *st) {
+       //int __xstat64(int __ver, const char *pathname, struct stat64 *st64) {  // stoopid GLIBC
+       //struct stat *st = (struct stat*)st64;
        char buf[255];
        if (const char *c = ldceph.get_ceph_path(pathname, buf))
          return ldceph.client->lstat(c, st);   // FIXME
@@ -243,7 +267,7 @@ extern "C" {
        char buf[255];
        if (const char *c = ldceph.get_ceph_path(pathname, buf)) {
          int r = ldceph.client->chdir(c);
-         if (r) {
+         if (r == 0) {
                if (!ldceph.cwd_in_mp)
                  syscall(SYS_chdir, ldceph.mount_point_parent);
                ldceph.cwd_in_mp = true;
index c40f1c5897ed854425dc980af620dd6377e8a384..c02d3092cb3fe730b425cb4d322f8fb57de720c9 100644 (file)
@@ -70,7 +70,7 @@ void Timer::timer_thread()
                if (it->first > now) break;
 
                utime_t t = it->first;
-               dout(DBL) << "queuing event(s) scheduled at " << t << endl;
+               dout(DBL) << "queueing event(s) scheduled at " << t << endl;
 
                if (messenger) {
                  for (set<Context*>::iterator cit = it->second.begin();
@@ -78,6 +78,7 @@ void Timer::timer_thread()
                           cit++) {
                        pending.push_back(*cit);
                        event_times.erase(*cit);
+                       num_event--;
                  }
                }
 
@@ -92,8 +93,10 @@ void Timer::timer_thread()
                { // make sure we're not holding any locks while we talk to the messenger
                  for (list<Context*>::iterator cit = pending.begin();
                           cit != pending.end();
-                          cit++)
+                          cit++) {
+                       dout(DBL) << "queue callback " << *cit << endl;
                        messenger->queue_callback(*cit);
+                 }
                  pending.clear();
                }
                lock.Lock();
@@ -198,6 +201,8 @@ void Timer::add_event_at(utime_t when,
   scheduled[ when ].insert(callback);
   event_times[callback] = when;
   
+  num_event++;
+
   // make sure i wake up
   register_timer();
 
index 7bf5c997e360f83390ee91e63c0ba878cfce2ec5..e1ceb392355d280b8eb40b1ba3fb6ea71aa2eced 100644 (file)
@@ -64,19 +64,25 @@ class Timer {
   void register_timer();  // make sure i get a callback
   void cancel_timer();    // make sure i get a callback
 
+
   pthread_t thread_id;
   bool      thread_stop;
   Mutex     lock;
   bool      timed_sleep;
   Cond      sleep_cond;
   Cond      timeout_cond;
+
  public:
   void timer_thread();    // waiter thread (that wakes us up)
 
+  int num_event;
+
+
  public:
   Timer() { 
        thread_id = 0;
        thread_stop = false;
+       num_event = 0;
   }
   ~Timer() { 
        // scheduled
index ff066042b37eef9db0b5373426f7f2b9591d85e8..51713aad8a238d721789d78177e702f9bab350e3 100644 (file)
@@ -222,6 +222,31 @@ md_config_t g_conf = {
 using namespace std;
 
 
+void env_to_vec(vector<char*>& args) 
+{
+  const char *p = getenv("CEPH_ARGS");
+  if (!p) return;
+  
+  static char buf[1000];  
+  int len = strlen(p);
+  memcpy(buf, p, len);
+  buf[len] = 0;
+  cout << "args " << buf << endl;
+
+  int l = 0;
+  for (int i=0; i<len; i++) {
+       if (buf[i] == ' ') {
+         buf[i] = 0;
+         args.push_back(buf+l);
+         cout << "arg " << (buf+l) << endl;
+         l = i+1;
+       }
+  }
+  args.push_back(buf+l);
+  cout << "arg " << (buf+l) << endl;
+}
+
+
 void argv_to_vec(int argc, char **argv,
                                 vector<char*>& args)
 {
index a1e86468aa9139095f167704d458ebbd852df559..6dd4e7b94e49f6480dada66632e5106593c47149 100644 (file)
@@ -190,6 +190,7 @@ extern md_config_t g_debug_after_conf;
 #define dout(x)  if ((x) <= g_conf.debug) cout
 #define dout2(x) if ((x) <= g_conf.debug) cout
 
+void env_to_vec(vector<char*>& args);
 void argv_to_vec(int argc, char **argv,
                                 vector<char*>& args);
 void vec_to_argv(vector<char*>& args,
index 55842885a0b7c160aaa88c231a50cdef8f2fa4ef..95524c44012a5f3b0f9daa90c29aa8402a4ac319 100644 (file)
@@ -20,7 +20,7 @@
 #include "include/types.h"
 #include "include/lru.h"
 #include "common/DecayCounter.h"
-#include <sys/stat.h>
+//#include <sys/stat.h>
 
 #include "CDentry.h"
 #include "Lock.h"
index 0b665cc0855414e9c9e39c434c988aedede279d4..d12f2c41d8dddfe63cd899088e11efac00354408 100644 (file)
@@ -84,8 +84,12 @@ class c_inode_info {
        } else 
          spec_defined = false;
 
+       if (in->dir)
+         dir_auth = in->dir->get_dir_auth();
+       else
+         dir_auth = -1;
+
        // dir info
-       dir_auth = (in->dir && in->dir->get_dir_auth());
        hashed = (in->dir && in->dir->is_hashed());   // FIXME not quite right.
        replicated = (in->dir && in->dir->is_rep());
   }
index 08e907820f1d4e8435dbd76283bef35f1b835f63..f7f0802032cf7f446e1fb0fa5e771dc249a5ee95 100644 (file)
@@ -31,7 +31,7 @@ using namespace std;
 using namespace __gnu_cxx;
 
 #include <sys/types.h>
-#include <sys/stat.h>
+//#include <sys/stat.h>
 #include <fcntl.h>
 
 class TCPDirectory : public Dispatcher {
index 9dbfb549d25e6398a1c3c7a2a70b9504d046b69a..8d9112e8b453a8fbcd9a176fd7d43998e34382ec 100644 (file)
@@ -140,6 +140,50 @@ int tcpmessenger_get_rank()
 }
 
 
+int tcpmessenger_findns(tcpaddr_t &nsa)
+{
+  char *nsaddr = 0;
+  bool have_nsa = false;
+
+  // env var?
+  /*int e_len = 0;
+  for (int i=0; envp[i]; i++)
+       e_len += strlen(envp[i]) + 1;
+  */
+  nsaddr = getenv("CEPH_NAMESERVER");////envz_entry(*envp, e_len, "CEPH_NAMESERVER");  
+  if (nsaddr) {
+       while (nsaddr[0] != '=') nsaddr++;
+       nsaddr++;
+  }
+
+  else {
+       // file?
+       int fd = ::open(".ceph_ns",O_RDONLY);
+       if (fd > 0) {
+         ::read(fd, (void*)&nsa, sizeof(nsa));
+         ::close(fd);
+         have_nsa = true;
+         nsaddr = "from .ceph_ns";
+       }
+  }
+
+  if (!nsaddr && !have_nsa) {
+       cerr << "i need ceph ns addr.. either CEPH_NAMESERVER env var or --ns blah" << endl;
+       return -1;
+       //exit(-1);
+  }
+  
+  // look up nsaddr?
+  if (!have_nsa && tcpmessenger_lookup(nsaddr, nsa) < 0) {
+       return -1;
+  }
+
+  cout << "ceph ns is " << nsaddr << " or " << nsa << endl;
+  return 0;
+}
+
+
+
 /** rankserver
  *
  * one per rank.  handles entity->rank lookup replies.
index 00a552ed7d448e78dae9e6157eae01ae971dfec4..da5391a053cf5fcd252ba9481193310f49d61662 100644 (file)
@@ -56,6 +56,8 @@ class TCPMessenger : public Messenger {
 
 extern int tcpmessenger_lookup(char *str, tcpaddr_t& ta);
 
+extern int tcpmessenger_findns(tcpaddr_t &nsa);
+
 extern int tcpmessenger_init();
 extern int tcpmessenger_start();   // start thread
 extern void tcpmessenger_wait();    // wait for thread to finish.
index 196b58c752fa8c9f9e0ea775cf844425f8c5eb51..8574bcb728132ed49be9e5f6da914382ef72b63e 100644 (file)
@@ -211,7 +211,7 @@ int OSD::init()
 
 int OSD::shutdown()
 {
-  dout(1) << "shutdown" << endl;
+  dout(1) << "shutdown, timer has " << g_timer.num_event << endl;
 
   // finish ops
   wait_for_no_ops();
index cebfd124ebf4a2a2c0594250e4012e80b31fd210..68d181b9f43f700d4582fa62f5c8bc96cec86db5 100644 (file)
@@ -30,64 +30,12 @@ int main(int argc, char **argv, char *envp[]) {
   argv_to_vec(argc, argv, args);
   parse_config_options(args);
 
-  vector<char*> nargs;
-  
-  char *nsaddr = 0;
-  tcpaddr_t nsa;
-  bool have_nsa = false;
-
-  for (unsigned i=0; i<args.size(); i++) {
-       if (strcmp(args[i], "--ns") == 0) {
-         nsaddr = args[++i];
-       }
-       else {
-         // unknown arg, pass it on.
-         nargs.push_back(args[i]);
-         cout << "fuse arg: " << args[i] << endl;
-       }
-  }
-  
-  if (nsaddr == 0) {
-       // env var?
-       int e_len = 0;
-       for (int i=0; envp[i]; i++)
-         e_len += strlen(envp[i]) + 1;
-       nsaddr = envz_entry(*envp, e_len, "CEPH_NAMESERVER");   
-       if (nsaddr) {
-         while (nsaddr[0] != '=') nsaddr++;
-         nsaddr++;
-       }
-  }
-
-  if (!nsaddr) {
-       // file?
-       int fd = ::open(".ceph_ns",O_RDONLY);
-       if (fd > 0) {
-         ::read(fd, (void*)&nsa, sizeof(nsa));
-         ::close(fd);
-         have_nsa = true;
-         nsaddr = "from .ceph_ns";
-       }
-  }
-
-  if (!nsaddr && !have_nsa) {
-       cerr << "i need ceph ns addr.. either CEPH_NAMESERVER env var or --ns blah" << endl;
-       exit(-1);
-  }
-
-  // look up nsaddr?
-  if (!have_nsa && tcpmessenger_lookup(nsaddr, nsa) < 0) {
-       return 1;
-  }
-
-  cout << "ceph ns is " << nsaddr << " or " << nsa << endl;
-
   // args for fuse
-  args = nargs;
   vec_to_argv(args, argc, argv);
 
-
   // start up tcpmessenger
+  tcpaddr_t nsa;
+  if (tcpmessenger_findns(nsa) < 0) exit(1);
   tcpmessenger_init();
   tcpmessenger_start();
   tcpmessenger_start_rankserver(nsa);