Whamcloud - gitweb
LU-8391 ldlm: check double grant race after resource change 75/21275/11
authorLi Dongyang <dongyang.li@anu.edu.au>
Wed, 13 Jul 2016 06:17:53 +0000 (16:17 +1000)
committerOleg Drokin <green@whamcloud.com>
Mon, 29 Oct 2018 15:58:03 +0000 (15:58 +0000)
commitfef1020406a0fb99ebb7871d7648bfad7a9d91a6
treeca4e736befc7ee9fe077efc20c83581f5bb92e77
parent7231a4d0d2661ddd81a2296064404529cb87605a
LU-8391 ldlm: check double grant race after resource change

In ldlm_handle_cp_callback(), we call lock_res_and_lock and then
check if the ldlm lock has already been granted.
If the lock resource has changed, we release the lock and go ahead
allocating new resource, then grabs the lock again before calling
ldlm_grant_lock().
However this gives another thread an opportunity to grab the lock
and pass the check, while we change the resource. Eventually the
other thread calls ldlm_grant_lock() on the same ldlm lock and
triggers a LASSERT.

Fix the issue by doing double grant race check after changing the
lock resource.

Signed-off-by: Li Dongyang <dongyang.li@anu.edu.au>
Change-Id: Ib327b5e6b5f211909db5350de383d470a891e72a
Reviewed-on: https://review.whamcloud.com/21275
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lockd.c