X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fldlm%2Fl_lock.c;h=b652097355ca025fe4a40ee4f2902b99e253b4d4;hb=258e762d6b42220292c5a634af1e931d32741d0f;hp=746b4858868c752f29286640c18a5a46e3df254a;hpb=9065e88a7257a98de247f18f997557bd7ccbcb1d;p=fs%2Flustre-release.git diff --git a/lustre/ldlm/l_lock.c b/lustre/ldlm/l_lock.c index 746b485..b652097 100644 --- a/lustre/ldlm/l_lock.c +++ b/lustre/ldlm/l_lock.c @@ -48,3 +48,39 @@ #include #include +/* + * ldlm locking uses resource to serialize access to locks + * but there is a case when we change resource of lock upon + * enqueue reply. we rely on that lock->l_resource = new_res + * is atomic + */ +struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock) +{ + struct ldlm_resource *res = lock->l_resource; + + if (!res->lr_namespace->ns_client) { + /* on server-side resource of lock doesn't change */ + lock_res(res); + return res; + } + + lock_bitlock(lock); + res = lock->l_resource; + lock_res(res); + return res; +} + +void unlock_res_and_lock(struct ldlm_lock *lock) +{ + struct ldlm_resource *res = lock->l_resource; + + if (!res->lr_namespace->ns_client) { + /* on server-side resource of lock doesn't change */ + unlock_res(res); + return; + } + + unlock_res(res); + unlock_bitlock(lock); +} +