writeback: fix possible race when creating bdi threads
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 25 Jul 2010 11:29:12 +0000 (14:29 +0300)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:53:19 +0000 (18:53 +0200)
commit94eac5e62364df4e605e451218ee6024a7ba664f
tree5e4b7d85361ad20821ba3371acc1536262846f22
parent6f904ff0e39ea88f81eb77e8dfb4e1238492f0a8
writeback: fix possible race when creating bdi threads

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: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
mm/backing-dev.c