• Omar Sandoval's avatar
    sbitmap: fix wakeup hang after sbq resize · 85edb87c
    Omar Sandoval authored
    commit 6c0ca7ae upstream.
    
    When we resize a struct sbitmap_queue, we update the wakeup batch size,
    but we don't update the wait count in the struct sbq_wait_states. If we
    resized down from a size which could use a bigger batch size, these
    counts could be too large and cause us to miss necessary wakeups. To fix
    this, update the wait counts when we resize (ensuring some careful
    memory ordering so that it's safe w.r.t. concurrent clears).
    
    This also fixes a theoretical issue where two threads could end up
    bumping the wait count up by the batch size, which could also
    potentially lead to hangs.
    Reported-by: default avatarMartin Raiber <martin@urbackup.org>
    Fixes: e3a2b3f9 ("blk-mq: allow changing of queue depth through sysfs")
    Fixes: 2971c35f ("blk-mq: bitmap tag: fix race on blk_mq_bitmap_tags::wake_cnt")
    Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
    Signed-off-by: default avatarJens Axboe <axboe@fb.com>
    [bwh: Backported to 3.16:
     - Adjust filename
     - Rename almost everything
     - Use ACCESS_ONCE() instead of {READ,WRITE}_ONCE()]
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    85edb87c
blk-mq-tag.c 14.5 KB