Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4b2aecc authored by Josef Bacik's avatar Josef Bacik Committed by Jens Axboe
Browse files

nbd: take tx_lock before disconnecting



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: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2e13456f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
	}
}