]> git.baikalelectronics.ru Git - kernel.git/commitdiff
nbd: take tx_lock before disconnecting
authorJosef Bacik <jbacik@fb.com>
Fri, 21 Jul 2017 14:48:14 +0000 (10:48 -0400)
committerJens Axboe <axboe@kernel.dk>
Sat, 22 Jul 2017 17:12:31 +0000 (11:12 -0600)
We need to take the tx_lock so we don't interleave our disconnect
request between real data going down the wire.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c

index f91e7ac3fa320dc40bd2adc3e37bc2e572931efa..6aefe9fca6ce6f26bdc038a254d4b4650dfac590 100644 (file)
@@ -978,11 +978,15 @@ static void send_disconnects(struct nbd_device *nbd)
        int i, ret;
 
        for (i = 0; i < config->num_connections; i++) {
+               struct nbd_sock *nsock = config->socks[i];
+
                iov_iter_kvec(&from, WRITE | ITER_KVEC, &iov, 1, sizeof(request));
+               mutex_lock(&nsock->tx_lock);
                ret = sock_xmit(nbd, i, 1, &from, 0, NULL);
                if (ret <= 0)
                        dev_err(disk_to_dev(nbd->disk),
                                "Send disconnect failed %d\n", ret);
+               mutex_unlock(&nsock->tx_lock);
        }
 }