nbd: Add locking for tasks
authorMarkus Pargmann <mpa@pengutronix.de>
Tue, 6 Oct 2015 18:03:54 +0000 (20:03 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 8 Oct 2015 20:21:24 +0000 (14:21 -0600)
commitdcc909d90ccdbb73226397ff6d298f7af35b0e11
treebce78076d417b467bfe3a4da807fe78e0e963059
parentc3984cc994377671f18d3d719ddd86b5107457ee
nbd: Add locking for tasks

The timeout handling introduced in
7e2893a16d3e (nbd: Fix timeout detection)
introduces a race condition which may lead to killing of tasks that are
not in nbd context anymore. This was not observed or reproducable yet.

This patch adds locking to critical use of task_recv and task_send to
avoid killing tasks that already left the NBD thread functions. This
lock is only acquired if a timeout occures or the nbd device
starts/stops.

Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
Fixes: 7e2893a16d3e ("nbd: Fix timeout detection")
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nbd.c