orangefs: bug fix for a race condition when getting a slot
authorDavid Reynolds <david@omnibond.com>
Thu, 8 Mar 2018 23:54:12 +0000 (18:54 -0500)
committerMike Marshall <hubcap@omnibond.com>
Mon, 2 Apr 2018 12:10:17 +0000 (08:10 -0400)
commitc2676ef801f50cc759d205a89adbf733c798d052
tree5bc9803d7981a227cf8dd727ed9ed8ad517a697b
parent0adb32858b0bddf4ada5f364a84ed60b196dbcda
orangefs: bug fix for a race condition when getting a slot

When a slot becomes free, call wake_up_locked regardless of the number
of slots available.

Without this patch, wake_up_locked is only called when going from no
free slots to one. This means that there is a chance a waiting task
will not be woken up. In many cases, the system will bounce between 0
and 1 free slots, and the waiting tasks will be woken up. But if there
is still a waiting task and another slot becomes available before the
number of free slots reaches zero, that waiting task may never be woken
up since the number of free slots may never reach zero again.

The bug behavior is easy to reproduce with the following script,
where /mnt/orangefs is an OrangeFS file system.

for i in {1..100}; do
for j in {1..20}; do
dd if=/dev/zero of=/mnt/orangefs/tmp$j bs=32768 count=32 &
done
wait
done

Signed-off-by: David Reynolds <david@omnibond.com>
Reviewed-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/orangefs-bufmap.c