Skip to content

Commit

Permalink
Mutation: rename to MutationImpl and define MutationRef
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 f41a2f8 commit 3be138f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
42 changes: 21 additions & 21 deletions src/mds/Mutation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@
#include "messages/MMDSSlaveRequest.h"


// Mutation
// MutationImpl

void Mutation::pin(MDSCacheObject *o)
void MutationImpl::pin(MDSCacheObject *o)
{
if (pins.count(o) == 0) {
o->get(MDSCacheObject::PIN_REQUEST);
pins.insert(o);
}
}

void Mutation::unpin(MDSCacheObject *o)
void MutationImpl::unpin(MDSCacheObject *o)
{
assert(pins.count(o));
o->put(MDSCacheObject::PIN_REQUEST);
pins.erase(o);
}

void Mutation::set_stickydirs(CInode *in)
void MutationImpl::set_stickydirs(CInode *in)
{
if (stickydirs.count(in) == 0) {
in->get_stickydirs();
stickydirs.insert(in);
}
}

void Mutation::drop_pins()
void MutationImpl::drop_pins()
{
for (set<MDSCacheObject*>::iterator it = pins.begin();
it != pins.end();
Expand All @@ -54,15 +54,15 @@ void Mutation::drop_pins()
pins.clear();
}

void Mutation::start_locking(SimpleLock *lock, int target)
void MutationImpl::start_locking(SimpleLock *lock, int target)
{
assert(locking == NULL);
pin(lock->get_parent());
locking = lock;
locking_target_mds = target;
}

void Mutation::finish_locking(SimpleLock *lock)
void MutationImpl::finish_locking(SimpleLock *lock)
{
assert(locking == lock);
locking = NULL;
Expand All @@ -71,27 +71,27 @@ void Mutation::finish_locking(SimpleLock *lock)


// auth pins
bool Mutation::is_auth_pinned(MDSCacheObject *object)
bool MutationImpl::is_auth_pinned(MDSCacheObject *object)
{
return auth_pins.count(object) || remote_auth_pins.count(object);
}

void Mutation::auth_pin(MDSCacheObject *object)
void MutationImpl::auth_pin(MDSCacheObject *object)
{
if (!is_auth_pinned(object)) {
object->auth_pin(this);
auth_pins.insert(object);
}
}

void Mutation::auth_unpin(MDSCacheObject *object)
void MutationImpl::auth_unpin(MDSCacheObject *object)
{
assert(auth_pins.count(object));
object->auth_unpin(this);
auth_pins.erase(object);
}

void Mutation::drop_local_auth_pins()
void MutationImpl::drop_local_auth_pins()
{
for (set<MDSCacheObject*>::iterator it = auth_pins.begin();
it != auth_pins.end();
Expand All @@ -102,12 +102,12 @@ void Mutation::drop_local_auth_pins()
auth_pins.clear();
}

void Mutation::add_projected_inode(CInode *in)
void MutationImpl::add_projected_inode(CInode *in)
{
projected_inodes.push_back(in);
}

void Mutation::pop_and_dirty_projected_inodes()
void MutationImpl::pop_and_dirty_projected_inodes()
{
while (!projected_inodes.empty()) {
CInode *in = projected_inodes.front();
Expand All @@ -116,12 +116,12 @@ void Mutation::pop_and_dirty_projected_inodes()
}
}

void Mutation::add_projected_fnode(CDir *dir)
void MutationImpl::add_projected_fnode(CDir *dir)
{
projected_fnodes.push_back(dir);
}

void Mutation::pop_and_dirty_projected_fnodes()
void MutationImpl::pop_and_dirty_projected_fnodes()
{
while (!projected_fnodes.empty()) {
CDir *dir = projected_fnodes.front();
Expand All @@ -130,24 +130,24 @@ void Mutation::pop_and_dirty_projected_fnodes()
}
}

void Mutation::add_updated_lock(ScatterLock *lock)
void MutationImpl::add_updated_lock(ScatterLock *lock)
{
updated_locks.push_back(lock);
}

void Mutation::add_cow_inode(CInode *in)
void MutationImpl::add_cow_inode(CInode *in)
{
pin(in);
dirty_cow_inodes.push_back(in);
}

void Mutation::add_cow_dentry(CDentry *dn)
void MutationImpl::add_cow_dentry(CDentry *dn)
{
pin(dn);
dirty_cow_dentries.push_back(pair<CDentry*,version_t>(dn, dn->get_projected_version()));
}

void Mutation::apply()
void MutationImpl::apply()
{
pop_and_dirty_projected_inodes();
pop_and_dirty_projected_fnodes();
Expand All @@ -167,7 +167,7 @@ void Mutation::apply()
(*p)->mark_dirty();
}

void Mutation::cleanup()
void MutationImpl::cleanup()
{
drop_local_auth_pins();
drop_pins();
Expand Down Expand Up @@ -276,7 +276,7 @@ void MDRequestImpl::drop_local_auth_pins()
{
if (has_more() && more()->is_freeze_authpin)
unfreeze_auth_pin(true);
Mutation::drop_local_auth_pins();
MutationImpl::drop_local_auth_pins();
}

void MDRequestImpl::print(ostream &out)
Expand Down
18 changes: 9 additions & 9 deletions src/mds/Mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ScatterLock;
class MClientRequest;
class MMDSSlaveRequest;

struct Mutation {
struct MutationImpl {
metareqid_t reqid;
__u32 attempt; // which attempt for this request
LogSegment *ls; // the log segment i'm committing to
Expand Down Expand Up @@ -78,21 +78,21 @@ struct Mutation {
list<CInode*> dirty_cow_inodes;
list<pair<CDentry*,version_t> > dirty_cow_dentries;

Mutation()
MutationImpl()
: attempt(0),
ls(0),
slave_to_mds(-1),
locking(NULL),
locking_target_mds(-1),
done_locking(false), committing(false), aborted(false), killed(false) { }
Mutation(metareqid_t ri, __u32 att=0, int slave_to=-1)
MutationImpl(metareqid_t ri, __u32 att=0, int slave_to=-1)
: reqid(ri), attempt(att),
ls(0),
slave_to_mds(slave_to),
locking(NULL),
locking_target_mds(-1),
done_locking(false), committing(false), aborted(false), killed(false) { }
virtual ~Mutation() {
virtual ~MutationImpl() {
assert(locking == NULL);
assert(pins.empty());
assert(auth_pins.empty());
Expand Down Expand Up @@ -140,13 +140,13 @@ struct Mutation {
}
};

inline ostream& operator<<(ostream& out, Mutation &mut)
inline ostream& operator<<(ostream& out, MutationImpl &mut)
{
mut.print(out);
return out;
}


typedef ceph::shared_ptr<MutationImpl> MutationRef;



Expand All @@ -155,7 +155,7 @@ 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 MDRequestImpl : public Mutation {
struct MDRequestImpl : public MutationImpl {
ceph::weak_ptr<MDRequestImpl> self_ref;
Session *session;
elist<MDRequestImpl*>::item item_session_request; // if not on list, op is aborted.
Expand Down Expand Up @@ -267,7 +267,7 @@ struct MDRequestImpl : public Mutation {
}
MDRequestImpl(metareqid_t ri, __u32 attempt, MClientRequest *req) :
self_ref(),
Mutation(ri, attempt),
MutationImpl(ri, attempt),
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 @@ -282,7 +282,7 @@ struct MDRequestImpl : public Mutation {
}
MDRequestImpl(metareqid_t ri, __u32 attempt, int by) :
self_ref(),
Mutation(ri, attempt, by),
MutationImpl(ri, attempt, by),
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 Down

0 comments on commit 3be138f

Please sign in to comment.