From: nikita Date: Sat, 18 Oct 2008 17:05:50 +0000 (+0000) Subject: Introduce ldlm_lock_addref_try() function (used by CLIO) that attempts to X-Git-Tag: v1_9_90~69 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7d329df8f801883b6013c306c2d9e37fc1dc3ad4;p=fs%2Flustre-release.git Introduce ldlm_lock_addref_try() function (used by CLIO) that attempts to addref a lock that might be being canceled concurrently. b=16450 --- diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 8d31936..38ef6a5 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1545,7 +1545,7 @@ Bugzilla : 16450 Description: Kill unused ldlm_handle2lock_ns() function. Details : Kill unused ldlm_handle2lock_ns() function. -Severity : minor +Severity : normal Bugzilla : 16450 Description: Add lu_ref support to ldlm_lock Details : lu_ref support for ldlm_lock and ldlm_resource. See lu_ref patch. @@ -1566,6 +1566,13 @@ Details : lu_ref support for ldlm_lock and ldlm_resource. See lu_ref patch. for proper use. On the other hand, it was very instrumental in finding a few leaked lock references. +Severity : normal +Bugzilla : 16450 +Description: Add ldlm_lock_addref_try(). +Details : Introduce ldlm_lock_addref_try() function (used by CLIO) that + attempts to addref a lock that might be being canceled + concurrently. + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 0e10778..be73ac0 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -948,6 +948,7 @@ void ldlm_lock_put(struct ldlm_lock *lock); void ldlm_lock_destroy(struct ldlm_lock *lock); void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc); void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode); +int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode); void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode); void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode); void ldlm_lock_allow_match(struct ldlm_lock *lock); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 9977c41..06efa9f 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -601,6 +601,33 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, __u32 mode) LDLM_DEBUG(lock, "ldlm_lock_addref(%s)", ldlm_lockname[mode]); } +/** + * Attempts to addref a lock, and fails if lock is already LDLM_FL_CBPENDING + * or destroyed. + * + * \retval 0 success, lock was addref-ed + * + * \retval -EAGAIN lock is being canceled. + */ +int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode) +{ + struct ldlm_lock *lock; + int result; + + result = -EAGAIN; + lock = ldlm_handle2lock(lockh); + if (lock != NULL) { + lock_res_and_lock(lock); + if (!(lock->l_flags & LDLM_FL_CBPENDING)) { + ldlm_lock_addref_internal_nolock(lock, mode); + result = 0; + } + unlock_res_and_lock(lock); + LDLM_LOCK_PUT(lock); + } + return result; +} + /* only called for local locks */ void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode) { diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index e4a3205..7edf62f 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -2371,6 +2371,7 @@ EXPORT_SYMBOL(ldlm_lock_fast_release); EXPORT_SYMBOL(ldlm_lock_match); EXPORT_SYMBOL(ldlm_lock_cancel); EXPORT_SYMBOL(ldlm_lock_addref); +EXPORT_SYMBOL(ldlm_lock_addref_try); EXPORT_SYMBOL(ldlm_lock_decref); EXPORT_SYMBOL(ldlm_lock_decref_and_cancel); EXPORT_SYMBOL(ldlm_lock_change_resource);