From 5176d3e35ba75104aaf7645976f6d2f47103e0cc Mon Sep 17 00:00:00 2001 From: sage Date: Tue, 3 May 2005 16:30:38 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@195 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/Makefile | 3 ++ ceph/client/fuse.cc | 2 +- ceph/common/Mutex.h | 25 +++++++++--- ceph/fakefuse.cc | 97 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 ceph/fakefuse.cc diff --git a/ceph/Makefile b/ceph/Makefile index cb419aacd04ae..62fb5b479f84e 100644 --- a/ceph/Makefile +++ b/ceph/Makefile @@ -66,6 +66,9 @@ mttest: test/mttest.cc msg/MTMessenger.cc ${COMMON_OBJS} mpifuse: mpifuse.cc mds/mds.o client/Client.o osd/OSD.o client/fuse.o msg/MPIMessenger.cc ${COMMON_OBJS} ${MPICC} ${CFLAGS} ${LIBS} $^ -o $@ +fakefuse: fakefuse.cc mds/mds.o client/Client.o osd/OSD.o client/fuse.o msg/FakeMessenger.cc msg/CheesySerializer.o ${COMMON_OBJS} + ${CC} ${CFLAGS} ${LIBS} $^ -o $@ + clean: rm -f *.o */*.o ${TARGETS} diff --git a/ceph/client/fuse.cc b/ceph/client/fuse.cc index a958c657e0097..b6afe089d5e8a 100644 --- a/ceph/client/fuse.cc +++ b/ceph/client/fuse.cc @@ -238,5 +238,5 @@ int ceph_fuse_main(Client *c, int argc, char *argv[]) // go fuse go cout << "ok, calling fuse_main" << endl; - return fuse_main(argc, argv, &ceph_oper); + return fuse_main(newargc, newargv, &ceph_oper); } diff --git a/ceph/common/Mutex.h b/ceph/common/Mutex.h index dc607eb63ba22..ee9604537554a 100755 --- a/ceph/common/Mutex.h +++ b/ceph/common/Mutex.h @@ -11,6 +11,7 @@ #define _Mutex_Posix_ #include +#include class Mutex { @@ -18,6 +19,8 @@ class Mutex void operator=(Mutex &M) {} Mutex( const Mutex &M ) {} + bool locked; + public: Mutex() @@ -25,21 +28,33 @@ class Mutex pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&M,&attr); + cout << "mutex init = " << pthread_mutex_init(&M,NULL) << endl; pthread_mutexattr_destroy(&attr); + locked = false; } virtual ~Mutex() { pthread_mutex_unlock(&M); pthread_mutex_destroy(&M); } - int Lock() const - { return pthread_mutex_lock(&M); } + int Lock() { + int r = pthread_mutex_lock(&M); + cout << pthread_self() << " lock = " << r << endl; + assert(!locked); + locked = true; + return r; + } int Lock_Try() const { return pthread_mutex_trylock(&M); } - int Unlock() const - { return pthread_mutex_unlock(&M); } + int Unlock() + { + assert(locked); + locked = false; + int r = pthread_mutex_unlock(&M); + cout << pthread_self() << " unlock = " << r << endl; + return r; + } }; #endif // !_Mutex_Posix_ diff --git a/ceph/fakefuse.cc b/ceph/fakefuse.cc new file mode 100644 index 0000000000000..5c37cb5e44aac --- /dev/null +++ b/ceph/fakefuse.cc @@ -0,0 +1,97 @@ + + +#include +#include +#include +using namespace std; + +#include "include/config.h" +#include "mds/MDCluster.h" + +#include "mds/MDS.h" +#include "osd/OSD.h" +#include "client/Client.h" +#include "client/fuse.h" + +#include "msg/FakeMessenger.h" +#include "msg/CheesySerializer.h" + + + +#define NUMMDS g_conf.num_mds +#define NUMOSD g_conf.num_osd +#define NUMCLIENT g_conf.num_client + + + +int main(int argc, char **argv) { + cout << "fakefuse starting" << endl; + + MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); + + // start messenger thread + fakemessenger_startthread(); + + + // create mds + MDS *mds[NUMMDS]; + for (int i=0; iinit(); + } + + // create osd + OSD *osd[NUMOSD]; + for (int i=0; iinit(); + } + + // create client + Client *client[NUMCLIENT]; + for (int i=0; iset_dispatcher(serializer); + + client[i] = new Client(mdc, i, serializer); + client[i]->init(); + + + // start up fuse + // use my argc, argv (make sure you pass a mount point!) + cout << "starting fuse on pid " << getpid() << endl; + ceph_fuse_main(client[i], argc, argv); + cout << "fuse finished on pid " << getpid() << endl; + } + + + // wait for it to finish + cout << "DONE -----" << endl; + fakemessenger_stopthread(); // blocks until messenger stops + + // shutdown + /* + cout << "---- check ----" << endl; + for (int i=0; imdcache->shutdown_pass(); + } + */ + + // cleanup + for (int i=0; i