]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
simpler request direction when replicated; hack to workaround mds session bug on...
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 11 Sep 2007 17:59:26 +0000 (17:59 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 11 Sep 2007 17:59:26 +0000 (17:59 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1828 29311d96-e01e-0410-9327-a35deaab8ce9

trunk/ceph/client/Client.cc
trunk/ceph/client/Client.h
trunk/ceph/client/SyntheticClient.cc

index da0eb44b1cd3e270de3f595afe9883ef3397bd22..dfae5e5ae3298e4e22a2707c1950fa5dd97d1152 100644 (file)
@@ -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<int> 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; i<depth; i++) {
+  unsigned i;
+  for (i=0; i<depth; i++) {
     // dir?
     if (diri && diri->inode.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?
index aff0db8487f9b45f13467c8c8679614f2a0e9873..1671637105d0abc914f7e83ce5effb732b4d6fdf 100644 (file)
@@ -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<int>::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<int> s;
+      mdsmap->get_in_mds_set(s);
+      set<int>::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
index b2474b9421a1bba78e23da48f7be52fca410331e..944e33434f41a0ab643bfd2b11905e63b6bedf7b 100644 (file)
@@ -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':'-',