]> 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 19:17:33 +0000 (19:17 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Mon, 13 Jun 2005 19:17:33 +0000 (19:17 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@306 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/Makefile
ceph/TODO
ceph/client/Client.cc
ceph/client/Client.h
ceph/config.cc
ceph/fakesyn.cc
ceph/test/gprof-helper.c [new file with mode: 0644]

index 011828d92bd1c61ce030f9a0255c27a4ecdefd94..7d09041c071bacb6d98c738c31303b453894fc2a 100644 (file)
@@ -9,7 +9,7 @@
 # behave just fine...  change ${CC} back to mpicxx if you get paranoid.
 CC = g++
 MPICC = mpicxx
-CFLAGS = -g -I. -pg -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE
+CFLAGS = -g -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE
 LIBS = -lpthread 
 
 MDS_OBJS= \
@@ -81,10 +81,10 @@ mpisyn: mpisyn.cc mds/allmds.o client/Client.o client/SyntheticClient.o osd/OSD.
        ${MPICC} ${CFLAGS} ${LIBS} -lfuse $^ -o $@
 
 fakesyn: fakesyn.cc mds/allmds.o client/Client.o client/SyntheticClient.o osd/OSD.o msg/FakeMessenger.o msg/CheesySerializer.o ${COMMON_OBJS}
-       ${CC} ${CFLAGS} ${LIBS} $^ -o $@
+       ${CC} -pg ${CFLAGS} ${LIBS} $^ -o $@
 
 fakefuse: fakefuse.cc mds/allmds.o client/Client.o osd/OSD.o client/fuse.o msg/FakeMessenger.cc msg/CheesySerializer.o ${COMMON_OBJS}
-       ${CC} ${CFLAGS} ${LIBS} -lfuse $^ -o $@
+       ${CC} -pg ${CFLAGS} ${LIBS} -lfuse $^ -o $@
 
 clean:
        rm -f *.o */*.o ${TARGETS} ${TEST_TARGETS}
index 4a586285a172662c4e25ebea5e12d2e36f8718b6..9d6590c14767bdfbdcba78dfc312959d1593c003 100644 (file)
--- a/ceph/TODO
+++ b/ceph/TODO
@@ -3,7 +3,7 @@
 - test mds scaling w/ makedirs, vs mds_log_on_request 
 - client needs to choose MDS intelligently
 
-- finish osd replication MOSDOp groundwork
+- fix up MDLog
 
 big fast todo's:
 - client buffer cache
@@ -11,7 +11,6 @@ big fast todo's:
 - heartbeat protocol
 
 - mds benchmarks
- - synthetic client stable,
  - pseudo-mega-filesystem
    - osd copy-on-write..
 
index 1b810819e59cff96c76f08388150e6469db7ee1e..0645fca921254d11dddb491ad954b4a91eaf0a19 100644 (file)
@@ -202,8 +202,37 @@ Dentry *Client::lookup(filepath& path)
 
 // -------
 
-MClientReply *Client::make_request(MClientRequest *req, int mds)
+MClientReply *Client::make_request(MClientRequest *req)
 {
+  // send to what MDS?  find deepest known prefix
+  int mds = 0;
+  Inode *cur = root;
+  for (int i=0; i<req->get_filepath().depth(); i++) {
+       if (cur && cur->inode.mode & INODE_MODE_DIR && cur->dir) {
+         Dir *dir = cur->dir;
+         Dentry *dn;
+         if (dir->dentries.count( req->get_filepath()[i] ) == 0) 
+               break;
+         
+         dout(7) << " have path seg " << i << " " << cur->inode.ino << " " << req->get_filepath()[i] << endl;
+         cur = dir->dentries[ req->get_filepath()[i] ]->inode;
+         assert(cur);
+       } else
+         break;
+  }
+  
+  if (cur && cur->mds_contacts.size()) {
+       dout(7) << "contacting mds from deepest inode " << cur->inode.ino << " : " << cur->mds_contacts << endl;
+       set<int>::iterator it = cur->mds_contacts.begin();
+       if (cur->mds_contacts.size() == 1)
+         mds = *it;
+       else {
+         int r = rand() % cur->mds_contacts.size();
+         while (r--) it++;
+         mds = *it;
+       }
+  }
+
   // drop mutex for duration of call
   client_lock.Unlock();  
   MClientReply *reply = (MClientReply*)messenger->sendrecv(req,
@@ -409,7 +438,7 @@ int Client::link(const char *existing, const char *newname)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   
   this->insert_trace(reply->get_trace());
@@ -436,7 +465,7 @@ int Client::unlink(const char *path)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   if (res == 0) {
        //this crashes, haven't looked at why yet
@@ -467,7 +496,7 @@ int Client::rename(const char *from, const char *to)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());
   delete reply;
@@ -495,7 +524,7 @@ int Client::mkdir(const char *path, mode_t mode)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());
   delete reply;
@@ -520,7 +549,7 @@ int Client::rmdir(const char *path)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   if (res == 0) {
        // crashes, not sure why yet
@@ -552,7 +581,7 @@ int Client::symlink(const char *target, const char *link)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  //FIXME assuming trace of link, not of target
   delete reply;
@@ -613,7 +642,7 @@ int Client::lstat(const char *path, struct stat *stbuf)
        req->set_caller_uid(getuid());
        req->set_caller_gid(getgid());
        
-       MClientReply *reply = make_request(req, 0);
+       MClientReply *reply = make_request(req);
        res = reply->get_result();
        dout(10) << "lstat res is " << res << endl;
        if (res == 0) {
@@ -667,7 +696,7 @@ int Client::chmod(const char *path, mode_t mode)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -694,7 +723,7 @@ int Client::chown(const char *path, uid_t uid, gid_t gid)
 
   //FIXME enforce caller uid rights?
 
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -721,7 +750,7 @@ int Client::utime(const char *path, struct utimbuf *buf)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
   delete reply;
@@ -749,7 +778,7 @@ int Client::mknod(const char *path, mode_t mode)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   this->insert_trace(reply->get_trace());  
 
@@ -786,7 +815,7 @@ int Client::getdir(const char *path, map<string,inode_t*>& contents)
 
   //FIXME enforce caller uid rights?
    
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   int res = reply->get_result();
   vector<c_inode_info*> trace = reply->get_trace();
   this->insert_trace(trace);  
@@ -842,7 +871,7 @@ int Client::open(const char *path, int mode)
   req->set_caller_uid(getuid());
   req->set_caller_gid(getgid());
   
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   assert(reply);
   dout(3) << "open result = " << reply->get_result() << endl;
 
@@ -897,7 +926,7 @@ int Client::close(fileh_t fh)
 
   release_inode_buffers(in);
 
-  MClientReply *reply = make_request(req, 0);
+  MClientReply *reply = make_request(req);
   assert(reply);
   int result = reply->get_result();
   dout(3) << "close " << fh << " result = " << result << endl;
index b1878930632419205fe0a7554fc0af57081dc2f0..c1358c53366780b76638dd81f589fddf1401746f 100644 (file)
@@ -241,7 +241,7 @@ class Client : public Dispatcher {
 
 
   // blocking mds call
-  MClientReply *make_request(MClientRequest *req, int mds);
+  MClientReply *make_request(MClientRequest *req);
 
   
   // buffer cache
index 8e29c998249ede02f8aa5088f31597eecfbb81d6..f3f38945c46848e73216997288b21105553d9629 100644 (file)
@@ -18,7 +18,7 @@ md_config_t g_conf = {
 
   // profiling and debugging
   log_messages: true,
-  log_interval: 10,
+  log_interval: 1,
   log_name: 0,
 
   fake_clock: false,
index 6aa4f2282735c35253800b53b527d8069590da74..03592a3fcff40a557f049aee47c2356e4e781ecd 100644 (file)
@@ -46,7 +46,9 @@ int main(int oargc, char **oargv) {
   char **nargv = new pchar[argc];
   nargv[nargc++] = argv[0];
 
-  int synthetic = 100;
+  string syn_sarg1;
+  int syn_mode = SYNCLIENT_MODE_WRITEFILE;
+  int syn_iarg1, syn_iarg2, syn_iarg3;
   int mkfs = 0;
   for (int i=1; i<argc; i++) {
        if (strcmp(argv[i], "--fastmkfs") == 0) {
@@ -55,9 +57,31 @@ int main(int oargc, char **oargv) {
        else if (strcmp(argv[i], "--fullmkfs") == 0) {
          mkfs = MDS_MKFS_FULL;
        }
-       else if (strcmp(argv[i],"--synthetic") == 0) {
-         synthetic = atoi(argv[++i]);
+
+       else if (strcmp(argv[i],"--synsarg1") == 0) 
+         syn_sarg1 = argv[++i];
+       else if (strcmp(argv[i],"--syniarg1") == 0) 
+         syn_iarg1 = atoi(argv[++i]);
+       else if (strcmp(argv[i],"--syniarg2") == 0) 
+         syn_iarg2 = atoi(argv[++i]);
+       else if (strcmp(argv[i],"--syniarg3") == 0) 
+         syn_iarg3 = atoi(argv[++i]);
+       else if (strcmp(argv[i],"--synmode") == 0) {
+         ++i;
+         if (strcmp(argv[i],"writefile") == 0) 
+               syn_mode = SYNCLIENT_MODE_WRITEFILE;
+         else if (strcmp(argv[i],"makedirs") == 0) 
+               syn_mode = SYNCLIENT_MODE_MAKEDIRS;
+         else if (strcmp(argv[i],"fullwalk") == 0) 
+               syn_mode = SYNCLIENT_MODE_FULLWALK;
+         else if (strcmp(argv[i],"randomwalk") == 0) 
+               syn_mode = SYNCLIENT_MODE_RANDOMWALK;
+         else {
+               cerr << "unknown syn mode " << argv[i] << endl;
+               return -1;
+         }
        }
+
        else {
          // unknown arg, pass it on.
          nargv[nargc++] = argv[i];
@@ -123,14 +147,15 @@ int main(int oargc, char **oargv) {
        cout << "starting synthatic client  " << endl;
        syn[i] = new SyntheticClient(client[i]);
 
-       syn[i]->mode = SYNCLIENT_MODE_MAKEDIRS;
        char s[20];
        sprintf(s,"syn.%d", i);
        syn[i]->sarg1 = s;
-       syn[i]->iarg1 = 5;
-       syn[i]->iarg2 = 5;
-       syn[i]->iarg3 = 2;
-         
+       
+       syn[i]->mode = syn_mode;
+       syn[i]->iarg1 = syn_iarg1;
+       syn[i]->iarg2 = syn_iarg2;
+       syn[i]->iarg3 = syn_iarg3;
+
        syn[i]->start_thread();
   }
   for (int i=0; i<NUMCLIENT; i++) {
diff --git a/ceph/test/gprof-helper.c b/ceph/test/gprof-helper.c
new file mode 100644 (file)
index 0000000..9f013ba
--- /dev/null
@@ -0,0 +1,120 @@
+/* gprof-helper.c -- preload library to profile pthread-enabled programs
+ *
+ * Authors: Sam Hocevar <sam at zoy dot org>
+ *          Daniel Jönsson <danieljo at fagotten dot org>
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the Do What The Fuck You Want To
+ *  Public License as published by Banlu Kemiyatorn. See
+ *  http://sam.zoy.org/projects/COPYING.WTFPL for more details.
+ *
+ * Compilation example:
+ * gcc -shared -fPIC gprof-helper.c -o gprof-helper.so -lpthread -ldl
+ *
+ * Usage example:
+ * LD_PRELOAD=./gprof-helper.so your_program
+ */
+
+#define _GNU_SOURCE
+#include <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <pthread.h>
+
+static void * wrapper_routine(void *);
+
+/* Original pthread function */
+static int (*pthread_create_orig)(pthread_t *__restrict,
+                                  __const pthread_attr_t *__restrict,
+                                  void *(*)(void *),
+                                  void *__restrict) = NULL;
+
+/* Library initialization function */
+void wooinit(void) __attribute__((constructor));
+
+void wooinit(void)
+{
+    pthread_create_orig = dlsym(RTLD_NEXT, "pthread_create");
+    fprintf(stderr, "pthreads: using profiling hooks for gprof\n");
+    if(pthread_create_orig == NULL)
+    {
+        char *error = dlerror();
+        if(error == NULL)
+        {
+            error = "pthread_create is NULL";
+        }
+        fprintf(stderr, "%s\n", error);
+        exit(EXIT_FAILURE);
+    }
+}
+
+/* Our data structure passed to the wrapper */
+typedef struct wrapper_s
+{
+    void * (*start_routine)(void *);
+    void * arg;
+
+    pthread_mutex_t lock;
+    pthread_cond_t  wait;
+
+    struct itimerval itimer;
+
+} wrapper_t;
+
+/* The wrapper function in charge for setting the itimer value */
+static void * wrapper_routine(void * data)
+{
+    /* Put user data in thread-local variables */
+    void * (*start_routine)(void *) = ((wrapper_t*)data)->start_routine;
+    void * arg = ((wrapper_t*)data)->arg;
+
+    /* Set the profile timer value */
+    setitimer(ITIMER_PROF, &((wrapper_t*)data)->itimer, NULL);
+
+    /* Tell the calling thread that we don't need its data anymore */
+    pthread_mutex_lock(&((wrapper_t*)data)->lock);
+    pthread_cond_signal(&((wrapper_t*)data)->wait);
+    pthread_mutex_unlock(&((wrapper_t*)data)->lock);
+
+    /* Call the real function */
+    return start_routine(arg);
+}
+
+/* Our wrapper function for the real pthread_create() */
+int pthread_create(pthread_t *__restrict thread,
+                   __const pthread_attr_t *__restrict attr,
+                   void * (*start_routine)(void *),
+                   void *__restrict arg)
+{
+    wrapper_t wrapper_data;
+    int i_return;
+
+    /* Initialize the wrapper structure */
+    wrapper_data.start_routine = start_routine;
+    wrapper_data.arg = arg;
+    getitimer(ITIMER_PROF, &wrapper_data.itimer);
+    pthread_cond_init(&wrapper_data.wait, NULL);
+    pthread_mutex_init(&wrapper_data.lock, NULL);
+    pthread_mutex_lock(&wrapper_data.lock);
+
+    /* The real pthread_create call */
+    i_return = pthread_create_orig(thread,
+                                   attr,
+                                   &wrapper_routine,
+                                   &wrapper_data);
+
+    /* If the thread was successfully spawned, wait for the data
+     * to be released */
+    if(i_return == 0)
+    {
+        pthread_cond_wait(&wrapper_data.wait, &wrapper_data.lock);
+    }
+
+    pthread_mutex_unlock(&wrapper_data.lock);
+    pthread_mutex_destroy(&wrapper_data.lock);
+    pthread_cond_destroy(&wrapper_data.wait);
+
+    return i_return;
+}
+