Merge tag 'for-5.12/drivers-2021-02-17' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / drivers / block / nbd.c
index b076a0a..8b9622e 100644 (file)
@@ -1022,6 +1022,12 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
        if (!sock)
                return err;
 
+       /*
+        * We need to make sure we don't get any errant requests while we're
+        * reallocating the ->socks array.
+        */
+       blk_mq_freeze_queue(nbd->disk->queue);
+
        if (!netlink && !nbd->task_setup &&
            !test_bit(NBD_RT_BOUND, &config->runtime_flags))
                nbd->task_setup = current;
@@ -1060,10 +1066,12 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
        nsock->cookie = 0;
        socks[config->num_connections++] = nsock;
        atomic_inc(&config->live_connections);
+       blk_mq_unfreeze_queue(nbd->disk->queue);
 
        return 0;
 
 put_socket:
+       blk_mq_unfreeze_queue(nbd->disk->queue);
        sockfd_put(sock);
        return err;
 }