Whamcloud - gitweb
LU-8319 fid: fix race in fid allocation 39/20939/3
authorFan Yong <fan.yong@intel.com>
Sun, 15 May 2016 02:35:24 +0000 (10:35 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 11 Jul 2016 23:52:52 +0000 (23:52 +0000)
commit4c066a61d5bc4b59e6fd23d5416500f0e61be3a1
tree3fa4f5fcb54f891266ec0d089087f1444d840672
parent80a3eb516dd05d8bb18c41680f0cea40f25443ed
LU-8319 fid: fix race in fid allocation

There is race condition when allocating fid/seq in parallel
as following:

The thread1 will release the lcs_mutex via seq_fid_alloc_prep(),
then another fid allocation thread2 can obtain the lcs_mutex and
allocate FID in the new sequence that has just been allocated by
the thread1 via seq_client_alloc_seq(); and then after thread2
released the lcs_mutex, the thread1 will re-allocate the current
FID in the new sequence without checking whether some others have
already taken such FID in the new sequence during it re-obtaining
the lcs_mutex.

Such race will cause two objects to use the same FID, and trigger
OI conflict and LMA verification failures.

This patch makes the fid allocation and lu_client_seq modification
to be protected by the lcs_mutex.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I79c250f57b73d0abd7d039eea02424ae438f1b56
Reviewed-on: http://review.whamcloud.com/20939
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/fid/fid_request.c