mirror of
https://github.com/ceph/ceph
synced 2024-12-17 00:46:05 +00:00
mds: MDRequest: rename to MDRequestImpl, and declare MDRequestRef
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 <greg@inktank.com>
This commit is contained in:
parent
fd235cddf1
commit
f773307ec9
@ -174,9 +174,9 @@ void Mutation::cleanup()
|
||||
}
|
||||
|
||||
|
||||
// MDRequest
|
||||
// MDRequestImpl
|
||||
|
||||
MDRequest::~MDRequest()
|
||||
MDRequestImpl::~MDRequestImpl()
|
||||
{
|
||||
if (client_request)
|
||||
client_request->put();
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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);
|
||||
@ -256,7 +256,7 @@ 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);
|
||||
@ -264,7 +264,7 @@ void MDRequest::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() &&
|
||||
@ -272,14 +272,14 @@ bool MDRequest::can_auth_pin(MDSCacheObject *object)
|
||||
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;
|
||||
|
@ -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)
|
||||
@ -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),
|
||||
@ -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),
|
||||
@ -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),
|
||||
@ -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();
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ using std::set;
|
||||
#include "mdstypes.h"
|
||||
|
||||
class CInode;
|
||||
struct MDRequest;
|
||||
struct MDRequestImpl;
|
||||
|
||||
#include "CInode.h"
|
||||
#include "Capability.h"
|
||||
@ -88,7 +88,7 @@ public:
|
||||
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user