Just move send_disconnects so we can call it earlier in the file in the next patch. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/block/nbd.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index a94ee45440b3..06b63c11ae50 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -980,6 +980,30 @@ static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx, return ret; } +static void send_disconnects(struct nbd_device *nbd) +{ + struct nbd_config *config = nbd->config; + struct nbd_request request = { + .magic = htonl(NBD_REQUEST_MAGIC), + .type = htonl(NBD_CMD_DISC), + }; + struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)}; + struct iov_iter from; + int i, ret; + + for (i = 0; i < config->num_connections; i++) { + struct nbd_sock *nsock = config->socks[i]; + + iov_iter_kvec(&from, WRITE, &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); + } +} + static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd, int *err) { @@ -1139,30 +1163,6 @@ static void nbd_parse_flags(struct nbd_device *nbd) blk_queue_write_cache(nbd->disk->queue, false, false); } -static void send_disconnects(struct nbd_device *nbd) -{ - struct nbd_config *config = nbd->config; - struct nbd_request request = { - .magic = htonl(NBD_REQUEST_MAGIC), - .type = htonl(NBD_CMD_DISC), - }; - struct kvec iov = {.iov_base = &request, .iov_len = sizeof(request)}; - struct iov_iter from; - int i, ret; - - for (i = 0; i < config->num_connections; i++) { - struct nbd_sock *nsock = config->socks[i]; - - iov_iter_kvec(&from, WRITE, &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); - } -} - static int nbd_disconnect(struct nbd_device *nbd) { struct nbd_config *config = nbd->config; -- 2.21.0