Skip to content

Commit

Permalink
MDCache: use MDRequestRef instead of MDRequest*
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Apr 4, 2014
1 parent 565b2c8 commit 5872c2d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 64 deletions.
77 changes: 37 additions & 40 deletions src/mds/MDCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2491,7 +2491,7 @@ void MDCache::send_slave_resolves()
} else {
set<int> resolve_set;
mds->mdsmap->get_mds_set(resolve_set, MDSMap::STATE_RESOLVE);
for (ceph::unordered_map<metareqid_t, MDRequest*>::iterator p = active_requests.begin();
for (ceph::unordered_map<metareqid_t, ceph::weak_ptr<MDRequestImpl> >::iterator p = active_requests.begin();
p != active_requests.end();
++p) {
if (!p->second->is_slave() || !p->second->slave_did_prepare())
Expand Down Expand Up @@ -2644,8 +2644,8 @@ void MDCache::handle_mds_failure(int who)
migrator->handle_mds_failure_or_stop(who);

// clean up any requests slave to/from this node
list<MDRequest*> finish;
for (ceph::unordered_map<metareqid_t, MDRequest*>::iterator p = active_requests.begin();
list<MDRequestRef> finish;
for (ceph::unordered_map<metareqid_t, ceph::weak_ptr<MDRequestImpl> >::iterator p = active_requests.begin();
p != active_requests.end();
++p) {
// slave to the failed node?
Expand All @@ -2666,7 +2666,7 @@ void MDCache::handle_mds_failure(int who)
if (p->second->slave_request)
p->second->aborted = true;
else
finish.push_back(p->second);
finish.push_back(p->second.lock());
}
}

Expand Down Expand Up @@ -3088,7 +3088,7 @@ void MDCache::handle_resolve_ack(MMDSResolveAck *ack)

finish_uncommitted_slave_update(p->first, from);
} else {
MDRequest *mdr = request_get(p->first);
MDRequestRef mdr = request_get(p->first);
// information about master imported caps
if (p->second.length() > 0)
mdr->more()->inode_import.claim(p->second);
Expand Down Expand Up @@ -3123,7 +3123,7 @@ void MDCache::handle_resolve_ack(MMDSResolveAck *ack)
assert(0);
}
} else {
MDRequest *mdr = request_get(*p);
MDRequestRef mdr = request_get(*p);
mdr->aborted = true;
if (mdr->slave_request) {
if (mdr->more()->slave_commit) // journaling slave prepare ?
Expand Down Expand Up @@ -3694,7 +3694,7 @@ void MDCache::rejoin_send_rejoins()
if (!mds->is_rejoin()) {
// i am survivor. send strong rejoin.
// note request remote_auth_pins, xlocks
for (ceph::unordered_map<metareqid_t, MDRequest*>::iterator p = active_requests.begin();
for (ceph::unordered_map<metareqid_t, ceph::weak_ptr<MDRequestImpl> >::iterator p = active_requests.begin();
p != active_requests.end();
++p) {
if ( p->second->is_slave())
Expand Down Expand Up @@ -4488,7 +4488,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
strong->xlocked_dentries[p->first].count(q->first)) {
MMDSCacheRejoin::slave_reqid r = strong->xlocked_dentries[p->first][q->first];
dout(10) << " dn xlock by " << r << " on " << *dn << dendl;
MDRequest *mdr = request_get(r.reqid); // should have this from auth_pin above.
MDRequestRef mdr = request_get(r.reqid); // should have this from auth_pin above.
assert(mdr->is_auth_pinned(dn));
if (!mdr->xlocks.count(&dn->versionlock)) {
assert(dn->versionlock.can_xlock_local());
Expand Down Expand Up @@ -4590,7 +4590,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
++q) {
SimpleLock *lock = in->get_lock(q->first);
dout(10) << " inode xlock by " << q->second << " on " << *lock << " on " << *in << dendl;
MDRequest *mdr = request_get(q->second.reqid); // should have this from auth_pin above.
MDRequestRef mdr = request_get(q->second.reqid); // should have this from auth_pin above.
assert(mdr->is_auth_pinned(in));
if (!mdr->xlocks.count(&in->versionlock)) {
assert(in->versionlock.can_xlock_local());
Expand Down Expand Up @@ -4622,7 +4622,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
r != q->second.end();
++r) {
dout(10) << " inode wrlock by " << *r << " on " << *lock << " on " << *in << dendl;
MDRequest *mdr = request_get(r->reqid); // should have this from auth_pin above.
MDRequestRef mdr = request_get(r->reqid); // should have this from auth_pin above.
if (in->is_auth())
assert(mdr->is_auth_pinned(in));
lock->set_state(LOCK_MIX);
Expand Down Expand Up @@ -7509,7 +7509,7 @@ void MDCache::dispatch(Message *m)
}
}

Context *MDCache::_get_waiter(MDRequest *mdr, Message *req, Context *fin)
Context *MDCache::_get_waiter(MDRequestRef& mdr, Message *req, Context *fin)
{
if (mdr) {
dout(20) << "_get_waiter retryrequest" << dendl;
Expand All @@ -7522,7 +7522,7 @@ Context *MDCache::_get_waiter(MDRequest *mdr, Message *req, Context *fin)
}
}

int MDCache::path_traverse(MDRequest *mdr, Message *req, Context *fin, // who
int MDCache::path_traverse(MDRequestRef& mdr, Message *req, Context *fin, // who
const filepath& path, // what
vector<CDentry*> *pdnvec, // result
CInode **pin,
Expand Down Expand Up @@ -7969,7 +7969,7 @@ void MDCache::open_remote_dirfrag(CInode *diri, frag_t approxfg, Context *fin)
* will return inode for primary, or link up/open up remote link's inode as necessary.
* If it's not available right now, puts mdr on wait list and returns null.
*/
CInode *MDCache::get_dentry_inode(CDentry *dn, MDRequest *mdr, bool projected)
CInode *MDCache::get_dentry_inode(CDentry *dn, MDRequestRef& mdr, bool projected)
{
CDentry::linkage_t *dnl;
if (projected)
Expand Down Expand Up @@ -8828,7 +8828,7 @@ void MDCache::kick_find_ino_peers(int who)
int MDCache::get_num_client_requests()
{
int count = 0;
for (ceph::unordered_map<metareqid_t, MDRequest*>::iterator p = active_requests.begin();
for (ceph::unordered_map<metareqid_t, ceph::weak_ptr<MDRequestImpl> >::iterator p = active_requests.begin();
p != active_requests.end();
++p) {
if (p->second->reqid.name.is_client() && !p->second->is_slave())
Expand Down Expand Up @@ -8910,7 +8910,7 @@ void MDCache::request_finish(MDRequestRef mdr)
}


void MDCache::request_forward(MDRequest *mdr, int who, int port)
void MDCache::request_forward(MDRequestRef& mdr, int who, int port)
{
if (mdr->client_request->get_source().is_client()) {
dout(7) << "request_forward " << *mdr << " to mds." << who << " req "
Expand All @@ -8926,7 +8926,7 @@ void MDCache::request_forward(MDRequest *mdr, int who, int port)
}


void MDCache::dispatch_request(MDRequest *mdr)
void MDCache::dispatch_request(MDRequestRef& mdr)
{
if (mdr->killed) {
dout(10) << "request " << *mdr << " was killed" << dendl;
Expand All @@ -8951,7 +8951,7 @@ void MDCache::dispatch_request(MDRequest *mdr)
}


void MDCache::request_drop_foreign_locks(MDRequest *mdr)
void MDCache::request_drop_foreign_locks(MDRequestRef& mdr)
{
if (!mdr->has_more())
return;
Expand Down Expand Up @@ -9003,19 +9003,19 @@ void MDCache::request_drop_foreign_locks(MDRequest *mdr)
* this function can get called more than once */
}

void MDCache::request_drop_non_rdlocks(MDRequest *mdr)
void MDCache::request_drop_non_rdlocks(MDRequestRef& mdr)
{
request_drop_foreign_locks(mdr);
mds->locker->drop_non_rdlocks(mdr);
}

void MDCache::request_drop_locks(MDRequest *mdr)
void MDCache::request_drop_locks(MDRequestRef& mdr)
{
request_drop_foreign_locks(mdr);
mds->locker->drop_locks(mdr);
}

void MDCache::request_cleanup(MDRequest *mdr)
void MDCache::request_cleanup(MDRequestRef& mdr)
{
dout(15) << "request_cleanup " << *mdr << dendl;

Expand Down Expand Up @@ -9060,7 +9060,7 @@ void MDCache::request_cleanup(MDRequest *mdr)
log_stat();
}

void MDCache::request_kill(MDRequest *mdr)
void MDCache::request_kill(MDRequestRef& mdr)
{
mdr->killed = true;
if (!mdr->committing) {
Expand All @@ -9087,7 +9087,7 @@ class C_MDC_AnchorPrepared : public Context {
}
};

void MDCache::anchor_create_prep_locks(MDRequest *mdr, CInode *in,
void MDCache::anchor_create_prep_locks(MDRequestRef& mdr, CInode *in,
set<SimpleLock*>& rdlocks, set<SimpleLock*>& xlocks)
{
dout(10) << "anchor_create_prep_locks " << *in << dendl;
Expand All @@ -9108,7 +9108,7 @@ void MDCache::anchor_create_prep_locks(MDRequest *mdr, CInode *in,
}
}

void MDCache::anchor_create(MDRequest *mdr, CInode *in, Context *onfinish)
void MDCache::anchor_create(MDRequestRef& mdr, CInode *in, Context *onfinish)
{
assert(in->is_auth());
dout(10) << "anchor_create " << *in << dendl;
Expand Down Expand Up @@ -9266,17 +9266,17 @@ void MDCache::_anchor_logged(CInode *in, version_t atid, Mutation *mut)

struct C_MDC_snaprealm_create_finish : public Context {
MDCache *cache;
MDRequest *mdr;
MDRequestRef mdr;
Mutation *mut;
CInode *in;
C_MDC_snaprealm_create_finish(MDCache *c, MDRequest *m, Mutation *mu, CInode *i) :
C_MDC_snaprealm_create_finish(MDCache *c, MDRequestRef& m, Mutation *mu, CInode *i) :
cache(c), mdr(m), mut(mu), in(i) {}
void finish(int r) {
cache->_snaprealm_create_finish(mdr, mut, in);
}
};

void MDCache::snaprealm_create(MDRequest *mdr, CInode *in)
void MDCache::snaprealm_create(MDRequestRef& mdr, CInode *in)
{
dout(10) << "snaprealm_create " << *in << dendl;
assert(!in->snaprealm);
Expand Down Expand Up @@ -9379,7 +9379,7 @@ void MDCache::do_realm_invalidate_and_update_notify(CInode *in, int snapop, bool
send_snaps(updates);
}

void MDCache::_snaprealm_create_finish(MDRequest *mdr, Mutation *mut, CInode *in)
void MDCache::_snaprealm_create_finish(MDRequestRef& mdr, Mutation *mut, CInode *in)
{
dout(10) << "_snaprealm_create_finish " << *in << dendl;

Expand Down Expand Up @@ -10879,7 +10879,7 @@ void MDCache::handle_dentry_link(MDentryLink *m)

// UNLINK

void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequest *mdr)
void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequestRef& mdr)
{
dout(10) << "send_dentry_unlink " << *dn << dendl;
// share unlink news with replicas
Expand Down Expand Up @@ -11459,19 +11459,19 @@ void MDCache::find_stale_fragment_freeze()

class C_MDC_FragmentPrep : public Context {
MDCache *mdcache;
MDRequest *mdr;
MDRequestRef mdr;
public:
C_MDC_FragmentPrep(MDCache *m, MDRequest *r) : mdcache(m), mdr(r) {}
C_MDC_FragmentPrep(MDCache *m, MDRequestRef& r) : mdcache(m), mdr(r) {}
virtual void finish(int r) {
mdcache->_fragment_logged(mdr);
}
};

class C_MDC_FragmentStore : public Context {
MDCache *mdcache;
MDRequest *mdr;
MDRequestRef mdr;
public:
C_MDC_FragmentStore(MDCache *m, MDRequest *r) : mdcache(m), mdr(r) {}
C_MDC_FragmentStore(MDCache *m, MDRequestRef& r) : mdcache(m), mdr(r) {}
virtual void finish(int r) {
mdcache->_fragment_stored(mdr);
}
Expand Down Expand Up @@ -11525,7 +11525,7 @@ void MDCache::fragment_frozen(dirfrag_t basedirfrag, int r)
dispatch_fragment_dir(mdr);
}

void MDCache::dispatch_fragment_dir(MDRequest *mdr)
void MDCache::dispatch_fragment_dir(MDRequestRef& mdr)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
Expand Down Expand Up @@ -11622,7 +11622,7 @@ void MDCache::dispatch_fragment_dir(MDRequest *mdr)
mds->mdlog->flush();
}

void MDCache::_fragment_logged(MDRequest *mdr)
void MDCache::_fragment_logged(MDRequestRef& mdr)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
Expand Down Expand Up @@ -11656,7 +11656,7 @@ void MDCache::_fragment_logged(MDRequest *mdr)
gather.activate();
}

void MDCache::_fragment_stored(MDRequest *mdr)
void MDCache::_fragment_stored(MDRequestRef& mdr)
{
dirfrag_t basedirfrag = mdr->more()->fragment_base;
map<dirfrag_t,fragment_info_t>::iterator it = fragments.find(basedirfrag);
Expand Down Expand Up @@ -12201,15 +12201,12 @@ void MDCache::dump_cache(const char *fn)



C_MDS_RetryRequest::C_MDS_RetryRequest(MDCache *c, MDRequest *r)
C_MDS_RetryRequest::C_MDS_RetryRequest(MDCache *c, MDRequestRef& r)
: cache(c), mdr(r)
{
mdr->get();
}
{}

void C_MDS_RetryRequest::finish(int r)
{
mdr->retry++;
cache->dispatch_request(mdr);
mdr->put();
}
Loading

0 comments on commit 5872c2d

Please sign in to comment.