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 02:05:52 +0000 (22:05 -0400)
commit8f88799cedabb7d4bd02bbf1ab3cae0b613d4808
treeac436499f3bafc17ad9c3dc20ca5e1c7a7be72c3
parent6daa2b3f3841eaccbc88c6ff184ab573f654b054
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