Skip to content

Commit

Permalink
nbd: take tx_lock before disconnecting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Bacik authored and Jens Axboe committed Jul 22, 2017
1 parent 2e13456 commit b4b2aec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b4b2aec

Please sign in to comment.