Skip to content

Commit c2676ef

Browse files
dreynolhubcapsc
authored andcommitted
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 <[email protected]> Reviewed-by: Martin Brandenburg <[email protected]> Signed-off-by: Mike Marshall <[email protected]>
1 parent 0adb328 commit c2676ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/orangefs/orangefs-bufmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ static void put(struct slot_map *m, int slot)
7171
spin_lock(&m->q.lock);
7272
__clear_bit(slot, m->map);
7373
v = ++m->c;
74-
if (unlikely(v == 1)) /* no free slots -> one free slot */
74+
if (v > 0)
7575
wake_up_locked(&m->q);
76-
else if (unlikely(v == -1)) /* finished dying */
76+
if (unlikely(v == -1)) /* finished dying */
7777
wake_up_all_locked(&m->q);
7878
spin_unlock(&m->q.lock);
7979
}

0 commit comments

Comments
 (0)