Whamcloud - gitweb
LU-4558 clio: Solve a race in cl_lock_put 81/9881/2
authorJinshan Xiong <jinshan.xiong@intel.com>
Thu, 3 Apr 2014 00:35:45 +0000 (17:35 -0700)
committerJinshan Xiong <jinshan.xiong@intel.com>
Thu, 3 Apr 2014 19:16:25 +0000 (12:16 -0700)
commitec1a5d4f1f5b52ee5031ddc11a862c82996541f7
treec2ea38215077104e8d59af2d13a130b274b265a3
parenta38ac90d1a3681928e434de2b471f57470911d04
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
lustre/obdclass/cl_lock.c