]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
calc update latency w/ optimizaitons
authoranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 20 Mar 2007 16:41:32 +0000 (16:41 +0000)
committeranwleung <anwleung@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 20 Mar 2007 16:41:32 +0000 (16:41 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1265 29311d96-e01e-0410-9327-a35deaab8ce9

branches/aleung/security1/ceph/crypto/CryptoLib.cc
branches/aleung/security1/ceph/crypto/CryptoLib.h
branches/aleung/security1/ceph/crypto/ExtCap.h
branches/aleung/security1/ceph/mds/MDS.h
branches/aleung/security1/ceph/mon/MonMap.h
branches/aleung/security1/ceph/osd/OSD.cc
branches/aleung/security1/ceph/osd/OSD.h

index 26b2cec093794294f7c9b95e0c79092b9a821255..a056e483cd70afb0caaae7867fd0c618ce3f803a 100644 (file)
@@ -208,7 +208,7 @@ ESIGN<SHA>::Verifier CryptoLib::_fromStr_esignPubKey(string seedString) {
  **********/
 CryptoLib::SigBuf CryptoLib::esignSig(byte* dataBuf,
                                      const unsigned int dataLen,
-                                     CryptoLib::esignPriv privKey) {
+                                     const CryptoLib::esignPriv& privKey) {
   // a linear congruential random num gen
   LC_RNG rng(time(NULL));
   SecByteBlock signature(privKey.SignatureLength());
@@ -224,7 +224,7 @@ CryptoLib::SigBuf CryptoLib::esignSig(byte* dataBuf,
  * and the public key
  **********/
 bool CryptoLib::esignVer(byte* dataBuf, const unsigned int dataLen,
-                        SigBuf signature, CryptoLib::esignPub pubKey) {
+                        SigBuf signature, const CryptoLib::esignPub& pubKey) {
   if (pubKey.VerifyMessage(dataBuf, dataLen, signature, signature.size())) {
     return true;
   }
index 380577fa4439f95e3c1e088574596b5d0c5c6d36..5671d1c3fe2cae4e3d75171033e5705298cdbae5 100644 (file)
@@ -78,9 +78,8 @@ namespace CryptoLib {
   
   
   // asymmetric signature functions
-  SigBuf esignSig(byte*, const unsigned int,
-                 esignPriv);
-  bool esignVer(byte*, const unsigned int, SigBuf, esignPub);
+  SigBuf esignSig(byte*, const unsigned int, const esignPriv&);
+  bool esignVer(byte*, const unsigned int, SigBuf, const esignPub&);
   SigBuf rsaSig(byte*, const unsigned int, rsaPriv);
   bool rsaVer(byte*, const unsigned int, SigBuf, rsaPub);
 
index d4efd93f4d710785ebd2daf9c370d2c4db17b054..9f154a5d8d67c41debd4e644def2e22931357a63 100644 (file)
@@ -205,7 +205,7 @@ public:
     return sizeof(data);
   }
 
-  void sign_extcap(esignPriv privKey) {
+  void sign_extcap(const esignPriv& privKey) {
     //byte capArray[sizeof(data)];
     //memcpy(capArray, &data, sizeof(data));
     SigBuf signature;
@@ -216,7 +216,7 @@ public:
     
   }
 
-  bool verif_extcap (esignPub pubKey) {
+  bool verif_extcap (const esignPub& pubKey) {
     //byte capArray[sizeof(data)];
     //memcpy(capArray, &data, sizeof(data));
 
index d5de241bfcd0d4f29b5c2681863671d1885188ea..7c8286a253364d5a80ecb6d215535ea9cd4e936e 100644 (file)
@@ -245,8 +245,8 @@ public:
   int shutdown_start();
   int shutdown_final();
 
-  esignPub getPubKey() { return myPubKey; }
-  esignPriv getPrvKey() { return myPrivKey; }
+  esignPub& getPubKey() { return myPubKey; }
+  esignPriv& getPrvKey() { return myPrivKey; }
 
   int hash_dentry(inodeno_t ino, const string& s) {
     return 0; // fixme
index 7a3560a8e63b0dcef76d3f2b22b9541857f8701a..68bbe3f304f7ba6982a7211b474a08a550b9491f 100644 (file)
@@ -84,12 +84,19 @@ class MonMap {
   //const string get_str_key() {
   //return pub_str_key;
   //}
-  const esignPub get_key() {
-    if (!keyConvert)
+  const esignPub& get_key() {
+    if (!keyConvert) {
       pub_key = _fromStr_esignPubKey(string(pub_str_key, sizeof(pub_str_key)));
+      keyConvert = true;
+    }
     return pub_key;
   }
 
+  void prepare_mon_key() {
+    pub_key = _fromStr_esignPubKey(string(pub_str_key, sizeof(pub_str_key)));
+    keyConvert = true;
+  }
+
   void encode(bufferlist& blist) {
     blist.append((char*)&epoch, sizeof(epoch));
     blist.append((char*)&num_mon, sizeof(num_mon));
index d7f0a9a7d42fef06c57184754b2de8b11df8b7fd..19fd3dcb3aec878a85ef2089c28c224efbf642b6 100644 (file)
@@ -110,6 +110,7 @@ OSD::OSD(int id, Messenger *m, MonMap *mm, char *dev) : timer(osd_lock)
   whoami = id;
   messenger = m;
   monmap = mm;
+  monmap->prepare_mon_key();
 
   osdmap = 0;
   boot_epoch = 0;
@@ -473,7 +474,7 @@ bool OSD::verify_cap(ExtCap *cap) {
 
   // have i already verified this cap?
   if (!cap_cache->prev_verified(cap->get_id())) {
-    //cout << "Verifying an unseen capability" << endl;
+
     // actually verify
     utime_t justver_time_start = g_clock.now();
     if (cap->verif_extcap(monmap->get_key())) {
@@ -2987,7 +2988,12 @@ void OSD::op_read(MOSDOp *op)//, PG *pg)
     //<< " in " << *pg 
            << endl;
 
-  utime_t read_time_start = g_clock.now();
+  //utime_t read_time_start = g_clock.now();
+  utime_t read_time_start;
+  if (outstanding_updates.count(op->get_reqid()) != 0)
+    read_time_start = outstanding_updates[op->get_reqid()];
+  else
+    read_time_start = g_clock.now();
 
   utime_t sec_time_start = g_clock.now();
   if (g_conf.secure_io) {
@@ -3007,6 +3013,7 @@ void OSD::op_read(MOSDOp *op)//, PG *pg)
        // do we have group cached? if not, update group
        // we will lose execution control here! re-gain on reply
        if (user_groups.count(my_hash) == 0) {
+                 outstanding_updates[op->get_reqid()] = read_time_start;
          update_group(op->get_client_inst(), my_hash, op);
          return;
        }       
@@ -3354,7 +3361,14 @@ void OSD::op_modify(MOSDOp *op, PG *pg)
 
   const char *opname = MOSDOp::get_opname(op->get_op());
 
-  utime_t write_time_start = g_clock.now();
+  utime_t write_time_start;
+  if (outstanding_updates.count(op->get_reqid()) != 0) {
+    write_time_start = outstanding_updates[op->get_reqid()];
+    cout << "Using stored time " <<  write_time_start << " for request " << 
+        op->get_reqid() << endl;
+  }
+  else
+    write_time_start = g_clock.now();
 
   // are any peers missing this?
   for (unsigned i=1; i<pg->acting.size(); i++) {
@@ -3395,6 +3409,9 @@ void OSD::op_modify(MOSDOp *op, PG *pg)
        // do we have group cached? if not, update group
        // we will lose execution control here! re-gain on reply
        if (user_groups.count(my_hash) == 0) {
+         cout << "Setting the time " << write_time_start << 
+           " for request " << op->get_reqid() << endl;
+         outstanding_updates[op->get_reqid()] = write_time_start;
          update_group(op->get_client_inst(), my_hash, op);
          return;
        }
@@ -3555,7 +3572,8 @@ void OSD::op_modify(MOSDOp *op, PG *pg)
   utime_t write_time_end = g_clock.now();
   if (op->get_op() == OSD_OP_WRITE &&
       op->get_source().is_client())
-    cout << "Write time " << write_time_end - write_time_start << endl;
+    cout << "Write time " << write_time_end - write_time_start << endl <<
+      "with write_time_end " << write_time_end << endl;
 }
 
 
index 52f447281000d74a01a64c6c231b5d028d20d905..e1a9bc610344648ffcb42a83749ba55c8ec8ff99 100644 (file)
@@ -118,6 +118,8 @@ public:
   map<hash_t, CapGroup> user_groups;
   map<hash_t, list<Message*> >update_waiter_op;
   void handle_osd_update_reply(MOSDUpdateReply *m);
+  // requests that are had their hashs updated
+  map<reqid_t, utime_t> outstanding_updates;
   
   // per-pg locking (serializing)
   hash_set<pg_t>               pg_lock;