Skip to content

Commit

Permalink
MDS: switch cache object classes to use MutationRef instead of raw po…
Browse files Browse the repository at this point in the history
…inters

Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Apr 8, 2014
1 parent 9caf3db commit 4dedab6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/mds/CDentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ class CDentry : public MDSCacheObject, public LRUObject {
return get_projected_linkage()->inode;
}

bool use_projected(client_t client, Mutation *mut) {
bool use_projected(client_t client, const MutationRef& mut) const {
return lock.can_read_projected(client) ||
lock.get_xlock_by() == mut;
}
linkage_t *get_linkage(client_t client, Mutation *mut) {
linkage_t *get_linkage(client_t client, const MutationRef& mut) {
return use_projected(client, mut) ? get_projected_linkage() : get_linkage();
}

Expand Down
2 changes: 1 addition & 1 deletion src/mds/CDir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ void CDir::assimilate_dirty_rstat_inodes()
dout(10) << "assimilate_dirty_rstat_inodes done" << dendl;
}

void CDir::assimilate_dirty_rstat_inodes_finish(Mutation *mut, EMetaBlob *blob)
void CDir::assimilate_dirty_rstat_inodes_finish(MutationRef& mut, EMetaBlob *blob)
{
if (!state_test(STATE_ASSIMRSTAT))
return;
Expand Down
2 changes: 1 addition & 1 deletion src/mds/CDir.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class CDir : public MDSCacheObject {
void resync_accounted_fragstat();
void resync_accounted_rstat();
void assimilate_dirty_rstat_inodes();
void assimilate_dirty_rstat_inodes_finish(Mutation *mut, EMetaBlob *blob);
void assimilate_dirty_rstat_inodes_finish(MutationRef& mut, EMetaBlob *blob);

protected:
version_t projected_version;
Expand Down
11 changes: 5 additions & 6 deletions src/mds/CInode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1678,9 +1678,9 @@ void CInode::start_scatter(ScatterLock *lock)
struct C_Inode_FragUpdate : public Context {
CInode *in;
CDir *dir;
Mutation *mut;
MutationRef mut;

C_Inode_FragUpdate(CInode *i, CDir *d, Mutation *m) : in(i), dir(d), mut(m) {}
C_Inode_FragUpdate(CInode *i, CDir *d, MutationRef& m) : in(i), dir(d), mut(m) {}
void finish(int r) {
in->_finish_frag_update(dir, mut);
}
Expand All @@ -1701,7 +1701,7 @@ void CInode::finish_scatter_update(ScatterLock *lock, CDir *dir,
dout(10) << "finish_scatter_update " << fg << " journaling accounted scatterstat update v" << inode_version << dendl;

MDLog *mdlog = mdcache->mds->mdlog;
Mutation *mut = new Mutation;
MutationRef mut(new MutationImpl);
mut->ls = mdlog->get_current_segment();

inode_t *pi = get_projected_inode();
Expand Down Expand Up @@ -1742,12 +1742,11 @@ void CInode::finish_scatter_update(ScatterLock *lock, CDir *dir,
}
}

void CInode::_finish_frag_update(CDir *dir, Mutation *mut)
void CInode::_finish_frag_update(CDir *dir, MutationRef& mut)
{
dout(10) << "_finish_frag_update on " << *dir << dendl;
mut->apply();
mut->cleanup();
delete mut;
}


Expand Down Expand Up @@ -1952,7 +1951,7 @@ void CInode::finish_scatter_gather_update(int type)
}
}

void CInode::finish_scatter_gather_update_accounted(int type, Mutation *mut, EMetaBlob *metablob)
void CInode::finish_scatter_gather_update_accounted(int type, MutationRef& mut, EMetaBlob *metablob)
{
dout(10) << "finish_scatter_gather_update_accounted " << type << " on " << *this << dendl;
assert(is_auth());
Expand Down
4 changes: 2 additions & 2 deletions src/mds/CInode.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ class CInode : public MDSCacheObject {
void encode_lock_state(int type, bufferlist& bl);
void decode_lock_state(int type, bufferlist& bl);

void _finish_frag_update(CDir *dir, Mutation *mut);
void _finish_frag_update(CDir *dir, MutationRef& mut);

void clear_dirty_scattered(int type);
bool is_dirty_scattered();
Expand All @@ -673,7 +673,7 @@ class CInode : public MDSCacheObject {
void finish_scatter_update(ScatterLock *lock, CDir *dir,
version_t inode_version, version_t dir_accounted_version);
void finish_scatter_gather_update(int type);
void finish_scatter_gather_update_accounted(int type, Mutation *mut, EMetaBlob *metablob);
void finish_scatter_gather_update_accounted(int type, MutationRef& mut, EMetaBlob *metablob);

// -- snap --
void open_snaprealm(bool no_split=false);
Expand Down

0 comments on commit 4dedab6

Please sign in to comment.