From: Greg Farnum Date: Wed, 16 Sep 2009 00:32:01 +0000 (-0700) Subject: uclient: First pass at encode_cap_release function; not used. X-Git-Tag: v0.15~36 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=370223027b598e17132cef6ec57a7be3a6764187;p=ceph.git uclient: First pass at encode_cap_release function; not used. --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 70f302b0ed7..b1543ddb61f 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -909,24 +909,46 @@ inline MClientRequest* Client::make_request_from_Meta(MetaRequest *request) return req; } -/* -//call me from something that has client_lock held, I think -void encode_cap_release(MetaRequest *req, int remove_cap, - int unless_have_cap, Inode *in) { - dout(20) << "encode_cap_release " << remove_cap << " unless " << in - << " has " << unless_have_cap << ". Inode caps are " - << in->caps_issued() << dendl; - - ceph_mds_request_release release; - int caps = in->caps[x]; - if ((caps & drop) && (caps & unless)==0) { +/*This won't do anything if the MetaRequest doesn't have set: + *MClientRequest *request + *Inode *source + *int caps_dropped + */ +void Client::encode_cap_release(MetaRequest *req, int mds) { + Inode *in; + int caps; + if (!req->source) goto invalid_exit; + in = req->source; + caps = in->caps_issued(); + dout(20) << "encode_cap_release " << req->caps_dropped << " unless " + << in << " has " << req->unless_have_caps + << ". Inode caps are " << caps << dendl; + if ( req->request && //we need a request to bundle with + req->caps_dropped && //and caps to drop + (caps & req->caps_dropped) && //and to have some of those caps + !(caps & req->unless_have_caps) ) {//and to not have the 'saving' caps + InodeCap *icap = in->caps[mds]; //encode message to drop the caps -in-> - dout(20) << "encode_inode_release quitting after encoding drop of " - << remove_cap << " from inode " << in << dendl; - } - else dout(20) << "encode_cap_release is quitting because we don't need to drop!" << dendl; - } */ + ceph_mds_request_release release; + icap->issued &= ~req->caps_dropped; + icap->implemented &= ~req->caps_dropped; + release.ino = in->ino; + release.cap_id = icap->cap_id; + release.caps = icap->issued; + release.wanted = icap->wanted; + release.seq = icap->seq; + release.issue_seq = icap->issue_seq; + release.mseq = icap->mseq; + release.dname_seq = 0; + release.dname_len = 0; + dout(20) << "encode_cap_release quitting after encoding drop of " + << req->caps_dropped << " from inode " << in << dendl; + goto clean_exit; + } + invalid_exit: + dout(20) << "encode_cap_release is quitting because we don't need to drop!" << dendl; + clean_exit: ; +} void Client::handle_client_session(MClientSession *m) { diff --git a/src/client/Client.h b/src/client/Client.h index 38677434690..4b0364a56bb 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -98,6 +98,9 @@ struct MetaRequest { ceph_mds_request_head head; filepath path, path2; bufferlist data; + int caps_dropped; //the caps this operation will drop + int unless_have_caps; //unless we have these caps already + utime_t sent_stamp; int mds; // who i am asking @@ -119,26 +122,28 @@ struct MetaRequest { Cond *caller_cond; // who to take up Cond *dispatch_cond; // who to kick back - Inode *source; + Inode *source; //Inode being affected -- useful for cap references Inode *target; MetaRequest(MClientRequest *req, tid_t t) : - request(req), + request(req), caps_dropped(0), unless_have_caps(0), resend_mds(-1), num_fwd(0), retry_attempt(0), ref(1), reply(0), kick(false), got_safe(false), got_unsafe(false), unsafe_item(this), lock("MetaRequest lock"), - caller_cond(0), dispatch_cond(0), target(0) { + caller_cond(0), dispatch_cond(0), + source(0), target(0) { memcpy(&head, &req->head, sizeof(ceph_mds_request_head)); } MetaRequest(int op) : - request(NULL), + request(NULL), caps_dropped(0), unless_have_caps(0), resend_mds(-1), num_fwd(0), retry_attempt(0), ref(1), reply(0), kick(false), got_safe(false), got_unsafe(false), unsafe_item(this), lock("MetaRequest lock"), - caller_cond(0), dispatch_cond(0), target(0) { + caller_cond(0), dispatch_cond(0), + source(0), target(0) { memset(&head, 0, sizeof(ceph_mds_request_head)); head.op = op; } @@ -815,8 +820,7 @@ public: //MClientRequest *req, int uid, int gid, Inode **ptarget = 0, int use_mds=-1, bufferlist *pdirbl=0); - void encode_cap_release(MetaRequest *request, MClientRequest *m, - int unless_have_cap, Inode *in); + void encode_cap_release(MetaRequest *request, int mds); int choose_target_mds(MClientRequest *req); void send_request(MetaRequest *request, int mds); void kick_requests(int mds, bool signal);