From: Sage Weil Date: Thu, 1 Sep 2011 23:27:49 +0000 (-0700) Subject: mds: mutation: add start/finish locking hooks X-Git-Tag: v0.35~82 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=8f7c72bcb5dc1e3521e7b9b3f8875878ba877458;p=ceph.git mds: mutation: add start/finish locking hooks Keep track of which lock we are currently working on locking in the Mutation. Use helpers to make sure we start/finish locking in a sane way. Signed-off-by: Sage Weil --- diff --git a/src/mds/Mutation.cc b/src/mds/Mutation.cc index 47380f1461372..1f2b6a9a1efaa 100644 --- a/src/mds/Mutation.cc +++ b/src/mds/Mutation.cc @@ -47,7 +47,21 @@ void Mutation::drop_pins() pins.clear(); } - // auth pins +void Mutation::start_locking(SimpleLock *lock) +{ + assert(locking == NULL); + pin(lock->get_parent()); + locking = lock; +} + +void Mutation::finish_locking(SimpleLock *lock) +{ + assert(locking == lock); + locking = NULL; +} + + +// auth pins bool Mutation::is_auth_pinned(MDSCacheObject *object) { return auth_pins.count(object) || remote_auth_pins.count(object); diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h index 71f041593224d..ca5ee963a91a0 100644 --- a/src/mds/Mutation.h +++ b/src/mds/Mutation.h @@ -58,6 +58,10 @@ struct Mutation { set< SimpleLock* > xlocks; // local or remote. set< SimpleLock*, SimpleLock::ptr_lt > locks; // full ordering + // lock we are currently trying to acquire. if we give up for some reason, + // be sure to eval() this. + SimpleLock *locking; + // if this flag is set, do not attempt to acquire further locks. // (useful for wrlock, which may be a moving auth target) bool done_locking; @@ -72,17 +76,20 @@ struct Mutation { list dirty_cow_inodes; list > dirty_cow_dentries; - Mutation() : - attempt(0), - ls(0), - slave_to_mds(-1), - done_locking(false), committing(false), aborted(false) { } - Mutation(metareqid_t ri, __u32 att=0, int slave_to=-1) : - reqid(ri), attempt(att), - ls(0), - slave_to_mds(slave_to), - done_locking(false), committing(false), aborted(false) { } + Mutation() + : attempt(0), + ls(0), + slave_to_mds(-1), + locking(NULL), + done_locking(false), committing(false), aborted(false) { } + Mutation(metareqid_t ri, __u32 att=0, int slave_to=-1) + : reqid(ri), attempt(att), + ls(0), + slave_to_mds(slave_to), + locking(NULL), + done_locking(false), committing(false), aborted(false) { } virtual ~Mutation() { + assert(locking == NULL); assert(pins.empty()); assert(auth_pins.empty()); assert(xlocks.empty()); @@ -105,6 +112,9 @@ struct Mutation { void set_stickydirs(CInode *in); void drop_pins(); + void start_locking(SimpleLock *lock); + void finish_locking(SimpleLock *lock); + // auth pins bool is_auth_pinned(MDSCacheObject *object); void auth_pin(MDSCacheObject *object);