Whamcloud - gitweb
LU-4558 clio: Solve a race in cl_lock_put 81/9881/3
authorJinshan Xiong <jinshan.xiong@intel.com>
Thu, 3 Apr 2014 00:35:45 +0000 (17:35 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 17 Apr 2014 15:46:29 +0000 (15:46 +0000)
commitb44cae1564e49343eb769f6b08f144dee10361ec
tree9ae55a3d7bede69ed80921c9709c22cedf47596f
parent2293389389651ce7a6f41eb3d54377782e40166c
LU-4558 clio: Solve a race in cl_lock_put

It's not atomic to check the last reference and state of cl_lock
in cl_lock_put(). This can cause a problem that an using lock is
freed, if the process is preempted between atomic_dec_and_test()
and (lock->cll_state == CLS_FREEING).

This problem can be solved by holding a refcount by coh_locks. In
this case, it can be sure that if the lock refcount reaches zero,
nobody else can have any chance to use it again.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I08b81bcd6a4040ea9608db97d60aa6706405ee8c
Reviewed-on: http://review.whamcloud.com/9881
Tested-by: Jenkins
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/cl_lock.c