From 8c1a8d9fe68432856942990ac3b0c82ffe9aea6c Mon Sep 17 00:00:00 2001 From: sageweil Date: Mon, 4 Jun 2007 21:55:08 +0000 Subject: [PATCH] * account for open popularity properly (rd vs wr) * locker bugfixes git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1395 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/cephmds2/TODO | 3 +- branches/sage/cephmds2/mds/Locker.cc | 21 ++++++-------- branches/sage/cephmds2/mds/Locker.h | 2 +- branches/sage/cephmds2/mds/MDBalancer.cc | 2 +- branches/sage/cephmds2/mds/Server.cc | 6 +++- branches/sage/cephmds2/messages/MLock.h | 37 ++++++++++++------------ 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/branches/sage/cephmds2/TODO b/branches/sage/cephmds2/TODO index 1c9886839e183..b1d2736b57638 100644 --- a/branches/sage/cephmds2/TODO +++ b/branches/sage/cephmds2/TODO @@ -57,7 +57,8 @@ sage mds - failures during recovery stages (resolve, rejoin)... make sure rejoin still works! - incremental mdsmaps? -- client failure + +- detect and deal with client failure - dirfrag split - make sure we are freezing _before_ we fetch to complete the dirfrag, else diff --git a/branches/sage/cephmds2/mds/Locker.cc b/branches/sage/cephmds2/mds/Locker.cc index c235c4eacceff..ce550931c4f14 100644 --- a/branches/sage/cephmds2/mds/Locker.cc +++ b/branches/sage/cephmds2/mds/Locker.cc @@ -97,7 +97,7 @@ void Locker::send_lock_message(SimpleLock *lock, int msg) } } -void Locker::send_lock_message(SimpleLock *lock, int msg, bufferlist &data) +void Locker::send_lock_message(SimpleLock *lock, int msg, const bufferlist &data) { for (map::iterator it = lock->get_parent()->replicas_begin(); it != lock->get_parent()->replicas_end(); @@ -1884,19 +1884,15 @@ bool Locker::file_sync(FileLock *lock) if (lock->get_state() == LOCK_LOCK) { if (in->is_replicated()) { - // soft data bufferlist softdata; lock->encode_locked_state(softdata); - - // bcast to replicas send_lock_message(lock, LOCK_AC_SYNC, softdata); } - + // change lock lock->set_state(LOCK_SYNC); - // reissue caps - issue_caps(in); + issue_caps(in); // reissue caps return true; } @@ -1908,10 +1904,10 @@ bool Locker::file_sync(FileLock *lock) issue_caps(in); } else { // no writers, go straight to sync - if (in->is_replicated()) { - // bcast to replicas - send_lock_message(lock, LOCK_AC_SYNC); + bufferlist softdata; + lock->encode_locked_state(softdata); + send_lock_message(lock, LOCK_AC_SYNC, softdata); } // change lock @@ -1929,8 +1925,9 @@ bool Locker::file_sync(FileLock *lock) } else { // no writers, go straight to sync if (in->is_replicated()) { - // bcast to replicas - send_lock_message(lock, LOCK_AC_SYNC); + bufferlist softdata; + lock->encode_locked_state(softdata); + send_lock_message(lock, LOCK_AC_SYNC, softdata); } // change lock diff --git a/branches/sage/cephmds2/mds/Locker.h b/branches/sage/cephmds2/mds/Locker.h index 6120c5c246683..5f79bbacf4de0 100644 --- a/branches/sage/cephmds2/mds/Locker.h +++ b/branches/sage/cephmds2/mds/Locker.h @@ -60,7 +60,7 @@ private: void handle_lock(MLock *m); void send_lock_message(SimpleLock *lock, int msg); - void send_lock_message(SimpleLock *lock, int msg, bufferlist &data); + void send_lock_message(SimpleLock *lock, int msg, const bufferlist &data); // -- locks -- bool acquire_locks(MDRequest *mdr, diff --git a/branches/sage/cephmds2/mds/MDBalancer.cc b/branches/sage/cephmds2/mds/MDBalancer.cc index 77d0075a72ef3..5e6bac91671ed 100644 --- a/branches/sage/cephmds2/mds/MDBalancer.cc +++ b/branches/sage/cephmds2/mds/MDBalancer.cc @@ -766,7 +766,7 @@ void MDBalancer::hit_recursive(CDir *dir, int type) // replicate? float dir_pop = dir->popularity[MDS_POP_CURDOM].pop[type].get(); // hmm?? - dout(-20) << "hit_recursive " << dir_pop << " curdom " << *dir << endl; + dout(-20) << "hit_recursive " << type << " pop " << dir_pop << " curdom " << *dir << endl; if (dir->is_auth()) { if (!dir->is_rep() && diff --git a/branches/sage/cephmds2/mds/Server.cc b/branches/sage/cephmds2/mds/Server.cc index 3435f3cbe491c..37400284065ba 100644 --- a/branches/sage/cephmds2/mds/Server.cc +++ b/branches/sage/cephmds2/mds/Server.cc @@ -2755,7 +2755,11 @@ void Server::_do_open(MDRequest *mdr, CInode *cur) << " on " << *cur << endl; // hit pop - mds->balancer->hit_inode(cur, META_POP_IRD); + if (cmode == FILE_MODE_RW || + cmode == FILE_MODE_W) + mds->balancer->hit_inode(cur, META_POP_IWR); + else + mds->balancer->hit_inode(cur, META_POP_IRD); // reply MClientReply *reply = new MClientReply(req, 0); diff --git a/branches/sage/cephmds2/messages/MLock.h b/branches/sage/cephmds2/messages/MLock.h index 02229125cc521..890c536e75310 100644 --- a/branches/sage/cephmds2/messages/MLock.h +++ b/branches/sage/cephmds2/messages/MLock.h @@ -17,7 +17,7 @@ #define __MLOCK_H #include "msg/Message.h" - +#include "mds/SimpleLock.h" // for replicas #define LOCK_AC_SYNC -1 @@ -91,6 +91,12 @@ class MLock : public Message { data.claim(bl); } virtual char *get_type_name() { return "ILock"; } + void print(ostream& out) { + out << "lock(a=" << action + << " " << ino + << " " << get_lock_type_name(otype) + << ")"; + } void set_ino(inodeno_t ino, char ot) { otype = ot; @@ -111,32 +117,27 @@ class MLock : public Message { this->dn = dn; } void set_reqid(metareqid_t ri) { reqid = ri; } - void set_data(bufferlist& data) { - this->data.claim( data ); + void set_data(const bufferlist& data) { + this->data = data; } void decode_payload() { int off = 0; - payload.copy(off,sizeof(action), (char*)&action); - off += sizeof(action); - payload.copy(off,sizeof(asker), (char*)&asker); - off += sizeof(asker); - payload.copy(off,sizeof(otype), (char*)&otype); - off += sizeof(otype); - payload.copy(off,sizeof(ino), (char*)&ino); - off += sizeof(ino); - payload.copy(off,sizeof(dirfrag), (char*)&dirfrag); - off += sizeof(dirfrag); + ::_decode(action, payload, off); + ::_decode(asker, payload, off); + ::_decode(otype, payload, off); + ::_decode(ino, payload, off); + ::_decode(dirfrag, payload, off); ::_decode(reqid, payload, off); ::_decode(dn, payload, off); ::_decode(data, payload, off); } virtual void encode_payload() { - payload.append((char*)&action, sizeof(action)); - payload.append((char*)&asker, sizeof(asker)); - payload.append((char*)&otype, sizeof(otype)); - payload.append((char*)&ino, sizeof(ino)); - payload.append((char*)&dirfrag, sizeof(dirfrag)); + ::_encode(action, payload); + ::_encode(asker, payload); + ::_encode(otype, payload); + ::_encode(ino, payload); + ::_encode(dirfrag, payload); ::_encode(reqid, payload); ::_encode(dn, payload); ::_encode(data, payload); -- 2.39.5