Whamcloud - gitweb
LU-3433 clio: wrong cl_lock usage 30/8530/2
authorVitaly Fertman <vitaly_fertman@xyratex.com>
Tue, 10 Dec 2013 16:09:45 +0000 (00:09 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 17 Dec 2013 05:39:11 +0000 (05:39 +0000)
granted lock is moved to HELD state in cl_wait_try() only which is
done after upcall for non-agl locks. as the result, lock unuse moves
cl_lock not to CACHED state, but to NEW state. A parallel thread
gets this lock and tries to enqueue it - instead of re-using a
cached lock, cl_enqueue_try() initiates a new enqueue and gets to
osc_lock_enqueue() where it asserts:

LASSERTF(ols->ols_state == OLS_NEW, ...);

the state of osc lock is RELEASED already - moved here by unuse.

This patch is back-ported from the following one:
Lustre-commit: 521335cefe670efa2dc34c5db522a283f318447e
Lustre-change: http://review.whamcloud.com/6709

Signed-off-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Change-Id: I27904bb6198efd5ff98e01f2f74767beabf03a45
Signed-off-by: Jian Yu <jian.yu@intel.com>
Reviewed-on: http://review.whamcloud.com/8530
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_lock.c

index 1b44712..37c3a40 100644 (file)
@@ -553,17 +553,20 @@ static int osc_lock_upcall(void *cookie, int errcode)
                                 lock->cll_flags |= CLF_FROM_UPCALL;
                                 cl_wait_try(env, lock);
                                 lock->cll_flags &= ~CLF_FROM_UPCALL;
-                                if (!olck->ols_glimpse)
-                                        olck->ols_agl = 0;
                         }
                         cl_lock_signal(env, lock);
-                        /* del user for lock upcall cookie */
-                        cl_unuse_try(env, lock);
-                } else {
-                        /* del user for lock upcall cookie */
-                        cl_lock_user_del(env, lock);
-                        cl_lock_error(env, lock, rc);
-                }
+                       /* del user for lock upcall cookie */
+                       if (olck->ols_agl) {
+                               if (!olck->ols_glimpse)
+                                       olck->ols_agl = 0;
+                               cl_unuse_try(env, lock);
+                       }
+               } else {
+                       /* del user for lock upcall cookie */
+                       if (olck->ols_agl)
+                               cl_lock_user_del(env, lock);
+                       cl_lock_error(env, lock, rc);
+               }
 
                /* release cookie reference, acquired by osc_lock_enqueue() */
                cl_lock_hold_release(env, lock, "upcall", lock);
@@ -1179,8 +1182,9 @@ static int osc_lock_enqueue(const struct lu_env *env,
                        /* lock will be passed as upcall cookie,
                         * hold ref to prevent to be released. */
                         cl_lock_hold_add(env, lock, "upcall", lock);
-                        /* a user for lock also */
-                        cl_lock_user_add(env, lock);
+                       /* a user for agl lock also */
+                       if (ols->ols_agl)
+                               cl_lock_user_add(env, lock);
                         ols->ols_state = OLS_ENQUEUED;
 
                         /*
@@ -1198,7 +1202,8 @@ static int osc_lock_enqueue(const struct lu_env *env,
                                           ols, einfo, &ols->ols_handle,
                                           PTLRPCD_SET, 1, ols->ols_agl);
                         if (result != 0) {
-                                cl_lock_user_del(env, lock);
+                               if (ols->ols_agl)
+                                       cl_lock_user_del(env, lock);
                                cl_lock_unhold(env, lock, "upcall", lock);
                                 if (unlikely(result == -ECANCELED)) {
                                         ols->ols_state = OLS_NEW;