• Artem Bityutskiy's avatar
    writeback: fix possible race when creating bdi threads · 94eac5e6
    Artem Bityutskiy authored
    This patch fixes a very unlikely race condition on the bdi forker thread error
    path: when bdi thread creation fails, 'bdi->wb.task' may contain the error code
    for a short period of time. If at the same time someone submits a work to this
    bdi, we can end up with an oops 'bdi_queue_work()' while executing
    'wake_up_process(wb->task)'.
    
    This patch fixes the issue by introducing a temporary variable 'task' and
    storing the possible error code there, so that 'wb->task' would never take
    erroneous values.
    
    Note, this race is very unlikely and I never hit it, so it is theoretical, but
    nevertheless worth fixing.
    
    This patch also merges 2 comments which were previously separate.
    Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
    94eac5e6
backing-dev.c 17.2 KB