Whamcloud - gitweb
LU-2163 lprocfs: fix jobstats initialization race
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 12 Oct 2012 21:23:13 +0000 (15:23 -0600)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Oct 2012 17:26:54 +0000 (13:26 -0400)
commit75a11fe9f6af21d75c75480c2838b00a122fdaca
tree18bff78d3609b2d0681672e0906dd074dfcd9e78
parent8f34119e3dc448f75605bf4968ef5540789426ec
LU-2163 lprocfs: fix jobstats initialization race

If two threads are racing to add the same jobid into the job stats
list in lprocfs_job_stats_log(), one thread will lose the race from
cfs_hash_findadd_unique() and enter the "if (job != job2)" case.  It
could fail LASSERT(!cfs_list_empty(&job->js_list)) depending whether
the other thread in "else" added "job2" to the list first or not.

Simply locking the check for cfs_list_empty(&job->js_list) is not
sufficient to fix the race.  There would need to be locking over the
whole cfs_hash_findadd_unique() and cfs_list_add() calls, but since
ojs_lock is global for the whole OST this may have performance costs.

Instead, just remove the LASSERT() entirely, since it provides no
value, and the "losing" thread can happily use the job_stat struct
immediately since it was fully initialized in job_alloc().

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Iecb17e2dc80621fd388295998df5708bcaabcab0
Reviewed-on: http://review.whamcloud.com/4263
Tested-by: Hudson
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/class_obd.c
lustre/obdclass/lprocfs_jobstats.c