From 5fa026807073f4de27576ba259a1ba3b01de94dd Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 15 May 2007 18:37:08 +0000 Subject: [PATCH] merged trunk changes r1338:1353 into branches/sage/cephmds2 git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1354 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/cephmds2/Makefile | 6 +- .../sage/cephmds2/client/SyntheticClient.cc | 6 ++ .../cephmds2/client/hadoop/CephFSInterface.cc | 63 +++++++++++++------ .../cephmds2/client/hadoop/CephFSInterface.h | 8 +++ branches/sage/cephmds2/common/Mutex.h | 14 +++++ branches/sage/cephmds2/common/Thread.h | 2 +- branches/sage/cephmds2/config.cc | 2 +- branches/sage/cephmds2/fakefuse.cc | 4 ++ branches/sage/cephmds2/mds/MDS.cc | 15 +---- branches/sage/cephmds2/mon/OSDMonitor.cc | 2 +- branches/sage/cephmds2/osd/OSD.cc | 2 +- 11 files changed, 86 insertions(+), 38 deletions(-) diff --git a/branches/sage/cephmds2/Makefile b/branches/sage/cephmds2/Makefile index 4abe10183b3c1..6248f207959d4 100644 --- a/branches/sage/cephmds2/Makefile +++ b/branches/sage/cephmds2/Makefile @@ -12,7 +12,7 @@ CFLAGS = -g -Wall -I. -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -DDARWI LDINC = ar -rc else # For linux -CFLAGS = -g -Wall -I. -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE +CFLAGS = -g -fPIC -Wall -I. -D_FILE_OFFSET_BITS=64 -DMPICH_IGNORE_CXX_SEEK -D_REENTRANT -D_THREAD_SAFE LDINC = ld -i -o endif @@ -178,8 +178,8 @@ osd_obfs.o: osd/OBFSStore.o osd/OSD.cc osd/PG.o osd/ObjectStore.o osd/FakeStore. # hadoop -libhadoopcephfs.so: client/hadoop/CephFSInterface.o client.o osdc.o msg/SimpleMessenger.o common.o - ${CC} -shared -Wl,-soname,$@.1 ${CFLAGS} -I/cse/grads/eestolan/java_local/jdk1.6.0/include ${LIBS} $^ -o $@ +libhadoopcephfs.so: client/hadoop/CephFSInterface.cc client.o osdc.o msg/SimpleMessenger.o common.o + ${CC} -fPIC -shared -Wl,-soname,$@.1 ${CFLAGS} -I/usr/local/java/include -I/usr/local/java/include/linux ${LIBS} $^ -o $@ # libceph libceph.o: client/ldceph.o client/Client.o msg/SimpleMessenger.o ${COMMON_OBJS} ${SYN_OBJS} ${OSDC_OBJS} diff --git a/branches/sage/cephmds2/client/SyntheticClient.cc b/branches/sage/cephmds2/client/SyntheticClient.cc index 5564cf90a6d72..d6adf65cbdcf7 100644 --- a/branches/sage/cephmds2/client/SyntheticClient.cc +++ b/branches/sage/cephmds2/client/SyntheticClient.cc @@ -714,6 +714,12 @@ int SyntheticClient::play_trace(Trace& t, string& prefix) char *buf = new char[size]; client->read(fh, buf, size, off); delete[] buf; + } else if (strcmp(op, "lseek") == 0) { + __int64_t id = t.get_int(); + __int64_t fh = open_files[id]; + int off = t.get_int(); + int whence = t.get_int(); + client->lseek(fh, off, whence); } else if (strcmp(op, "write") == 0) { __int64_t id = t.get_int(); __int64_t fh = open_files[id]; diff --git a/branches/sage/cephmds2/client/hadoop/CephFSInterface.cc b/branches/sage/cephmds2/client/hadoop/CephFSInterface.cc index 3202c662153dc..64d6d76fe00e5 100644 --- a/branches/sage/cephmds2/client/hadoop/CephFSInterface.cc +++ b/branches/sage/cephmds2/client/hadoop/CephFSInterface.cc @@ -48,16 +48,6 @@ JNIEXPORT jlong JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1init return clientp; } -/* on shutdown, - -client->unmount(); -client->shutdown(); -delete client; - -// wait for messenger to finish -rank.wait(); - -*/ /* @@ -485,6 +475,7 @@ JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1i * Class: org_apache_hadoop_fs_ceph_CephFileSystem * Method: ceph_getdir * Signature: (JLjava/lang/String;)[Ljava/lang/String; + * Returns a Java array of Strings with the directory contents */ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1getdir (JNIEnv *env, jobject obj, jlong clientp, jstring j_path) { @@ -507,13 +498,15 @@ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_cep //cout << "checking for empty dir" << endl; jint dir_size = contents.size(); - if (dir_size < 1) - { - // cout << "dir was empty" << endl; - //return NULL; - } - //out << "dir was not empty" << endl; + // Hadoop doesn't want . or .. in the listing, so we shrink the + // listing size by two, or by one if the directory's root + if(('/' == c_path[0]) && (0 == c_path[1])) + dir_size -= 1; + else + dir_size -= 2; + assert (dir_size >= 0); + // Create a Java String array of the size of the directory listing // jstring blankString = env->NewStringUTF(""); jclass stringClass = env->FindClass("java/lang/String"); @@ -523,13 +516,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_cep } jobjectArray dirListingStringArray = (jobjectArray) env->NewObjectArray(dir_size, stringClass, NULL); - // populate the array with the elements of the directory list + // populate the array with the elements of the directory list, + // omitting . and .. int i = 0; + string dot("."); + string dotdot (".."); for (map::iterator it = contents.begin(); it != contents.end(); it++) { + // is it "."? + if (it->first == dot) continue; + if (it->first == dotdot) continue; + if (0 == dir_size) cout << "WARNING: adding stuff to an empty array" << endl; + assert (i < dir_size); env->SetObjectArrayElement(dirListingStringArray, i, env->NewStringUTF(it->first.c_str())); ++i; @@ -595,6 +596,30 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_ return result; } +/* + * Class: org_apache_hadoop_fs_ceph_CephFileSystem + * Method: ceph_kill_client + * Signature: (J)Z + * + * Closes the Ceph client. + */ +JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1kill_1client + (JNIEnv *env, jobject obj, jlong clientp) +{ + Client* client; + client = *(Client**)&clientp; + + client->unmount(); + client->shutdown(); + delete client; + + // wait for messenger to finish + rank.wait(); + + return true; +} + + /* * Class: org_apache_hadoop_fs_ceph_CephInputStream @@ -769,8 +794,8 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1clo JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephOutputStream_ceph_1write (JNIEnv *env, jobject obj, jlong clientp, jint fh, jbyteArray j_buffer, jint buffer_offset, jint length) { - cout << "In write" << endl; - cout.flush(); + //cout << "In write" << endl; + //cout.flush(); // IMPORTANT NOTE: Hadoop write arguments are a bit different from POSIX so we diff --git a/branches/sage/cephmds2/client/hadoop/CephFSInterface.h b/branches/sage/cephmds2/client/hadoop/CephFSInterface.h index 8cba3248c33dc..0930ecb25b8f1 100644 --- a/branches/sage/cephmds2/client/hadoop/CephFSInterface.h +++ b/branches/sage/cephmds2/client/hadoop/CephFSInterface.h @@ -155,6 +155,14 @@ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_ JNIEXPORT jint JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1open_1for_1overwrite (JNIEnv *, jobject, jlong, jstring); +/* + * Class: org_apache_hadoop_fs_ceph_CephFileSystem + * Method: ceph_kill_client + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_org_apache_hadoop_fs_ceph_CephFileSystem_ceph_1kill_1client + (JNIEnv *, jobject, jlong); + #undef org_apache_hadoop_fs_ceph_CephInputStream_SKIP_BUFFER_SIZE #define org_apache_hadoop_fs_ceph_CephInputStream_SKIP_BUFFER_SIZE 2048L /* diff --git a/branches/sage/cephmds2/common/Mutex.h b/branches/sage/cephmds2/common/Mutex.h index c4615a3ff4c6e..325ba2a0e11fc 100755 --- a/branches/sage/cephmds2/common/Mutex.h +++ b/branches/sage/cephmds2/common/Mutex.h @@ -63,6 +63,20 @@ public: } friend class Cond; + + +public: + class Locker { + Mutex &mutex; + + public: + Locker(Mutex& m) : mutex(m) { + mutex.Lock(); + } + ~Locker() { + mutex.Unlock(); + } + }; }; #endif diff --git a/branches/sage/cephmds2/common/Thread.h b/branches/sage/cephmds2/common/Thread.h index 2d8a393498479..d1ae1e7674165 100644 --- a/branches/sage/cephmds2/common/Thread.h +++ b/branches/sage/cephmds2/common/Thread.h @@ -48,7 +48,7 @@ class Thread { //assert(0); return -EINVAL; // never started. } - + int status = pthread_join(thread_id, prval); if (status != 0) { switch (status) { diff --git a/branches/sage/cephmds2/config.cc b/branches/sage/cephmds2/config.cc index 8d7564c0f9b3d..345f979be929d 100644 --- a/branches/sage/cephmds2/config.cc +++ b/branches/sage/cephmds2/config.cc @@ -157,7 +157,7 @@ md_config_t g_conf = { mds_decay_halflife: 30, mds_beacon_interval: 5.0, - mds_beacon_grace: 10.0, + mds_beacon_grace: 100.0, mds_log: true, mds_log_max_len: MDS_CACHE_SIZE / 3, diff --git a/branches/sage/cephmds2/fakefuse.cc b/branches/sage/cephmds2/fakefuse.cc index ed2e90a8d5625..a9f98e9d5bb08 100644 --- a/branches/sage/cephmds2/fakefuse.cc +++ b/branches/sage/cephmds2/fakefuse.cc @@ -123,7 +123,11 @@ int main(int argc, char **argv) { // use my argc, argv (make sure you pass a mount point!) cout << "starting fuse on pid " << getpid() << endl; client[i]->mount(); + + char *oldcwd = get_current_dir_name(); // note previous wd ceph_fuse_main(client[i], argc, argv); + ::chdir(oldcwd); // return to previous wd + client[i]->unmount(); cout << "fuse finished on pid " << getpid() << endl; client[i]->shutdown(); diff --git a/branches/sage/cephmds2/mds/MDS.cc b/branches/sage/cephmds2/mds/MDS.cc index 0e736d698adc7..fb62840da6830 100644 --- a/branches/sage/cephmds2/mds/MDS.cc +++ b/branches/sage/cephmds2/mds/MDS.cc @@ -692,10 +692,12 @@ void MDS::handle_osd_map(MOSDMap *m) { version_t had = osdmap->get_epoch(); + dout(10) << "handle_osd_map had " << had << endl; + // process locally objecter->handle_osd_map(m); - if (had == 0) { + if (had == 0 && osdmap->get_epoch() > 0) { if (is_creating()) boot_create(); // new tables, journal else if (is_starting()) @@ -706,17 +708,6 @@ void MDS::handle_osd_map(MOSDMap *m) assert(is_standby()); } - // pass on to clients - /* - for (set::iterator it = clientmap.get_mount_set().begin(); - it != clientmap.get_mount_set().end(); - it++) { - MOSDMap *n = new MOSDMap; - n->maps = m->maps; - n->incremental_maps = m->incremental_maps; - messenger->send_message(n, clientmap.get_inst(*it)); - } - */ } diff --git a/branches/sage/cephmds2/mon/OSDMonitor.cc b/branches/sage/cephmds2/mon/OSDMonitor.cc index 8f0ee4484ea4f..8a1ff495515fd 100644 --- a/branches/sage/cephmds2/mon/OSDMonitor.cc +++ b/branches/sage/cephmds2/mon/OSDMonitor.cc @@ -139,7 +139,7 @@ void OSDMonitor::create_initial() } // 7 bits per osd. - osdmap.set_pg_bits(osdbits + 7); + osdmap.set_pg_bits(osdbits + 4); // FIXME } // start at epoch 0 until all osds boot diff --git a/branches/sage/cephmds2/osd/OSD.cc b/branches/sage/cephmds2/osd/OSD.cc index d2355cb4d32ff..c1e579db496fe 100644 --- a/branches/sage/cephmds2/osd/OSD.cc +++ b/branches/sage/cephmds2/osd/OSD.cc @@ -1647,7 +1647,7 @@ void OSD::handle_pg_notify(MOSDPGNotify *m) dout(10) << *pg << " osd" << from << " now clean (" << pg->clean_set << "): " << *it << dendl; if (pg->is_all_clean()) { - dout(-10) << *pg << " now clean on all replicas" << dendl; + dout(10) << *pg << " now clean on all replicas" << dendl; pg->state_set(PG::STATE_CLEAN); pg->clean_replicas(); } -- 2.39.5