]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Prediction now actually work...with some hacky fixes
authoranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 27 Mar 2007 00:10:46 +0000 (00:10 +0000)
committeranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 27 Mar 2007 00:10:46 +0000 (00:10 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1306 29311d96-e01e-0410-9327-a35deaab8ce9

20 files changed:
branches/aleung/security1/ceph/client/Client.cc
branches/aleung/security1/ceph/client/Client.h
branches/aleung/security1/ceph/config.cc
branches/aleung/security1/ceph/config.h
branches/aleung/security1/ceph/crypto/CapGroup.h
branches/aleung/security1/ceph/crypto/RecentPopularity.h
branches/aleung/security1/ceph/crypto/UserBatch.h [new file with mode: 0644]
branches/aleung/security1/ceph/crypto/driver.cc
branches/aleung/security1/ceph/mds/Locker.cc
branches/aleung/security1/ceph/mds/MDS.cc
branches/aleung/security1/ceph/mds/MDS.h
branches/aleung/security1/ceph/mds/Server.cc
branches/aleung/security1/ceph/mds/Server.h
branches/aleung/security1/ceph/messages/MClientAuthUser.h
branches/aleung/security1/ceph/messages/MClientRequest.h
branches/aleung/security1/ceph/mkdir_trace.pl
branches/aleung/security1/ceph/mon/MonMap.h
branches/aleung/security1/ceph/mon/Monitor.cc
branches/aleung/security1/ceph/mon/OSDMonitor.cc
branches/aleung/security1/ceph/osd/OSDMap.h

index 6bdbe2c025fe75f31125d27b6f7721a76aa1a672..d937e1e7850bfed57a026355a56d2f37a4476788 100644 (file)
@@ -1358,19 +1358,12 @@ int Client::link(const char *existing, const char *newname,
     gid = getgid();
   }
   
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  // This is for FUSE support of passing the userid
-  //Ticket *tk;
-  //if (uid == -1 || gid == -1)
-  //  tk = get_user_ticket(getuid(), getgid());
-  //else
-  //  tk = get_user_ticket(uid, gid);
+  //Ticket *tk = get_user_ticket(uid, gid);
 
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
 
   // main path arg is new link name
@@ -1392,7 +1385,7 @@ int Client::link(const char *existing, const char *newname,
   delete reply;
   dout(10) << "link result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1414,13 +1407,12 @@ int Client::unlink(const char *relpath, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
+  //Ticket *tk = get_user_ticket(uid, gid);
 
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1455,7 +1447,7 @@ int Client::unlink(const char *relpath, __int64_t uid, __int64_t gid)
   delete reply;
   dout(10) << "unlink result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1477,13 +1469,12 @@ int Client::rename(const char *relfrom, const char *relto,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
+  //Ticket *tk = get_user_ticket(uid, gid);
 
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string absfrom;
   mkabspath(relfrom, absfrom);
@@ -1514,7 +1505,7 @@ int Client::rename(const char *relfrom, const char *relto,
   delete reply;
   dout(10) << "rename result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1537,12 +1528,12 @@ int Client::mkdir(const char *relpath, mode_t mode, __int64_t uid, __int64_t gid
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
+  //Ticket *tk = get_user_ticket(uid, gid);
   //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1570,7 +1561,7 @@ int Client::mkdir(const char *relpath, mode_t mode, __int64_t uid, __int64_t gid
   delete reply;
   dout(10) << "mkdir result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1591,13 +1582,12 @@ int Client::rmdir(const char *relpath, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
+  //Ticket *tk = get_user_ticket(uid, gid);
 
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1633,7 +1623,7 @@ int Client::rmdir(const char *relpath, __int64_t uid, __int64_t gid)
   delete reply;
   dout(10) << "rmdir result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1657,12 +1647,12 @@ int Client::symlink(const char *reltarget, const char *rellink,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abstarget;
   mkabspath(reltarget, abstarget);
@@ -1693,7 +1683,7 @@ int Client::symlink(const char *reltarget, const char *rellink,
   delete reply;
   dout(10) << "symlink result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1715,12 +1705,12 @@ int Client::readlink(const char *relpath, char *buf, off_t size,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1747,7 +1737,7 @@ int Client::readlink(const char *relpath, char *buf, off_t size,
   if (res > size) res = size;
   memcpy(buf, in->symlink->c_str(), res);
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;  // return length in bytes (to mimic the system call)
@@ -1887,12 +1877,12 @@ int Client::lstat(const char *relpath, struct stat *stbuf,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1911,7 +1901,7 @@ int Client::lstat(const char *relpath, struct stat *stbuf,
     dout(10) << "stat sez size = " << in->inode.size << " ino = " << stbuf->st_ino << endl;
   }
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1934,12 +1924,12 @@ int Client::lstatlite(const char *relpath, struct statlite *stl,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -1964,7 +1954,7 @@ int Client::lstatlite(const char *relpath, struct statlite *stl,
     dout(10) << "stat sez size = " << in->inode.size << " ino = " << in->inode.ino << endl;
   }
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -1988,12 +1978,12 @@ int Client::chmod(const char *relpath, mode_t mode,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -2019,7 +2009,7 @@ int Client::chmod(const char *relpath, mode_t mode,
   delete reply;
   dout(10) << "chmod result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -2042,12 +2032,12 @@ int Client::chown(const char *relpath, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -2077,7 +2067,7 @@ int Client::chown(const char *relpath, __int64_t uid, __int64_t gid)
   delete reply;
   dout(10) << "chown result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -2099,12 +2089,12 @@ int Client::utime(const char *relpath, struct utimbuf *buf,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -2135,7 +2125,7 @@ int Client::utime(const char *relpath, struct utimbuf *buf,
   delete reply;
   dout(10) << "utime result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -2160,12 +2150,12 @@ int Client::mknod(const char *relpath, mode_t mode,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -2195,7 +2185,7 @@ int Client::mknod(const char *relpath, mode_t mode,
 
   delete reply;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
   return res;
@@ -2227,12 +2217,12 @@ int Client::getdir(const char *relpath, map<string,inode_t>& contents,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   string abspath;
   mkabspath(relpath, abspath);
@@ -2312,7 +2302,7 @@ int Client::getdir(const char *relpath, map<string,inode_t>& contents,
 
   delete reply;     //fix thing above first
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return res;
 }
@@ -2525,27 +2515,36 @@ int Client::open(const char *relpath, int flags, __int64_t uid, __int64_t gid)
     uid = getuid();
     gid = getgid();
   }
+  
+  //Ticket *tk = get_user_ticket(uid, gid);
 
-  Ticket *tk = get_user_ticket(uid, gid);
-
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
 
   string abspath;
   mkabspath(relpath, abspath);
   const char *path = abspath.c_str();
+
+  // client access prediction stuff
+  /*
+  inodeno_t this_inode = path_map[abspath];
+  cout << "This inode is " << this_inode << endl;
+
+  if (this_inode != inodeno_t() && successor_inode[uid] != inodeno_t())
+    predicter[uid].add_observation(this_inode, successor_inode[uid]);
+  
+  inodeno_t prediction = predicter[uid].predict_successor(this_inode);
   
-  // note the successor relationship
-  predicter[uid].add_observation(abspath, successor[uid]);
-  string prediction = predicter[uid].predict_successor(abspath);
-  successor[uid] = abspath;
-  if (prediction.size() == 0)
+  if (prediction == inodeno_t()) {
     cout << "Could not make confident prediction" << endl;
-  else
+  }
+  else {
     cout << "Predicted access of " << prediction << endl;
+  }
+  */
 
   dout(3) << "op: fh = client->open(\"" << path << "\", " << flags << ");" << endl;
   tout << "open" << endl;
@@ -2577,9 +2576,17 @@ int Client::open(const char *relpath, int flags, __int64_t uid, __int64_t gid)
   // FIXME where does FUSE maintain user information
   req->set_caller_uid(uid);
   req->set_caller_gid(gid);
-  
+
+  // add prediction info
+  //string pred_string;
+  //if (prediction != inodeno_t()) {
+  //char convertInode[sizeof(prediction)];
+  //memcpy(convertInode, &prediction, sizeof(convertInode));
+  //pred_string = string(convertInode, 8);
+  //}
+
   MClientReply *reply = make_request(req, tryauth); // try auth if writer
-  
+
   assert(reply);
   dout(3) << "op: open_files[" << reply->get_result() << "] = fh;  // fh = " << reply->get_result() << endl;
   tout << reply->get_result() << endl;
@@ -2599,6 +2606,14 @@ int Client::open(const char *relpath, int flags, __int64_t uid, __int64_t gid)
     assert(f->inode);
     f->inode->get();
 
+    // note successor relationships
+    //if (this_inode == inodeno_t() && successor_inode[uid] != inodeno_t())
+    //predicter[uid].add_observation(reply->get_ino(), successor_inode[uid]);
+    
+    // update successor
+    //path_map[abspath] = reply->get_ino();
+    //successor_inode[uid] = reply->get_ino();
+
     if (cmode & FILE_MODE_R) f->inode->num_open_rd++;
     if (cmode & FILE_MODE_W) f->inode->num_open_wr++;
     if (cmode & FILE_MODE_LAZY) f->inode->num_open_lazy++;
@@ -2666,7 +2681,7 @@ int Client::open(const char *relpath, int flags, __int64_t uid, __int64_t gid)
 
   delete reply;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   trim_cache();
   client_lock.Unlock();
 
@@ -2716,12 +2731,12 @@ int Client::close(fh_t fh, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->close(open_files[ " << fh << " ]);" << endl;
   dout(3) << "op: open_files.erase( " << fh << " );" << endl;
@@ -2786,7 +2801,7 @@ int Client::close(fh_t fh, __int64_t uid, __int64_t gid)
   put_inode( in );
   int result = 0;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return result;
 }
@@ -2848,12 +2863,12 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->read(" << fh << ", buf, " << size << ", " << offset << ");   // that's " << offset << "~" << size << endl;
   tout << "read" << endl;
@@ -2949,7 +2964,7 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset,
   dout(10) << "read rvalue " << rvalue << ", r " << r << endl;
 
   // done!
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return rvalue;
 }
@@ -2998,12 +3013,12 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   //dout(7) << "write fh " << fh << " size " << size << " offset " << offset << endl;
   dout(3) << "op: client->write(" << fh << ", buf, " << size << ", " << offset << ");" << endl;
@@ -3120,7 +3135,7 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset,
   in->file_wr_mtime = in->inode.mtime = g_clock.gettime();
 
   // ok!
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return totalwritten;  
 }
@@ -3141,12 +3156,12 @@ int Client::truncate(const char *file, off_t size, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->truncate(\"" << file << "\", " << size << ");" << endl;
   tout << "truncate" << endl;
@@ -3169,7 +3184,7 @@ int Client::truncate(const char *file, off_t size, __int64_t uid, __int64_t gid)
 
   dout(10) << " truncate result is " << res << endl;
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return res;
 }
@@ -3190,12 +3205,12 @@ int Client::fsync(fh_t fh, bool syncdataonly, __int64_t uid, __int64_t gid)
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->fsync(open_files[ " << fh << " ], " << syncdataonly << ");" << endl;
   tout << "fsync" << endl;
@@ -3224,7 +3239,7 @@ int Client::fsync(fh_t fh, bool syncdataonly, __int64_t uid, __int64_t gid)
     while (!done) cond.Wait(client_lock);
   }
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return r;
 }
@@ -3277,12 +3292,12 @@ int Client::lazyio_propogate(int fd, off_t offset, size_t count,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->lazyio_propogate(" << fd
           << ", " << offset << ", " << count << ")" << endl;
@@ -3313,7 +3328,7 @@ int Client::lazyio_propogate(int fd, off_t offset, size_t count,
     }
   }
 
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return 0;
 }
@@ -3334,12 +3349,12 @@ int Client::lazyio_synchronize(int fd, off_t offset, size_t count,
     gid = getgid();
   }
 
-  Ticket *tk = get_user_ticket(uid, gid);
-  //Ticket *tk = get_user_ticket(getuid(), getgid());
-  if (!tk) {
-    client_lock.Unlock();
-    return -EPERM;
-  }
+  //Ticket *tk = get_user_ticket(uid, gid);
+
+  //if (!tk) {
+  //  client_lock.Unlock();
+  //  return -EPERM;
+  //}
 
   dout(3) << "op: client->lazyio_synchronize(" << fd
           << ", " << offset << ", " << count << ")" << endl;
@@ -3365,7 +3380,7 @@ int Client::lazyio_synchronize(int fd, off_t offset, size_t count,
     }
   }
   
-  put_user_ticket(tk);
+  //put_user_ticket(tk);
   client_lock.Unlock();
   return 0;
 }
index 95be526a10de9b75e955e74992df71db865fb78f..dfa999f98b2cb99757184980c5556dbfada6f865 100644 (file)
@@ -532,6 +532,8 @@ protected:
 
   // prediction
   map<uid_t, string > successor;
+  map<uid_t, inodeno_t> successor_inode;
+  map<string, inodeno_t> path_map;
   map<uid_t, RecentPopularity> predicter;
 
   Ticket *get_user_ticket(uid_t uid, gid_t gid);
index 3f96ab6961baca61c86a49f1ea304291ae2defe5..46c4b18bb491564b5d5d47cb4dc6ae2481c4bdc4 100644 (file)
@@ -313,6 +313,8 @@ md_config_t g_conf = {
   fix_client_id:          0, /* 0=off, 1=on */
   renewal:                0, /* 0=off, 1=on */
   renewal_period:         240, /* renew every 4 minutes */
+  config_predict:         0, /* 0=off, non-zero = filename ptr */
+  collect_predictions:    0, /* 0=off, 1=on */
   client_aux:             0, /* 0=off, 1=on */
   sign_scheme:            0, /* 0=esign, 1=RSA */
   hash_scheme:            0, /* 0=sha-1, 1=sha-256,
@@ -803,6 +805,10 @@ void parse_config_options(std::vector<char*>& args)
       g_conf.renewal = atoi(args[++i]);
     else if (strcmp(args[i], "--renewal_period") == 0)
       g_conf.renewal_period = atoi(args[++i]);
+    else if (strcmp(args[i], "--config_predict") == 0)
+      g_conf.config_predict = args[++i];
+    else if (strcmp(args[i], "--collect_predictions") == 0)
+      g_conf.collect_predictions = atoi(args[++i]);
 
     else if (strcmp(args[i], "--file_layout_ssize") == 0) 
       g_OSD_FileLayout.stripe_size = atoi(args[++i]);
index ce586d71d55030235b1ddae9d85ecfeb1368352a..5deafe005404ba69e50783961ec4ae709c7ad171 100644 (file)
@@ -303,6 +303,8 @@ struct md_config_t {
   int fix_client_id;
   int renewal;
   int renewal_period;
+  char* config_predict;
+  int collect_predictions;
   int client_aux;
   int sign_scheme;
   int hash_scheme;
index f392cc653422cf02ec60c2dccbfabf68bc6d7678..412ba8a414eadb191d45a1e43ae767b0574f9fc6 100644 (file)
@@ -98,6 +98,8 @@ class CapGroup {
     //FIXME need to re-compute hash
   }
 
+  int num_inodes() { return inodes.size(); }
+
   bool contains(uid_t user) {
     for (list<uid_t>::iterator ui = users.begin();
         ui != users.end();
index 8904ce24bb2c8bc884e29b9b1898963fece2d414..aaf53bb0a540992a60c4a1df6cf4f980b77f5465 100644 (file)
@@ -19,28 +19,39 @@ class RecentPopularity {
   int J;
   // sequence size parameter (6 is a happy default)
   int K;
-  map < string, deque<string> > inode_sequences;
+  map < inodeno_t, deque<inodeno_t> > inode_sequences;
 public:
   RecentPopularity() : J(4), K(6) {}
   RecentPopularity(int jay, int kay) : J(jay), K(kay) {}
+  RecentPopularity(map<inodeno_t, deque<inodeno_t> > sequence) : J(4), K(6),
+                                                                inode_sequences(sequence) {}
   
-  void add_observation(string X, string successor) {
+
+  map<inodeno_t, deque<inodeno_t> >& get_sequence() { return inode_sequences; }
+  void add_observation(inodeno_t X, inodeno_t successor) {
     inode_sequences[X].push_back(successor);
     
     if (inode_sequences[X].size() > (unsigned)K)
       inode_sequences[X].pop_front();
   }
 
-  string predict_successor(string X) {
+  inodeno_t predict_successor(inodeno_t X) {
+
+    //debug -- remove this at some point
+    //for (deque<inodeno_t>::reverse_iterator test_it = inode_sequences[X].rbegin();
+    //test_it != inode_sequences[X].rend();
+    //test_it++) {
+    //cout << *test_it << endl;
+    //}
 
     // is our known sequence big enough?
     if (inode_sequences[X].size() < (unsigned)K)
-      return string();
+      return inodeno_t();
 
     // can we make a prediction with confidence?
-    set<string> checked_inodes;
+    set<inodeno_t> checked_inodes;
     unsigned int index = 0;
-    for (deque<string>::reverse_iterator iri = inode_sequences[X].rbegin();
+    for (deque<inodeno_t>::reverse_iterator iri = inode_sequences[X].rbegin();
         iri != inode_sequences[X].rend();
         iri++) {
       
@@ -50,7 +61,7 @@ public:
        // are there enough unchecked inodes to even keep going?
        if (inode_sequences[X].size() - index >= (unsigned)J) {
          int occurance = 0;
-         for (deque<string>::reverse_iterator ini = iri;
+         for (deque<inodeno_t>::reverse_iterator ini = iri;
               ini != inode_sequences[X].rend();
               ini++) {
            
diff --git a/branches/aleung/security1/ceph/crypto/UserBatch.h b/branches/aleung/security1/ceph/crypto/UserBatch.h
new file mode 100644 (file)
index 0000000..7087c7d
--- /dev/null
@@ -0,0 +1,202 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
+
+#ifndef __USERBATCH_H
+#define __USERBATCH_H
+
+#include "include/types.h"
+#include "common/Clock.h"
+#include "common/Mutex.h"
+#include "common/Cond.h"
+
+#include "messages/MClientRequest.h"
+//#include "mds/Server.h"
+
+class Server;
+//class MDS;
+
+class UserBatch {
+
+  Server *server;
+  MDS *mds;
+
+  // is the thread initiated
+  bool thread_init;
+  // is the thread running
+  bool batch_stop;
+  // are we batching requests
+  bool batching;
+
+  Mutex batch_lock;
+  Cond batch_cond;
+
+public:
+  utime_t one_req_ago;
+  utime_t two_req_ago;
+  uid_t user;
+  gid_t user_group;
+
+  set<MClientRequest*> batched_requests;
+  bool batch_id_set;
+  cap_id_t batch_id;
+
+  class BatchThread : public Thread {
+    UserBatch *batch;
+  public:
+    BatchThread() {}
+    BatchThread  (UserBatch *ub) : batch (ub) {}
+    void *entry() {
+      batch->batch_entry();
+      return 0;
+    }
+  } batch_thread;
+
+  UserBatch(Server *serve, MDS* metads) : server(serve), mds(metads) {
+    thread_init = false;
+    batching = false;
+    batch_stop = false;
+    batch_thread = BatchThread(this);
+    batch_thread.create();
+  }
+  ~UserBatch () {
+    batch_lock.Lock();
+    batch_stop = true;
+    batch_cond.Signal();
+    batch_lock.Unlock();
+    batch_thread.join();
+  }
+
+  bool is_batching() { return batching; }
+  bool should_batch(utime_t new_request_time) {
+    //if (new_request_time - two_req_ago < utime_t(0,10000)) // 10ms between
+    if (new_request_time > utime_t()) // always batch
+      return true;
+    return false;
+  }
+  void update_batch_time(utime_t new_request_time) {
+    two_req_ago = one_req_ago;
+    one_req_ago = new_request_time;
+  }
+
+  void add_to_batch(MClientRequest *req) {
+    dout(1) << "Batching the request for uid:"
+           << req->get_caller_uid() << " on client:"
+           << req->get_client() << " for file:"
+           << req->get_ino() << " with client inst:"
+           << req->get_client_inst() << endl;
+    
+    batch_lock.Lock();
+    
+    // wait until the thread has initialized
+    while (! thread_init)
+      batch_cond.Wait(batch_lock);
+    
+    // was batching thread already on?
+    if (batching) {
+      batched_requests.insert(req);
+    }
+    else {
+      // set the user were batching for
+      user = req->get_caller_uid();
+      user_group = req->get_caller_gid();
+
+      // set the future capid
+      batch_id.cid = mds->cap_id_count;
+      batch_id.mds_id = mds->get_nodeid();
+      mds->cap_id_count++;
+      
+      batching = true;
+      batch_id_set = true;
+      
+      batched_requests.insert(req);
+      
+      // start the buffering now
+      batch_cond.Signal();
+    }
+    
+    batch_lock.Unlock();
+    return;
+  }
+
+  void batch_entry()
+  {
+    cout << "batch thread start------>" << endl;
+    batch_lock.Lock();
+    
+    // init myself and signal anyone waiting for me to init
+    thread_init = true;
+    batch_cond.Signal();
+    
+    while(!batch_stop) {
+      
+      // ifwe're not buffering, then,
+      // were gonna get signaled when we start buffering
+      // plus i need to release the lock for anyone
+      // waiting for me to init
+      while (!batching)
+       batch_cond.Wait(batch_lock);
+      
+      // the sleep releases the lock and allows the dispatch
+      // to insert requests into the buffer
+      // sleep first, then serve cap
+      batch_cond.WaitInterval(catch_lock, utime_t(5,0));
+      
+      // now i've slept, make cap for users
+      list<inodeno_t> inode_list;
+      CapGroup inode_hash;
+      for (set<MClientRequest *>::iterator si = buffered_reqs.begin();
+          si != buffered_reqs.end();
+          si++) {
+       inode_list.push_back((*ii)->get_ino());
+       inode_hash.add_inode((*ii)->get_ino());
+      }
+      inode_hash.sign_list(mds->getPrvKey());
+      mds->unix_groups_byhash[inode_hash.get_root_hash()]= inode_hash;
+      
+      ExtCap *ext_cap = new ExtCap(FILE_MODE_RW,
+                                  user,
+                                  user_group,
+                                  inode_hash.get_root_hash());
+      ext_cap->set_type(USER_BATCH);
+      ext_cap->set_id(batch_id);
+      ext_cap->sign_extcap(mds->getPrvKey());
+      
+      // put the cap every inodes cache
+      CInode *inode_cache;
+      for (list<inodeno_t>::iterator ili = inode_list.begin();
+          ili != inode_list.end();
+          ili++) {
+       inode_cache= mds->mdcache->inode_map[(*ili)];
+       inode_cache->add_user_extcap(user, ext_cap);
+      }
+      
+      // let requests loose
+      for (set<MClientRequest *>::iterator ri = batched_requests.begin();
+          ri != batched_requests.end();
+          ri++) {
+       server->handle_client_open(*ri, this);
+      }
+      
+      batched_requests.clear();
+      
+      //turn batching off
+      batching = false;
+    }
+    
+    batch_lock.Unlock();
+    cout << "<------batcher thread finish" << endl;
+  }
+  
+};
+
+#endif
index 2eb9c503de5a5967f96eb35a2813c8968b922d98..ae9ea6ff59ccd234473afec435e02b6a65e2fe3c 100644 (file)
@@ -13,7 +13,7 @@
  * Author: Andrew Leung Nov., 2006
  ******************************/
 #include"CryptoLib.h"
-#include "MerkleTree.h"
+//#include "MerkleTree.h"
 #include<iostream>
 
 using namespace std;
@@ -23,6 +23,7 @@ int main(int argc, char* argv[]) {
   // message to hash
   const byte* msg = (const byte*)"hash me";
 
+  /*
   // test merkle trees
   MerkleTree mtree;
   uid_t user1 = 1000;
@@ -36,6 +37,7 @@ int main(int argc, char* argv[]) {
     cout << "mtree2 is bigger" << endl;
   else
     cout << "mtree is bigger" << endl;
+  */
 
   // sha-1
   byte digest[SHA1DIGESTSIZE];
@@ -72,6 +74,7 @@ int main(int argc, char* argv[]) {
   toHex(digestmd5, hexmd5, MD5DIGESTSIZE, 2*MD5DIGESTSIZE);
   cout << "MD5 of " << msg << " is " << string((const char*)hexmd5,2*MD5DIGESTSIZE) << endl;
 
+  
   // esign signature
   byte* signMsg = (byte *)"Message to sign is getting bigger by the minutefdsfdfdsffdfsfsdfdsfdfdsfsdfdsfsdfdsfsdsfdssdfsdfdsfdsffds";
   //char* keyInput = "esig1536.dat";
@@ -79,6 +82,7 @@ int main(int argc, char* argv[]) {
   esignPriv privKey = esignPrivKey(keyInput);
   esignPub pubKey = esignPubKey(privKey);
   SigBuf mySignature = esignSig(signMsg, strlen((const char*)signMsg), privKey);
+
   // testing --> remove me!
   byte testBuf[mySignature.size()];
   memcpy((void*)testBuf,(void*)mySignature, mySignature.size());
@@ -136,6 +140,8 @@ int main(int argc, char* argv[]) {
   else
     cout << "Array copy Key failed" << endl;
 
+  /*
+
   // RSA signature
   byte* rsaMsg = (byte *)"Message to sign";
   char* rsaInput = "rsa1024.dat";
@@ -217,5 +223,7 @@ int main(int argc, char* argv[]) {
   decryptRC5(cipherRC5, plainRC5len, recoverRC5, decRC5);
   cout << "My recovered message is " << recoverRC5 << endl;
 
+  */
+
   return 0;
 }
index d15c4fc567c73e83050be2a3f7185e355337ee1f..8013e826a8991c417d3cc21e800dda0a275c28d5 100644 (file)
@@ -249,6 +249,12 @@ ExtCap* Locker::issue_new_extcaps(CInode *in, int mode, MClientRequest *req) {
     else
       ext_cap = in->get_unix_world_cap();
   }
+  if (g_conf.mds_group == 4) {
+    if (mds->predict_cap_cache[in->ino()].count(my_user) == 0)
+      ext_cap = 0;
+    else
+      ext_cap = &(mds->predict_cap_cache[in->ino()][my_user]);
+  }
   // no grouping
   else 
     ext_cap = in->get_user_extcap(my_user);
@@ -302,6 +308,23 @@ ExtCap* Locker::issue_new_extcaps(CInode *in, int mode, MClientRequest *req) {
       
       ext_cap->set_type(1);
       
+    }
+    // do prediction
+    else if (g_conf.mds_group == 4) {
+      // can we make any predictions?
+      if (mds->precompute_succ.count(in->ino()) != 0) {
+       cout << "Making a prediction in capability for " << in->ino() << endl;
+       // add the hash
+       hash_t inode_hash = mds->precompute_succ[in->ino()];
+       ext_cap = new ExtCap(FILE_MODE_RW, my_user, my_group, inode_hash);
+       ext_cap->set_type(USER_BATCH);
+      }
+      else {
+       cout << "Can't make predictions for this cap for " << in->ino() << endl;
+       ext_cap = new ExtCap(my_want, my_user, in->ino());
+       ext_cap->set_type(0);
+      }
+
     }
     // default no grouping
     else {
@@ -327,6 +350,20 @@ ExtCap* Locker::issue_new_extcaps(CInode *in, int mode, MClientRequest *req) {
       else
        in->set_unix_world_cap(ext_cap);
     }
+    else if (g_conf.mds_group == 4) {
+      // did we use a hash for the inodes?
+      if (ext_cap->get_type() == USER_BATCH) {
+       hash_t inode_hash = ext_cap->get_file_hash();
+       list<inodeno_t> inode_list = mds->unix_groups_byhash[inode_hash].get_inode_list();
+       // cache in every inode included in the cap
+       for (list<inodeno_t>::iterator lii = inode_list.begin();
+            lii != inode_list.end();
+            lii++) {
+         mds->predict_cap_cache[*lii][my_user] = (*ext_cap);
+       }
+      }
+      mds->predict_cap_cache[in->ino()][my_user] = (*ext_cap);
+    }
     else
       in->add_user_extcap(my_user,ext_cap);
 
index 159ba79403898a0a6fc0414768ecd64be1135c39..d461f8d2f25b8dcf1320b79cf25d78ead634f7b6 100644 (file)
@@ -98,6 +98,7 @@ MDS::MDS(int whoami, Messenger *m, MonMap *mm) : timer(mds_lock) {
   myPrivKey = esignPrivKey("crypto/esig1023.dat");
   myPubKey = esignPubKey(myPrivKey);
 
+
   // create unix_groups from file?
   if (g_conf.unix_group_file) {
     ifstream from(g_conf.unix_group_file);
@@ -150,6 +151,40 @@ MDS::MDS(int whoami, Messenger *m, MonMap *mm) : timer(mds_lock) {
     }
   }
 
+  // do prediction read-in
+  if (g_conf.mds_group == 4) {
+    map<inodeno_t, deque<inodeno_t> > sequence;
+    int off = 0;
+    bufferlist bl;
+    server->get_bl_ss(bl);
+    ::_decode(sequence, bl, off);
+    rp_predicter = RecentPopularity(sequence);
+
+    for (map<inodeno_t, deque<inodeno_t> >::iterator mi = sequence.begin();
+        mi != sequence.end();
+        mi++) {
+      CapGroup inode_list;
+      inodeno_t prediction;
+      prediction = rp_predicter.predict_successor(mi->first);
+      
+      cout << "Predictions for " << mi->first << ": ";
+      while(prediction != inodeno_t()) {
+       cout << prediction << ", ";
+       inode_list.add_inode(prediction);
+       prediction = rp_predicter.predict_successor(prediction);
+
+      }
+      cout << "Cannot make any further predictions" << endl;
+
+      // cache the list
+      if (inode_list.num_inodes() != 0) {
+       inode_list.sign_list(myPrivKey);
+       unix_groups_byhash[inode_list.get_root_hash()] = inode_list;
+       precompute_succ[mi->first] = inode_list.get_root_hash();
+      }
+    }
+  }
+
   // cap identifiers
   cap_id_count = 0;
  
index 69370d09c7c9f207795500b479d416bed2ee2f24..27c204678c1dd5dc37ff963b960f440066039c37 100644 (file)
@@ -50,6 +50,7 @@ using namespace CryptoLib;
 #include "crypto/CapGroup.h"
 #include "crypto/MerkleTree.h"
 #include "crypto/Renewal.h"
+#include "crypto/RecentPopularity.h"
 
 #define MDS_PORT_MAIN     0
 #define MDS_PORT_SERVER   1
@@ -175,6 +176,12 @@ public:
   // batched file groups by user
   map<uid_t, UserBatch*> user_batch;
 
+  // successors
+  RecentPopularity rp_predicter;
+  inodeno_t last_access;
+  map<inodeno_t, hash_t> precompute_succ;
+  map<inodeno_t , map<uid_t, ExtCap> > predict_cap_cache;
+
   void queue_waitfor_active(Context *c) { waitfor_active.push_back(c); }
 
   bool is_dne()      { return state == MDSMap::STATE_DNE; }
index c8b19a0c0b34e6e0447b7e327fbc5a99b9a8c144..dac2eb23c5a0299d689dd39576c35b6ea47f3df3 100644 (file)
@@ -2297,7 +2297,138 @@ void Server::handle_client_truncate(MClientRequest *req, CInode *cur)
                  new EString("truncate fixme"));
 }
 
+set<inodeno_t> Server::parse_predictions(string pred_string) {
+  // get number of predictions
+  int first_index = pred_string.find_first_of(",");
+  int num_preds = atoi(pred_string.substr(0, first_index).c_str());
+  cout << "Number of predictions to make " << num_preds << endl;
+  
+  string str_to_parse = pred_string.substr(first_index+1, pred_string.size()-1);
+  cout << "Remaining string " << str_to_parse << ":" << endl;
+  
+  set<inodeno_t> successors;
+  string pred;
+  inodeno_t place_holder_inode;
+  int comma_index;
+  for (int parser = 0; parser < num_preds; parser++) {
+
+    comma_index = str_to_parse.find_first_of(",");
+    pred = str_to_parse.substr(0, comma_index);
+    cout << "Got token " << pred << ":" << endl;
+    if (pred == ";")
+      break;
+
+    memset((byte*)&place_holder_inode, 0x00, sizeof(place_holder_inode));
+    memcpy((byte*)&place_holder_inode, pred.c_str(), pred.size());
+    successors.insert(place_holder_inode);
+    cout << "Just inserted place_holder_inode " << place_holder_inode << endl;
+    str_to_parse = str_to_parse.substr(comma_index+1, str_to_parse.size()-1);
+  }
+
+  return successors;
+}
+
+int Server::get_bl_ss(bufferlist& bl)
+{
+  string dir = "/home/aleung/ssrc/ceph/branches/aleung/security1/ceph";
+  /*
+  char fn[200];
+  if (b) {
+    sprintf(fn, "%s/%s/%s", dir.c_str(), a, b);
+  } else {
+    sprintf(fn, "%s/%s", dir.c_str(), a);
+  }
+  */
+  char fn[200];
+  sprintf(fn, "predictions");
+  
+  int fd = ::open(fn, O_RDONLY);
+  if (!fd) {
+    /*
+    if (b) {
+      dout(15) << "get_bl " << a << "/" << b << " DNE" << endl;
+    } else {
+      dout(15) << "get_bl " << a << " DNE" << endl;
+    }
+    */
+    dout(15) << "get_bl predictions DNE" << endl;
+    return 0;
+  }
 
+  // get size
+  struct stat st;
+  int rc = ::fstat(fd, &st);
+  assert(rc == 0);
+  __int32_t len = st.st_size;
+  // read buffer
+  bl.clear();
+  bufferptr bp(len);
+  int off = 0;
+  while (off < len) {
+    dout(20) << "reading at off " << off << " of " << len << endl;
+    int r = ::read(fd, bp.c_str()+off, len-off);
+    if (r < 0) derr(0) << "errno on read " << strerror(errno) << endl;
+    assert(r>0);
+    off += r;
+  }
+  bl.append(bp);
+  ::close(fd);
+
+  /*
+  if (b) {
+    dout(15) << "get_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl;
+  } else {
+    dout(15) << "get_bl " << a << " = " << bl.length() << " bytes" << endl;
+  }
+  */
+  dout(15) << "get_bl predictions = " << bl.length() << " bytes" << endl;
+
+  return len;
+}
+
+int Server::put_bl_ss(bufferlist& bl)
+{
+  string dir = "/home/aleung/ssrc/ceph/branches/aleung/security1/ceph";
+  /*
+  char fn[200];
+  sprintf(fn, "%s/%s", dir.c_str(), a);
+  if (b) {
+    ::mkdir(fn, 0755);
+    dout(15) << "put_bl " << a << "/" << b << " = " << bl.length() << " bytes" << endl;
+    sprintf(fn, "%s/%s/%s", dir.c_str(), a, b);
+  } else {
+    dout(15) << "put_bl " << a << " = " << bl.length() << " bytes" << endl;
+  }
+  
+  char tfn[200];
+  sprintf(tfn, "%s.new", fn);  
+  */
+  char tfn[200];
+  sprintf(tfn, "predictions");
+  int fd = ::open(tfn, O_WRONLY|O_CREAT);
+  assert(fd);
+  
+  // chmod
+  ::fchmod(fd, 0644);
+
+  // write data
+  for (list<bufferptr>::const_iterator it = bl.buffers().begin();
+       it != bl.buffers().end();
+       it++)  {
+    int r = ::write(fd, it->c_str(), it->length());
+    if (r != (int)it->length())
+      derr(0) << "put_bl_ss ::write() returned " << r << " not " << it->length() << endl;
+    if (r < 0) 
+      derr(0) << "put_bl_ss ::write() errored out, errno is " << strerror(errno) << endl;
+  }
+
+  ::fsync(fd);
+  ::close(fd);
+  //::rename(tfn, fn);
+
+  return 0;
+}
 
 // ===========================
 // open, openc, close
@@ -2321,6 +2452,23 @@ void Server::handle_client_open(MClientRequest *req,
     return;
   }
 
+
+  // check file prediction stuff
+  if (g_conf.collect_predictions != 0) {
+    // if this isnt the first access
+    if (mds->last_access != inodeno_t() && mds->last_access != cur->ino()) {
+      cout << "Observed " << cur->ino() << " followed "
+          << mds->last_access << endl;
+
+      mds->rp_predicter.add_observation(mds->last_access, cur->ino());
+      bufferlist bl;
+      ::_encode(mds->rp_predicter.get_sequence(), bl);
+      put_bl_ss(bl);
+    }
+
+    mds->last_access = cur->ino();
+  }
+  
   // auth for write access
   // redirect the write open to the auth?
   if (mode != FILE_MODE_R && mode != FILE_MODE_LAZY &&
index da96243f44ae6deb7076696e13faa4c0b038b83c..f8ed795043b4b8e911a29133b302e3dc48a1838d 100644 (file)
@@ -141,6 +141,11 @@ public:
                    CInode **pin, CDentry **pdn, 
                    bool okexist=false);
 
+  // prediction stuff
+  set<inodeno_t> parse_predictions(string pred_string);
+  int put_bl_ss(bufferlist& bl);
+  int get_bl_ss(bufferlist& bl);
+
 
 
 };
index d72afca05cd5c31c4c695ce3b5bb86b0cef6df36..2aabf12ba72a691b8414229e1f5f651c89222081 100644 (file)
@@ -22,11 +22,16 @@ class MClientAuthUser : public Message {
   uid_t uid;
   gid_t gid;
   string pubKey;
+  //char userPublicKey[ESIGNKEYSIZE];
   
  public:
   MClientAuthUser() : Message(MSG_CLIENT_AUTH_USER) {}
   MClientAuthUser(string un, uid_t u, gid_t g, string k) : 
     Message(MSG_CLIENT_AUTH_USER), username(un), uid(u), gid(g), pubKey(k) { }
+  //MClientAuthUser(string un, uid_t u, gid_t g, byte* k) : 
+  //  Message(MSG_CLIENT_AUTH_USER), username(un), uid(u), gid(g) {
+  //  memset(userPublicKey, k, ESIGNKEYSIZE);
+  //}
 
   char *get_type_name() { return "client_auth_user"; }
   const string& get_str_key() { return pubKey; }
index 6bd18c3dae8c2c9d1d9a81fb794b838ec6199020..2a8f066316705d1c37ca2d3344755a3d41d2824a 100644 (file)
@@ -75,8 +75,21 @@ class MClientRequest : public Message {
   string sarg;
   string sarg2;
 
-
  public:
+
+  // prediction hints (totally hacky)
+  //int predictions;
+  //string hint1;
+  //string hint2;
+  //string hint3;
+  //string hint4;
+  //string hint5;
+  //string hint6;
+  //string hint7;
+  //string hint8;
+  //string hint9;
+  //string hint10;
+
   MClientRequest() {}
   MClientRequest(int op, int client) : Message(MSG_CLIENT_REQUEST) {
     memset(&st, 0, sizeof(st));
@@ -111,7 +124,7 @@ class MClientRequest : public Message {
   void set_iarg2(int i) { st.iarg2 = i; }
   void set_targ(time_t& t) { st.targ = t; }
   void set_targ2(time_t& t) { st.targ2 = t; }
-  void set_sarg(string& arg) { this->sarg = arg; }
+  void set_sarg(string& arg) { this->sarg = arg; } 
   void set_sarg(const char *arg) { this->sarg = arg; }
   void set_sarg2(string& arg) { this->sarg2 = arg; }
   void set_sizearg(size_t s) { st.sizearg = s; }
@@ -121,6 +134,9 @@ class MClientRequest : public Message {
   void set_client_inst(const entity_inst_t& i) { st.client_inst = i; }
   const entity_inst_t& get_client_inst() { return st.client_inst; }
 
+  //void set_num_hints(int hints) { st.num_hints = hints; }
+  //int get_num_hints() { return st.num_hints; }
+
   int get_client() { return st.client; }
   long get_tid() { return st.tid; }
   int get_op() { return st.op; }
@@ -146,6 +162,21 @@ class MClientRequest : public Message {
     path._decode(payload, off);
     _decode(sarg, payload, off);
     _decode(sarg2, payload, off);
+
+    //payload.copy(off, sizeof(sarg2), (char*)&sarg2);
+    //off += sizeof(sarg2); 
+    //payload.copy(off, sizeof(int), (char*)&predictions);
+    //off += sizeof(int); 
+    //_decode(hint1, payload, off);
+    //_decode(hint2, payload, off);
+    //_decode(hint3, payload, off);
+    //_decode(hint4, payload, off);
+    //_decode(hint5, payload, off);
+    //_decode(hint6, payload, off);
+    //_decode(hint7, payload, off);
+    //_decode(hint8, payload, off);
+    //_decode(hint9, payload, off);
+    //_decode(hint10, payload, off);
   }
 
   virtual void encode_payload() {
@@ -153,6 +184,22 @@ class MClientRequest : public Message {
     path._encode(payload);
     _encode(sarg, payload);
     _encode(sarg2, payload);
+    //bufferlist helper;
+    //helper.append(sarg2.c_str(), sarg2.size());
+    //payload.append(helper);
+
+    //payload.append((char*)&sarg2, sizeof(sarg2));
+    //payload.append((char*)&predictions, sizeof(int));
+    //_encode(hint1, payload);
+    //_encode(hint2, payload);
+    //_encode(hint3, payload);
+    //_encode(hint4, payload);
+    //_encode(hint5, payload);
+    //_encode(hint6, payload);
+    //_encode(hint7, payload);
+    //_encode(hint8, payload);
+    //_encode(hint9, payload);
+    //_encode(hint10, payload);
   }
 
   void print(ostream& out) {
index b2d3aad543bbd219497f890a2b9d8f8984b5430e..702017395ae0041b4567fc370298c18c1b3ad1a1 100755 (executable)
@@ -60,11 +60,6 @@ for $file_handle(@files) {
                    }
                }
 
-               #if (! $seen_paths{$dirpath}) {
-               #    $seen_paths{$dirpath} = 1;
-               #    print "mkdir\n\/$dirpath\n493\n";
-               #}
-               
            }
        }
        
index 323616990811984b8a3a84c2e34ced4a092e759e..aa2f048a2e7795e8085afdc8c17ea85e14be0b07 100644 (file)
@@ -46,6 +46,7 @@ class MonMap {
     pub_key = esignPubKey(tempKey);
     //pub_str_key = pubToString(pub_key);
     memcpy(pub_str_key, pubToString(pub_key).c_str(), sizeof(pub_str_key));
+    
     // now throw away the private key
     keyConvert = false;
   }
index 840b9d3eb106ad1646c306d22a3ee274fc886624..f2ca50d6517b0480073449a9a9e4262df596b05a 100644 (file)
@@ -48,8 +48,6 @@ void Monitor::set_new_private_key(char *pk)
   myPrivKey = _fromStr_esignPrivKey(string(pk, ESIGNPRIVSIZE));
   myPubKey = esignPubKey(myPrivKey);
   
-  // FIXME.
-  //assert(0);
 }
 
 void Monitor::init()
@@ -97,8 +95,7 @@ void Monitor::init()
     // der?
     //myPrivKey = esignPrivKey("crypto/esig1536.dat");
     //myPubKey = esignPubKey(myPrivKey);
-
-    // assert(0);
+    
   }
 
   // create 
index c49639bebdedadcd6f32ec3847bbb16c12609f09..0f527ba0352421c92223bbda56702d3ec301b34b 100644 (file)
@@ -388,8 +388,9 @@ void OSDMonitor::handle_osd_boot(MOSDBoot *m)
     // waiting for boot!
     // add the OSD instance to the map?
     osdmap.osd_inst[from] = m->get_source_inst();
+
     // adds the key to the map
-    osdmap.osd_str_keys[from] = m->get_public_key();
+    //osdmap.osd_str_keys[from] = m->get_public_key();
 
     if (osdmap.osd_inst.size() == osdmap.osds.size()) {
       dout(7) << "osd_boot all osds booted." << endl;
index 06598d6a1cd99e63ee4bf016b1f3b3ce3e849523..e0cf25232877096b9db06c011696615300bf05de 100644 (file)
@@ -78,8 +78,8 @@ public:
     list<int> new_out;
     map<int,float> new_overload;  // updated overload value
     list<int>      old_overload;  // no longer overload
-    map<int,string> added_osd_keys; // new public keys
-    list<int> removed_osd_keys; // public keys to remove
+    //map<int,string> added_osd_keys; // new public keys
+    //list<int> removed_osd_keys; // public keys to remove
     
     void encode(bufferlist& bl) {
       bl.append((char*)&epoch, sizeof(epoch));
@@ -90,8 +90,8 @@ public:
       ::_encode(new_in, bl);
       ::_encode(new_out, bl);
       ::_encode(new_overload, bl);
-      ::_encode(added_osd_keys, bl);
-      ::_encode(removed_osd_keys, bl);
+      //::_encode(added_osd_keys, bl);
+      //::_encode(removed_osd_keys, bl);
     }
     void decode(bufferlist& bl, int& off) {
       bl.copy(off, sizeof(epoch), (char*)&epoch);
@@ -105,8 +105,8 @@ public:
       ::_decode(new_in, bl, off);
       ::_decode(new_out, bl, off);
       ::_decode(new_overload, bl, off);
-      ::_decode(added_osd_keys, bl, off);
-      ::_decode(removed_osd_keys, bl, off);
+      //::_decode(added_osd_keys, bl, off);
+      //::_decode(removed_osd_keys, bl, off);
     }
 
     Incremental(epoch_t e=0) : epoch(e), mon_epoch(0) {}
@@ -124,8 +124,8 @@ private:
   set<int>  out_osds;    // list of unmapped disks
   map<int,float> overload_osds; 
   map<int,entity_inst_t> osd_inst;
-  map<int,string> osd_str_keys; //all public keys in str form
-  map<int,esignPub> osd_keys; // all public key objects (cache)
+  //map<int,string> osd_str_keys; //all public keys in str form
+  //map<int,esignPub> osd_keys; // all public key objects (cache)
 
  public:
   Crush     crush;       // hierarchical map
@@ -156,6 +156,7 @@ private:
   const set<int>& get_down_osds() { return down_osds; }
   const set<int>& get_out_osds() { return out_osds; }
   const map<int,float>& get_overload_osds() { return overload_osds; }
+  /*
   const map<int,string>& get_key_str_map() { return osd_str_keys; }
   const map<int,esignPub>& get_key_map() { return osd_keys; }
   const esignPub get_key(int client) { 
@@ -170,6 +171,7 @@ private:
     return tempPub;
   }
   const string& get_str_keys(int client) { return osd_str_keys[client]; }
+  */
   
   bool is_down(int osd) { return down_osds.count(osd); }
   bool is_up(int osd) { return !is_down(osd); }
@@ -245,6 +247,7 @@ private:
       overload_osds.erase(*i);
     }
     // add the incremental keys to osd_keys
+    /*
     for (map<int,string>::iterator i = inc.added_osd_keys.begin();
          i != inc.added_osd_keys.end();
          i++) {
@@ -256,6 +259,7 @@ private:
       assert(osd_str_keys.count(*i)); // sanity check
       osd_str_keys.erase(*i);
     }
+    */
   }
 
   // serialize, unserialize
@@ -270,7 +274,7 @@ private:
     _encode(out_osds, blist);
     _encode(overload_osds, blist);
     _encode(osd_inst, blist);
-    _encode(osd_keys, blist);
+    //_encode(osd_keys, blist);
     
     crush._encode(blist);
   }
@@ -291,7 +295,7 @@ private:
     _decode(out_osds, blist, off);
     _decode(overload_osds, blist, off);
     _decode(osd_inst, blist, off);
-    _decode(osd_keys, blist, off);
+    //_decode(osd_keys, blist, off);
     
     crush._decode(blist, off);
   }