[RHEL7,COMMIT] ms/nbd: only clear the queue on device teardown

Submitted by Konstantin Khorenko on Nov. 6, 2019, 3:30 p.m.


Message ID 201911061530.xA6FUkmS032677@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Nov. 6, 2019, 3:30 p.m.
The commit is pushed to "branch-rh7-3.10.0-1062.4.1.vz7.115.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.4.1.vz7.115.11
commit 962d342f8acfdf57f310e7785c00c35f048aafe2
Author: Josef Bacik <josef@toxicpanda.com>
Date:   Wed Nov 6 18:30:46 2019 +0300

    ms/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>
    (cherry picked from commit 2516ab1543fdd1f9d08385d73cae51f668a9f3dc)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
 drivers/block/nbd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);