[GFS2] GFS2: chmod hung - fix race in thread creation
authorBob Peterson <rpeterso@redhat.com>
Fri, 14 Sep 2007 14:27:59 +0000 (09:27 -0500)
committerSteven Whitehouse <swhiteho@redhat.com>
Wed, 10 Oct 2007 07:56:22 +0000 (08:56 +0100)
commit55c0c4ac0be144014651b19e77c9b77f367955de
treedbea7f24657f8e99f4ff94519cb4f24373930320
parentd66f8277f53407754f50ae6bada68f1b68d04d48
[GFS2] GFS2: chmod hung - fix race in thread creation

The problem boiled down to a race between the gdlm_init_threads()
function initializing thread1 and its setting of blist = 1.
Essentially, "if (current == ls->thread1)" was checked by the thread
before the thread creator set ls->thread1.

Since thread1 is the only thread who is allowed to work on the
blocking queue, and since neither thread thought it was thread1, no one
was working on the queue.  So everything just sat.

This patch reuses the ls->async_lock spin_lock to fix the race,
and it fixes the problem.  I've done more than 2000 iterations of the
loop that was recreating the failure and it seems to work.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
--
fs/gfs2/locking/dlm/thread.c