From af5438e2f76e23d39e5543b7946837cc9776d4f9 Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 11 Sep 2007 17:59:26 +0000 Subject: [PATCH] simpler request direction when replicated; hack to workaround mds session bug on cap migration git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1828 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 14 +++++++-- trunk/ceph/client/Client.h | 44 ++++++++++++++++++++++------ trunk/ceph/client/SyntheticClient.cc | 6 ++-- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index da0eb44b1cd3e..dfae5e5ae3298 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -430,6 +430,7 @@ void Client::update_inode_dist(Inode *in, InodeStat *st) in->dir_replicated = true; // FIXME // dist + /* if (!st->dirfrag_dist.empty()) { // FIXME set dist = st->dirfrag_dist.begin()->second; if (dist.empty() && !in->dir_contacts.empty()) @@ -440,6 +441,7 @@ void Client::update_inode_dist(Inode *in, InodeStat *st) << " " << dist << dendl; in->dir_contacts = dist; } + */ } @@ -544,7 +546,8 @@ int Client::choose_target_mds(MClientRequest *req) int missing_dn = -1; // which dn we miss on (if we miss) unsigned depth = req->get_filepath().depth(); - for (unsigned i=0; iinode.mode & INODE_MODE_DIR && diri->dir) { Dir *dir = diri->dir; @@ -591,7 +594,10 @@ int Client::choose_target_mds(MClientRequest *req) } } else { // balance our traffic! - mds = diri->pick_replica(mdsmap); + mds = diri->pick_replica(mdsmap); // for the _inode_ + dout(20) << "for " << req->get_filepath() << " diri " << diri->inode.ino << " rep " + << diri->dir_contacts + << " mds" << mds << dendl; } } dout(20) << "mds is " << mds << dendl; @@ -1087,7 +1093,9 @@ void Client::handle_file_caps(MClientFileCaps *m) m->clear_payload(); // for if/when we send back to MDS // note push seq increment - assert(mds_sessions.count(mds)); + if (mds_sessions.count(mds) == 0) + dout(0) << "got file_caps without session from mds" << mds << " msg " << *m << dendl; + //assert(mds_sessions.count(mds)); // HACK FIXME SOON mds_sessions[mds]++; // reap? diff --git a/trunk/ceph/client/Client.h b/trunk/ceph/client/Client.h index aff0db8487f9b..1671637105d0a 100644 --- a/trunk/ceph/client/Client.h +++ b/trunk/ceph/client/Client.h @@ -272,27 +272,53 @@ class Inode { int pick_replica(MDSMap *mdsmap) { // replicas? - if (ino() > 1ULL && dir_contacts.size()) { + /* fixme + if (//ino() > 1ULL && + dir_contacts.size()) { set::iterator it = dir_contacts.begin(); if (dir_contacts.size() == 1) return *it; else { //cout << "dir_contacts on " << inode.ino << " is " << dir_contacts << std::endl; - int r = rand() % dir_contacts.size(); + int r = 1 + (rand() % dir_contacts.size()); + int a = authority(); while (r--) { it++; - if (mdsmap->is_down(*it)) - it++; - if (it == dir_contacts.end()) - it = dir_contacts.begin(); + if (mdsmap->is_down(*it)) it++; + if (it == dir_contacts.end()) it = dir_contacts.begin(); + if (*it == a) it++; // skip the authority + if (it == dir_contacts.end()) it = dir_contacts.begin(); } return *it; } } - - if (dir_replicated || ino() == 1) { + */ + + if (dir_replicated) {// || ino() == 1) { + // pick a random mds that isn't the auth + set s; + mdsmap->get_in_mds_set(s); + set::iterator it = s.begin(); + if (s.empty()) + return 0; + if (s.size() == 1) + return *it; + else { + //cout << "dir_contacts on " << inode.ino << " is " << dir_contacts << std::endl; + int r = 1 + (rand() % s.size()); + int a = authority(); + while (r--) { + it++; + if (mdsmap->is_down(*it)) it++; + if (it == s.end()) it = s.begin(); + if (*it == a) it++; // skip the authority + if (it == s.end()) it = s.begin(); + } + //if (inode.ino == 1) cout << "chose " << *it << " from " << s << std::endl; + return *it; + } //cout << "num_mds is " << mdcluster->get_num_mds() << endl; - return mdsmap->get_random_in_mds(); + //return mdsmap->get_random_in_mds(); //return rand() % mdsmap->get_num_mds(); // huh.. pick a random mds! } else diff --git a/trunk/ceph/client/SyntheticClient.cc b/trunk/ceph/client/SyntheticClient.cc index b2474b9421a1b..944e33434f41a 100644 --- a/trunk/ceph/client/SyntheticClient.cc +++ b/trunk/ceph/client/SyntheticClient.cc @@ -932,7 +932,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) const char *a = t.get_string(buf, p); if (strcmp(a, p) != 0 && strcmp(a, "/") != 0 && - strcmp(a, "") != 0) // stop stating the root directory already + strcmp(a, "/lib") != 0 && // or /lib.. that would be a lookup. hack. + a[0] != 0) // stop stating the root directory already client->lstat(a, &st); } else if (strcmp(op, "chmod") == 0) { const char *a = t.get_string(buf, p); @@ -1405,7 +1406,8 @@ int SyntheticClient::full_walk(string& basedir) // print char *tm = ctime(&st.st_mtime); tm[strlen(tm)-1] = 0; - printf("%c%c%c%c%c%c%c%c%c%c %2d %5d %5d %8d %12s %s\n", + printf("%llx %c%c%c%c%c%c%c%c%c%c %2d %5d %5d %8d %12s %s\n", + st.st_ino, S_ISDIR(st.st_mode) ? 'd':'-', (st.st_mode & 0400) ? 'r':'-', (st.st_mode & 0200) ? 'w':'-', -- 2.39.5