[Devel] [PATCH rh7 1/2] nbd: only clear the queue on device teardown
Andrey Ryabinin
aryabinin at virtuozzo.com
Wed Nov 6 12:48:40 MSK 2019
From: Josef Bacik <josef at toxicpanda.com>
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 at fb.com>
Signed-off-by: Jens Axboe <axboe at fb.com>
https://jira.sw.ru/browse/PSBM-99114
(cherry picked from commit 2516ab1543fdd1f9d08385d73cae51f668a9f3dc)
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
drivers/block/nbd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e4e30f650f9e..8e43eac169f4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -642,7 +642,9 @@ static void nbd_clear_req(struct request *req, void *data, bool reserved)
static void nbd_clear_que(struct nbd_device *nbd)
{
+ blk_mq_stop_hw_queues(nbd->disk->queue);
blk_mq_tagset_busy_iter(&nbd->tag_set, nbd_clear_req, NULL);
+ blk_mq_start_hw_queues(nbd->disk->queue);
dev_dbg(disk_to_dev(nbd->disk), "queue cleared\n");
}
@@ -996,7 +998,7 @@ static int nbd_start_device(struct nbd_device *nbd, struct block_device *bdev)
static void nbd_clear_sock_ioctl(struct nbd_device *nbd,
struct block_device *bdev)
{
- nbd_clear_sock(nbd);
+ sock_shutdown(nbd);
kill_bdev(bdev);
nbd_bdev_reset(bdev);
}
--
2.23.0
More information about the Devel
mailing list