From b9c6921ef121c34e21f089465205b6d072516454 Mon Sep 17 00:00:00 2001 From: anwleung Date: Tue, 20 Mar 2007 16:41:32 +0000 Subject: [PATCH] calc update latency w/ optimizaitons git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1265 29311d96-e01e-0410-9327-a35deaab8ce9 --- .../aleung/security1/ceph/crypto/CryptoLib.cc | 4 +-- .../aleung/security1/ceph/crypto/CryptoLib.h | 5 ++-- .../aleung/security1/ceph/crypto/ExtCap.h | 4 +-- branches/aleung/security1/ceph/mds/MDS.h | 4 +-- branches/aleung/security1/ceph/mon/MonMap.h | 11 ++++++-- branches/aleung/security1/ceph/osd/OSD.cc | 26 ++++++++++++++++--- branches/aleung/security1/ceph/osd/OSD.h | 2 ++ 7 files changed, 41 insertions(+), 15 deletions(-) diff --git a/branches/aleung/security1/ceph/crypto/CryptoLib.cc b/branches/aleung/security1/ceph/crypto/CryptoLib.cc index 26b2cec093794..a056e483cd70a 100644 --- a/branches/aleung/security1/ceph/crypto/CryptoLib.cc +++ b/branches/aleung/security1/ceph/crypto/CryptoLib.cc @@ -208,7 +208,7 @@ ESIGN::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; } diff --git a/branches/aleung/security1/ceph/crypto/CryptoLib.h b/branches/aleung/security1/ceph/crypto/CryptoLib.h index 380577fa4439f..5671d1c3fe2ca 100644 --- a/branches/aleung/security1/ceph/crypto/CryptoLib.h +++ b/branches/aleung/security1/ceph/crypto/CryptoLib.h @@ -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); diff --git a/branches/aleung/security1/ceph/crypto/ExtCap.h b/branches/aleung/security1/ceph/crypto/ExtCap.h index d4efd93f4d710..9f154a5d8d67c 100644 --- a/branches/aleung/security1/ceph/crypto/ExtCap.h +++ b/branches/aleung/security1/ceph/crypto/ExtCap.h @@ -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)); diff --git a/branches/aleung/security1/ceph/mds/MDS.h b/branches/aleung/security1/ceph/mds/MDS.h index d5de241bfcd0d..7c8286a253364 100644 --- a/branches/aleung/security1/ceph/mds/MDS.h +++ b/branches/aleung/security1/ceph/mds/MDS.h @@ -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 diff --git a/branches/aleung/security1/ceph/mon/MonMap.h b/branches/aleung/security1/ceph/mon/MonMap.h index 7a3560a8e63b0..68bbe3f304f7b 100644 --- a/branches/aleung/security1/ceph/mon/MonMap.h +++ b/branches/aleung/security1/ceph/mon/MonMap.h @@ -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)); diff --git a/branches/aleung/security1/ceph/osd/OSD.cc b/branches/aleung/security1/ceph/osd/OSD.cc index d7f0a9a7d42fe..19fd3dcb3aec8 100644 --- a/branches/aleung/security1/ceph/osd/OSD.cc +++ b/branches/aleung/security1/ceph/osd/OSD.cc @@ -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; iacting.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; } diff --git a/branches/aleung/security1/ceph/osd/OSD.h b/branches/aleung/security1/ceph/osd/OSD.h index 52f447281000d..e1a9bc6103446 100644 --- a/branches/aleung/security1/ceph/osd/OSD.h +++ b/branches/aleung/security1/ceph/osd/OSD.h @@ -118,6 +118,8 @@ public: map user_groups; map >update_waiter_op; void handle_osd_update_reply(MOSDUpdateReply *m); + // requests that are had their hashs updated + map outstanding_updates; // per-pg locking (serializing) hash_set pg_lock; -- 2.39.5