From 788f30c76b3c6af8d14a0a5d34f97cb24b7c5e7b Mon Sep 17 00:00:00 2001 From: zhanghc Date: Wed, 15 Apr 2009 09:26:07 +0000 Subject: [PATCH] b=18733 add protection ( spin_lock(&lock->l_lock) ) before using lock->l_resource in "lock_res_and_lock" i=johann i=green --- lustre/ldlm/l_lock.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lustre/ldlm/l_lock.c b/lustre/ldlm/l_lock.c index ac268ec..cb08f5b 100644 --- a/lustre/ldlm/l_lock.c +++ b/lustre/ldlm/l_lock.c @@ -52,16 +52,15 @@ */ struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock) { - struct ldlm_resource *res = lock->l_resource; - - if (ns_is_server(res->lr_namespace)) { - /* on server-side resource of lock doesn't change */ - lock_res(res); - return res; - } + struct ldlm_resource *res = NULL; spin_lock(&lock->l_lock); res = lock->l_resource; + + if (ns_is_server(res->lr_namespace)) + /* on server-side resource of lock doesn't change */ + spin_unlock(&lock->l_lock); + lock_res(res); return res; } -- 1.8.3.1