aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2017-04-06 17:02:03 -0400
committerJens Axboe <axboe@fb.com>2017-04-17 11:58:42 -0400
commit2516ab1543fdd1f9d08385d73cae51f668a9f3dc (patch)
treef65a2a8d4dfe50b1b44357c3d7aba216f1c9ec18
parent799f9a38bc9f5551819fd118a82826df0a8525cf (diff)
nbd: only clear the queue on device teardown
When running a disconnect torture test I noticed that sometimes we would crash with a negative ref count on our queue. This was because we were ending the same request twice. Turns out we were racing with NBD_CLEAR_SOCK clearing the requests as well as the teardown of the device clearing the requests. So instead make the ioctl only shutdown the sockets and make it so that we only ever run nbd_clear_que from the device teardown. Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/block/nbd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b55cc057f569..71e98cb78c95 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -616,7 +616,9 @@ static void nbd_clear_req(struct request *req, void *data, bool reserved)
616 616
617static void nbd_clear_que(struct nbd_device *nbd) 617static void nbd_clear_que(struct nbd_device *nbd)
618{ 618{
619 blk_mq_stop_hw_queues(nbd->disk->queue);
619 blk_mq_tagset_busy_iter(&nbd->tag_set, nbd_clear_req, NULL); 620 blk_mq_tagset_busy_iter(&nbd->tag_set, nbd_clear_req, NULL);
621 blk_mq_start_hw_queues(nbd->disk->queue);
620 dev_dbg(disk_to_dev(nbd->disk), "queue cleared\n"); 622 dev_dbg(disk_to_dev(nbd->disk), "queue cleared\n");
621} 623}
622 624
@@ -1041,7 +1043,7 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *b
1041static void nbd_clear_sock_ioctl(struct nbd_device *nbd, 1043static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
1042 struct block_device *bdev) 1044 struct block_device *bdev)
1043{ 1045{
1044 nbd_clear_sock(nbd); 1046 sock_shutdown(nbd);
1045 kill_bdev(bdev); 1047 kill_bdev(bdev);
1046 nbd_bdev_reset(bdev); 1048 nbd_bdev_reset(bdev);
1047 if (test_and_clear_bit(NBD_HAS_CONFIG_REF, 1049 if (test_and_clear_bit(NBD_HAS_CONFIG_REF,