Skip to content

Commit

Permalink
mds: MDRequest: rename to MDRequestImpl, and declare MDRequestRef
Browse files Browse the repository at this point in the history
We're switching the MDRequest to be used as a shared pointer. This is the
first step on the path to inserting an OpTracker into the MDS.
Give the MDRequestImpl a weak_ptr self_ref so that we can keep
using the elist for now.

Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Apr 4, 2014
1 parent fd235cd commit f773307
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 39 deletions.
30 changes: 15 additions & 15 deletions src/mds/Mutation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ void Mutation::cleanup()
}


// MDRequest
// MDRequestImpl

MDRequest::~MDRequest()
MDRequestImpl::~MDRequestImpl()
{
if (client_request)
client_request->put();
Expand All @@ -185,34 +185,34 @@ MDRequest::~MDRequest()
delete _more;
}

MDRequest::More* MDRequest::more()
MDRequestImpl::More* MDRequestImpl::more()
{
if (!_more)
_more = new More();
return _more;
}

bool MDRequest::has_more()
bool MDRequestImpl::has_more()
{
return _more;
}

bool MDRequest::are_slaves()
bool MDRequestImpl::are_slaves()
{
return _more && !_more->slaves.empty();
}

bool MDRequest::slave_did_prepare()
bool MDRequestImpl::slave_did_prepare()
{
return more()->slave_commit;
}

bool MDRequest::did_ino_allocation()
bool MDRequestImpl::did_ino_allocation()
{
return alloc_ino || used_prealloc_ino || prealloc_inos.size();
}

bool MDRequest::freeze_auth_pin(CInode *inode)
bool MDRequestImpl::freeze_auth_pin(CInode *inode)
{
assert(!more()->rename_inode || more()->rename_inode == inode);
more()->rename_inode = inode;
Expand All @@ -226,7 +226,7 @@ bool MDRequest::freeze_auth_pin(CInode *inode)
return true;
}

void MDRequest::unfreeze_auth_pin(bool clear_inode)
void MDRequestImpl::unfreeze_auth_pin(bool clear_inode)
{
assert(more()->is_freeze_authpin);
CInode *inode = more()->rename_inode;
Expand All @@ -239,14 +239,14 @@ void MDRequest::unfreeze_auth_pin(bool clear_inode)
more()->rename_inode = NULL;
}

void MDRequest::set_remote_frozen_auth_pin(CInode *inode)
void MDRequestImpl::set_remote_frozen_auth_pin(CInode *inode)
{
assert(!more()->rename_inode || more()->rename_inode == inode);
more()->rename_inode = inode;
more()->is_remote_frozen_authpin = true;
}

void MDRequest::set_ambiguous_auth(CInode *inode)
void MDRequestImpl::set_ambiguous_auth(CInode *inode)
{
assert(!more()->rename_inode || more()->rename_inode == inode);
assert(!more()->is_ambiguous_auth);
Expand All @@ -256,30 +256,30 @@ void MDRequest::set_ambiguous_auth(CInode *inode)
more()->is_ambiguous_auth = true;
}

void MDRequest::clear_ambiguous_auth()
void MDRequestImpl::clear_ambiguous_auth()
{
CInode *inode = more()->rename_inode;
assert(inode && more()->is_ambiguous_auth);
inode->clear_ambiguous_auth();
more()->is_ambiguous_auth = false;
}

bool MDRequest::can_auth_pin(MDSCacheObject *object)
bool MDRequestImpl::can_auth_pin(MDSCacheObject *object)
{
return object->can_auth_pin() ||
(is_auth_pinned(object) && has_more() &&
more()->is_freeze_authpin &&
more()->rename_inode == object);
}

void MDRequest::drop_local_auth_pins()
void MDRequestImpl::drop_local_auth_pins()
{
if (has_more() && more()->is_freeze_authpin)
unfreeze_auth_pin(true);
Mutation::drop_local_auth_pins();
}

void MDRequest::print(ostream &out)
void MDRequestImpl::print(ostream &out)
{
out << "request(" << reqid;
//if (request) out << " " << *request;
Expand Down
34 changes: 15 additions & 19 deletions src/mds/Mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ inline ostream& operator<<(ostream& out, Mutation &mut)
* mostly information about locks held, so that we can drop them all
* the request is finished or forwarded. see request_*().
*/
struct MDRequest : public Mutation {
int ref;
struct MDRequestImpl : public Mutation {
ceph::weak_ptr<MDRequestImpl> self_ref;
Session *session;
elist<MDRequest*>::item item_session_request; // if not on list, op is aborted.
elist<MDRequestImpl*>::item item_session_request; // if not on list, op is aborted.

// -- i am a client (master) request
MClientRequest *client_request; // client request (if any)
Expand Down Expand Up @@ -251,8 +251,8 @@ struct MDRequest : public Mutation {


// ---------------------------------------------------
MDRequest() :
ref(1),
MDRequestImpl() :
self_ref(),
session(0), item_session_request(this),
client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
Expand All @@ -265,9 +265,9 @@ struct MDRequest : public Mutation {
_more(0) {
in[0] = in[1] = 0;
}
MDRequest(metareqid_t ri, __u32 attempt, MClientRequest *req) :
MDRequestImpl(metareqid_t ri, __u32 attempt, MClientRequest *req) :
self_ref(),
Mutation(ri, attempt),
ref(1),
session(0), item_session_request(this),
client_request(req), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
Expand All @@ -280,9 +280,9 @@ struct MDRequest : public Mutation {
_more(0) {
in[0] = in[1] = 0;
}
MDRequest(metareqid_t ri, __u32 attempt, int by) :
MDRequestImpl(metareqid_t ri, __u32 attempt, int by) :
self_ref(),
Mutation(ri, attempt, by),
ref(1),
session(0), item_session_request(this),
client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
Expand All @@ -295,16 +295,7 @@ struct MDRequest : public Mutation {
_more(0) {
in[0] = in[1] = 0;
}
~MDRequest();

MDRequest *get() {
++ref;
return this;
}
void put() {
if (--ref == 0)
delete this;
}
~MDRequestImpl();

More* more();
bool has_more();
Expand All @@ -320,8 +311,13 @@ struct MDRequest : public Mutation {
void clear_ambiguous_auth();

void print(ostream &out);
void set_self_ref(ceph::shared_ptr<MDRequestImpl>& ref) {
self_ref = ref;
}
};

typedef ceph::shared_ptr<MDRequestImpl> MDRequestRef;


struct MDSlaveUpdate {
int origop;
Expand Down
7 changes: 4 additions & 3 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,11 @@ void Server::journal_close_session(Session *session, int state)
mdlog->flush();

// clean up requests, too
elist<MDRequest*>::iterator p = session->requests.begin(member_offset(MDRequest,
item_session_request));
elist<MDRequestImpl*>::iterator p =
session->requests.begin(member_offset(MDRequestImpl,
item_session_request));
while (!p.end()) {
MDRequest *mdr = *p;
MDRequestImpl *mdr = *p;
++p;
mdcache->request_kill(mdr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/mds/SessionMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using std::set;
#include "mdstypes.h"

class CInode;
struct MDRequest;
struct MDRequestImpl;

#include "CInode.h"
#include "Capability.h"
Expand Down Expand Up @@ -88,7 +88,7 @@ class Session : public RefCountedObject {

list<Message*> preopen_out_queue; ///< messages for client, queued before they connect

elist<MDRequest*> requests;
elist<MDRequestImpl*> requests;

interval_set<inodeno_t> pending_prealloc_inos; // journaling prealloc, will be added to prealloc_inos

Expand Down

0 comments on commit f773307

Please sign in to comment.