*** empty log message ***

git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@40 29311d96-e01e-0410-9327-a35deaab8ce9
This commit is contained in:
sage 2004-07-26 14:58:58 +00:00
parent 0d1d57e5fd
commit 20d7ed2a4e
20 changed files with 205 additions and 114 deletions

View File

@ -4,6 +4,7 @@
#include "include/Message.h"
#include "mds/MDS.h"
#include "mds/MDCluster.h"
#include "Client.h"
#include "ClNode.h"
@ -13,20 +14,24 @@
#include <stdlib.h>
#include "include/config.h"
#define debug 1
Client::Client(int id, Messenger *m, long req)
Client::Client(MDCluster *mdc, int id, Messenger *m, long req)
{
mdcluster = mdc;
whoami = id;
messenger = m;
max_requests = req;
cwd = 0;
root = 0;
tid = 0;
cache_lru.lru_set_max(1000);
cache_lru.lru_set_midpoint(.5);
max_requests = req;
cache_lru.lru_set_max(CLIENT_CACHE);
cache_lru.lru_set_midpoint(CLIENT_CACHE_MID);
}
Client::~Client()
@ -240,8 +245,6 @@ void Client::send_request(string& p, int op)
mds = 0;
}
//mds = rand() % 10;
if (debug > 0)
cout << "client" << whoami << " req " << req->tid << " op " << req->op << " to mds" << mds << " for " << req->path << endl;
messenger->send_message(req,

View File

@ -11,9 +11,11 @@ class DentryCache;
class CInode;
class ClNode;
class MClientReply;
class MDCluster;
class Client : public Dispatcher {
protected:
MDCluster *mdcluster;
Messenger *messenger;
int whoami;
@ -26,7 +28,7 @@ class Client : public Dispatcher {
vector<string> last_req_dn;
public:
Client(int id, Messenger *m, long req);
Client(MDCluster *mdc, int id, Messenger *m, long req);
~Client();
int init();

View File

@ -7,12 +7,14 @@
#include <iostream>
#include "include/Clock.h"
#include "include/config.h"
Logger::Logger(string& fn, LogType *type)
{
filename = "out/";
filename += fn;
interval = 1.0;
interval = LOGGER_INTERVAL;
start = last_logged = g_clock.gettime(); // time 0!
wrote_header = -1;
open = false;
@ -71,6 +73,8 @@ void Logger::flush(bool force)
last_logged += interval;
force = false;
//cout << "logger " << this << " advancing from " << last_logged << " now " << now << endl;
if (!open) {
out.open(filename.c_str(), ofstream::out);
open = true;

View File

@ -1,6 +1,8 @@
#include <sys/types.h>
#include "include/Clock.h"
#include "include/config.h"
#ifndef NULL
#define NULL 0
#endif
@ -19,15 +21,16 @@ Clock::Clock() {
double g_now = 0.0;
double Clock::gettime() {
g_now += .0001;
return g_now;
/*
#ifdef FAKE_CLOCK
g_now += .000001;
return g_now;
#else
// get actual time
gettimeofday(&curtime,NULL);
return curtime.tv_sec + curtime.tv_usec/1000000.0;
*/
#endif
}
void Clock::settime(double t) {

15
ceph/config.h Normal file
View File

@ -0,0 +1,15 @@
#define NUMMDS 10
#define NUMOSD 10
#define CLIENT_CACHE 100
#define CLIENT_CACHE_MID .5
#define LOG_MESSAGES
#define LOGGER_INTERVAL 10.0
//#define FAKE_CLOCK
#define NUMCLIENT 10
#define CLIENT_REQUESTS 100000

View File

@ -2,6 +2,7 @@
#include "CDentry.h"
#include "CDir.h"
#include <cassert>
// CDentry
@ -10,12 +11,12 @@ void CDentry::remove() {
}
CDentry::CDentry(const CDentry& m) {
throw 1; //std::cerr << "copy cons called, implement me" << endl;
assert(0); //std::cerr << "copy cons called, implement me" << endl;
}
// =
const CDentry& CDentry::operator= (const CDentry& right) {
throw 1;//std::cerr << "copy op called, implement me" << endl;
assert(0); //std::cerr << "copy op called, implement me" << endl;
}
// comparisons

View File

@ -31,6 +31,7 @@ void CDir::hit()
void CDir::add_child(CDentry *d)
{
assert(nitems == items.size());
assert(items.count(d->name) == 0);
//cout << "adding " << d->name << " to " << this << endl;
items[d->name] = d;

View File

@ -92,7 +92,14 @@ class CDir {
size_t get_size() {
assert(nitems == items.size());
if (nitems != items.size()) {
for (CDir_map_t::iterator it = items.begin();
it != items.end();
it++)
cout << "item " << (*it).first << endl;
cout << "nitems " << nitems << endl;
assert(nitems == items.size());
}
return nitems;
}

View File

@ -166,10 +166,10 @@ class CInode : LRUObject {
// --- reference counting
void put(int by) {
assert(ref > 0);
if (ref_set.count(by) != 1) {
if (ref > 0 || ref_set.count(by) != 1) {
cout << "bad put " << *this << " by " << by << " was " << ref << " (" << ref_set << ")" << endl;
assert(ref_set.count(by) == 1);
assert(ref > 0);
}
ref--;
ref_set.erase(by);

View File

@ -51,7 +51,7 @@ int MDBalancer::proc_message(Message *m)
default:
cout << "mds" << mds->get_nodeid() << " balancer unknown message " << m->get_type() << endl;
throw "asdf";
assert(0);
break;
}
@ -87,7 +87,7 @@ void MDBalancer::send_heartbeat()
cout << "mds" << mds->get_nodeid() << " sending heartbeat " << beat_epoch << " " << load << endl;
int size = mds->get_cluster()->get_size();
int size = mds->get_cluster()->get_num_mds();
for (int i = 0; i<size; i++) {
if (i == mds->get_nodeid()) continue;
mds->messenger->send_message(new MHeartbeat(load, beat_epoch),
@ -117,7 +117,7 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m)
mds_load[ m->get_source() ] = m->load;
//cout << " load is " << load << " have " << mds_load.size() << endl;
int cluster_size = mds->get_cluster()->get_size();
int cluster_size = mds->get_cluster()->get_num_mds();
if (mds_load.size() == cluster_size)
do_rebalance();
@ -126,7 +126,7 @@ void MDBalancer::handle_heartbeat(MHeartbeat *m)
void MDBalancer::do_rebalance()
{
int cluster_size = mds->get_cluster()->get_size();
int cluster_size = mds->get_cluster()->get_num_mds();
int whoami = mds->get_nodeid();
cout << "mds" << whoami << " do_rebalance: cluster loads are" << endl;

View File

@ -70,7 +70,7 @@ bool MDCache::remove_inode(CInode *o)
delete dn;
}
else if (o->nparents > 1) {
throw "implement me";
assert(o->nparents <= 1);
}
// remove from map
@ -354,8 +354,8 @@ int MDCache::write_start(CInode *in, Message *m)
in->get(); // pin
}
} else {
throw "not implemented";
assert(auth != whoami);
}
@ -442,7 +442,7 @@ int MDCache::proc_message(Message *m)
default:
cout << "mds" << mds->get_nodeid() << " cache unknown message " << m->get_type() << endl;
throw "asdf";
assert(0);
break;
}
@ -618,7 +618,7 @@ int MDCache::handle_discover(MDiscover *dis)
cout << "mds" << mds->get_nodeid() << " handle_discover got result" << endl;
int r = path_traverse(dis->basepath, trav, NULL, MDS_TRAVERSE_FAIL); // FIXME BUG
if (r != 0) throw "wtf";
assert(r == 0);
CInode *cur = trav[trav.size()-1];
CInode *start = cur;
@ -705,7 +705,7 @@ int MDCache::handle_discover(MDiscover *dis)
while (!dis->done()) {
if (!cur->is_dir()) {
cout << "woah, discover on non dir " << dis->current_need() << endl;
throw "implement me";
assert(cur->is_dir());
}
if (!cur->dir) cur->dir = new CDir(cur);
@ -749,7 +749,7 @@ int MDCache::handle_discover(MDiscover *dis)
// don't have it.
if (cur->dir->is_complete()) {
// file not found.
throw "implement me";
assert(!cur->dir->is_complete());
} else {
// readdir
cout << "mds" << whoami << " incomplete dir contents for " << *cur << ", fetching" << endl;
@ -1058,7 +1058,7 @@ void MDCache::export_dir(CInode *in,
if (!in->parent) {
cout << "i won't export root" << endl;
throw "asdf";
assert(in->parent);
return;
}

View File

@ -3,27 +3,65 @@
#include "CDir.h"
#include "CInode.h"
MDCluster::MDCluster()
#include <iostream>
using namespace std;
MDCluster::MDCluster(int num_mds, int num_osd)
{
this->num_mds = num_mds;
this->num_osd = num_osd;
map_osds();
}
MDCluster::~MDCluster()
void MDCluster::map_osds()
{
// logs on ~10% of osd
osd_log_begin = 0;
osd_log_end = num_osd / 10;
if (osd_log_end > num_mds)
osd_log_end = num_mds;
// metadata on the rest
osd_meta_begin = osd_log_end;
osd_meta_end = num_osd;
cout << "mdcluster: " << num_mds << " mds, " << num_osd << " osd" << endl;
cout << "mdcluster: logs on " << (osd_log_end-osd_log_begin) << " osd [" << osd_log_begin << ", " << osd_log_end << ")" << endl;
cout << "mdcluster: metadata on " << (osd_meta_end-osd_meta_begin) << " osd [" << osd_meta_begin << ", " << osd_meta_end << ")" << endl;
}
int MDCluster::add_mds(MDS *m)
{
mds.push_back(m);
return mds.size() - 1;
}
int MDCluster::hash_dentry( CDir *dir, string& dn )
{
unsigned r = dir->get_inode()->inode.ino;
for (unsigned i=0; i<dn.length(); i++)
r += (dn[r] ^ i);
return r % get_size();
return osd_meta_begin + (r % (osd_meta_end - osd_meta_begin));
}
int MDCluster::get_meta_osd(inodeno_t ino)
{
return osd_meta_begin + (ino % (osd_meta_end - osd_meta_begin));
}
object_t MDCluster::get_meta_oid(inodeno_t ino)
{
return ino;
}
int MDCluster::get_log_osd(int mds)
{
return osd_log_begin + (mds % (osd_log_end - osd_log_begin));
}
object_t MDCluster::get_log_oid(int mds)
{
return 1000 + mds;
}

View File

@ -1,6 +1,8 @@
#ifndef __MDCLUSTER_H
#define __MDCLUSTER_H
#include "include/types.h"
#include <string>
#include <vector>
using namespace std;
@ -10,17 +12,32 @@ class MDS;
class MDCluster {
protected:
vector<MDS*> mds;
int num_mds;
int num_osd;
int osd_meta_begin; // 0
int osd_meta_end; // 10
int osd_log_begin;
int osd_log_end;
void map_osds();
public:
MDCluster();
~MDCluster();
MDCluster(int num_mds, int num_osd);
int get_size() { return mds.size(); }
int add_mds(MDS *m);
int get_num_mds() { return num_mds; }
//int get_size() { return mds.size(); }
//int add_mds(MDS *m);
int hash_dentry( CDir *dir, string& dn );
int get_meta_osd(inodeno_t ino);
object_t get_meta_oid(inodeno_t ino);
int get_log_osd(int mds);
object_t get_log_oid(int mds);
};
#endif

View File

@ -1,6 +1,7 @@
#include "MDLog.h"
#include "MDS.h"
#include "MDCluster.h"
#include "LogStream.h"
#include "LogEvent.h"
@ -21,8 +22,12 @@ MDLog::MDLog(MDS *m)
num_events = 0;
max_events = 0;
trim_reading = false;
reader = new LogStream(mds, 666, mds->get_nodeid());
writer = new LogStream(mds, 666, mds->get_nodeid());
reader = new LogStream(mds,
mds->get_cluster()->get_log_osd(mds->get_nodeid()),
mds->get_cluster()->get_log_oid(mds->get_nodeid()));
writer = new LogStream(mds,
mds->get_cluster()->get_log_osd(mds->get_nodeid()),
mds->get_cluster()->get_log_oid(mds->get_nodeid()));
if (!mdlog_logtype)
mdlog_logtype = new LogType();

View File

@ -46,8 +46,8 @@ void C_MDS_RetryMessage::redelegate(MDS *mds, int newmds)
// cons/des
MDS::MDS(MDCluster *mdc, Messenger *m) {
whoami = mdc->add_mds(this);
MDS::MDS(MDCluster *mdc, int whoami, Messenger *m) {
this->whoami = whoami;
mdcluster = mdc;
messenger = m;
@ -137,7 +137,7 @@ void MDS::proc_message(Message *m)
default:
cout << "mds" << whoami << " main unknown message " << m->get_type() << endl;
throw "asdf";
assert(0);
}
}
@ -236,7 +236,7 @@ int MDS::handle_client_request(MClientRequest *req)
default:
cout << "mds" << whoami << " unknown mop " << req->op << endl;
throw "eek";
assert(0);
}
if (reply) {
@ -417,7 +417,7 @@ MClientReply *MDS::handle_client_readdir(MClientRequest *req,
}
} else {
if (dirauth < 0) {
throw "not implemented";
assert(dirauth >= 0);
} else {
// forward to authority
cout << "mds" << whoami << " forwarding readdir to authority " << dirauth << endl;

View File

@ -103,7 +103,7 @@ class MDS : public Dispatcher {
public:
MDS(MDCluster *mdc, Messenger *m);
MDS(MDCluster *mdc, int whoami, Messenger *m);
~MDS();
int get_nodeid() { return whoami; }

View File

@ -9,6 +9,7 @@
#include "include/Message.h"
#include <cassert>
#include <iostream>
using namespace std;
@ -19,7 +20,7 @@ void MDStore::proc_message(Message *m)
default:
cout << "mds" << mds->get_nodeid() << " store unknown message " << m->get_type() << endl;
throw "asdf";
assert(0);
}
}
@ -71,8 +72,8 @@ bool MDStore::fetch_dir( CInode *in,
MDFetchDirContext *fin = new MDFetchDirContext( this, in->ino() );
// issue osd read
int osd = in->inode.ino % 10;
object_t oid = in->inode.ino;
int osd = mds->mdcluster->get_meta_osd(in->inode.ino);
object_t oid = mds->mdcluster->get_meta_oid(in->inode.ino);
mds->osd_read( osd, oid,
0, 0,
@ -88,7 +89,7 @@ bool MDStore::fetch_dir_2( int result, char *buf, size_t buflen, inodeno_t ino)
return false;
}
cout << "fetch_dir_2 on " << *idir << " ref " << idir->ref << " has " << idir->dir->get_size();
cout << "fetch_dir_2 on " << *idir << " ref " << idir->ref << " has " << idir->dir->get_size() << endl;
// make sure we have a CDir
if (idir->dir == NULL) idir->dir = new CDir(idir);
@ -97,7 +98,11 @@ bool MDStore::fetch_dir_2( int result, char *buf, size_t buflen, inodeno_t ino)
__uint32_t num = *((__uint32_t*)buf);
cout << " " << num << " items" << endl;
size_t p = 4;
while (p < buflen && num > 0) {
int parsed = 0;
while (parsed < num) {
assert(p < buflen && num > 0);
parsed++;
// dentry
string dname = buf+p;
p += dname.length() + 1;
@ -106,23 +111,22 @@ bool MDStore::fetch_dir_2( int result, char *buf, size_t buflen, inodeno_t ino)
// just a hard link?
if (*(buf+p) == 'L') {
// yup. we don't do that yet.
throw "not implemented";
assert(0);
} else {
p++;
inode_t *inode = (inode_t*)(buf+p);
p += sizeof(inode_t);
if (mds->mdcache->have_inode(inode->ino)) {
CInode *in = mds->mdcache->get_inode(inode->ino);
cout << " readdir got (but i already had) " << *in << " isdir " << in->inode.isdir << " touched " << in->inode.touched<< endl;
continue;
}
// inode
CInode *in = new CInode();
memcpy(&in->inode, buf+p, sizeof(inode_t));
p += sizeof(inode_t);
if (mds->mdcache->have_inode(in->inode.ino)) {
cout << " readdir got (but i already had) " << *in << " isdir " << in->inode.isdir << " touched " << in->inode.touched<< endl;
inodeno_t ino = in->inode.ino;
delete in;
in = mds->mdcache->get_inode(ino);
continue;
}
memcpy(&in->inode, inode, sizeof(inode_t));
// add and link
mds->mdcache->add_inode( in );
@ -143,7 +147,6 @@ bool MDStore::fetch_dir_2( int result, char *buf, size_t buflen, inodeno_t ino)
*/
}
num--;
}
idir->dir->state_set(CDIR_MASK_COMPLETE);
@ -308,8 +311,8 @@ bool MDStore::commit_dir( CInode *in,
in->dir->state_set(CDIR_MASK_MID_COMMIT);
// submit to osd
int osd = in->inode.ino % 10;
object_t oid = in->inode.ino;
int osd = mds->mdcluster->get_meta_osd(in->inode.ino);
object_t oid = mds->mdcluster->get_meta_oid(in->inode.ino);
mds->osd_write( osd, oid,
off, 0,

View File

@ -1,4 +1,7 @@
#include "include/config.h"
#include "include/FakeMessenger.h"
#include "mds/MDS.h"
#include "include/LogType.h"
@ -14,7 +17,7 @@ using namespace std;
// global queue.
hash_map<int, FakeMessenger*> directory;
map<int, FakeMessenger*> directory;
hash_map<int, Logger*> loggers;
LogType *logtype;
@ -26,7 +29,9 @@ int fakemessenger_do_loop()
while (1) {
bool didone = false;
hash_map<int, FakeMessenger*>::iterator it = directory.begin();
cout << "do_loop top" << endl;
map<int, FakeMessenger*>::iterator it = directory.begin();
while (it != directory.end()) {
Message *m = it->second->get_message();
if (m) {
@ -93,6 +98,7 @@ bool FakeMessenger::send_message(Message *m, long dest, int port, int fromport)
// deliver
try {
#ifdef LOG_MESSAGES
// stats
loggers[whoami]->inc("+send",1);
loggers[dest]->inc("-recv",1);
@ -102,6 +108,7 @@ bool FakeMessenger::send_message(Message *m, long dest, int port, int fromport)
loggers[whoami]->inc(s);
sprintf(s,"-%s", m->get_type_name());
loggers[dest]->inc(s);
#endif
// queue
FakeMessenger *dm = directory[dest];
@ -110,6 +117,7 @@ bool FakeMessenger::send_message(Message *m, long dest, int port, int fromport)
}
catch (...) {
cout << "no destination " << dest << endl;
assert(0);
}
}

View File

@ -97,7 +97,9 @@ void OSD::read(MOSDRead *r)
if (fd < 0) {
// send reply (failure)
cout << "read open FAILED on " << get_filename(whoami, r->oid) << " errno " << errno << endl;
reply = new MOSDReadReply(r, NULL, -1);
assert(0);
} else {
@ -113,6 +115,7 @@ void OSD::read(MOSDRead *r)
char *buf = new char[r->len];
long got = ::read(fd, buf, r->len);
flock(fd, LOCK_UN);
close(fd);
// send reply
@ -142,6 +145,7 @@ void OSD::write(MOSDWrite *m)
cout << "err opening " << f << " " << errno << endl;
reply = new MOSDWriteReply(m, -1);
assert(0);
} else {
// lock
@ -154,6 +158,7 @@ void OSD::write(MOSDWrite *m)
if (m->offset)
lseek(fd, m->offset, SEEK_SET);
long wrote = ::write(fd, m->buf, m->len);
flock(fd, LOCK_UN);
close(fd);
// reply

View File

@ -21,11 +21,8 @@ using namespace std;
__uint64_t ino = 1;
#define NUMMDSS 10
#define NUMOSDS 10
#define NUMCLIENTS 10
#define CLIENT_REQUESTS 10000
#include "include/config.h"
// this parses find output
int play();
@ -33,49 +30,31 @@ int play();
int main(char **argv, int argc) {
cout << "hi there" << endl;
try {
play();
}
catch (char *s) {
cout << "exception: " << s << endl;
}
}
int play() {
cout << "creating stuff" << endl;
// init
MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD);
// create mds
MDCluster *mdc = new MDCluster();
MDS *mds[10];
for (int i=0; i<NUMMDSS; i++) {
mds[i] = new MDS(mdc, new FakeMessenger(MSG_ADDR_MDS(i)));
MDS *mds[NUMMDS];
for (int i=0; i<NUMMDS; i++) {
mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i)));
mds[i]->init();
}
// create osds
OSD *osd[10];
for (int i=0; i<NUMOSDS; i++) {
OSD *osd[NUMOSD];
for (int i=0; i<NUMOSD; i++) {
osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i)));
osd[i]->init();
}
OSD *logosd = new OSD(666, new FakeMessenger(MSG_ADDR_OSD(666)));
logosd->init();
// create clients
Client *client[NUMCLIENTS];
for (int i=0; i<NUMCLIENTS; i++) {
client[i] = new Client(i, new FakeMessenger(MSG_ADDR_CLIENT(i)), CLIENT_REQUESTS);
Client *client[NUMCLIENT];
for (int i=0; i<NUMCLIENT; i++) {
client[i] = new Client(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(i)), CLIENT_REQUESTS);
client[i]->init();
}
cout << "sending test ping, load" << endl;
// send an initial message...?
mds[0]->messenger->send_message(new MPing(10), 1, MDS_PORT_MAIN, MDS_PORT_MAIN);
for (int i=0; i<NUMCLIENTS; i++)
// seed initial requests
for (int i=0; i<NUMCLIENT; i++)
//for (int i=0; i<1; i++)
client[i]->issue_request();
@ -84,7 +63,7 @@ int play() {
// cleanup
cout << "cleanup" << endl;
for (int i=0; i<NUMMDSS; i++) {
for (int i=0; i<NUMMDS; i++) {
if (mds[i]->shutdown() == 0) {
//cout << "clean shutdown of mds " << i << endl;
delete mds[i];
@ -92,7 +71,7 @@ int play() {
cout << "problems shutting down mds " << i << endl;
}
}
for (int i=0; i<NUMOSDS; i++) {
for (int i=0; i<NUMOSD; i++) {
if (osd[i]->shutdown() == 0) {
//cout << "clean shutdown of osd " << i << endl;
delete osd[i];
@ -100,7 +79,7 @@ int play() {
cout << "problems shutting down osd " << i << endl;
}
}
for (int i=0; i<NUMCLIENTS; i++) {
for (int i=0; i<NUMCLIENT; i++) {
if (client[i]->shutdown() == 0) {
//cout << "clean shutdown of client " << i << endl;
delete client[i];