Commit f52c0e08 authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe

nbd: clean up return value checking of sock_xmit()

Check if sock_xmit() return 0 is useless because it'll never return
0, comment it and remove such checkings.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20210916093350.1410403-6-yukuai3@huawei.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0de2b7a4
...@@ -495,7 +495,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req, ...@@ -495,7 +495,8 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
} }
/* /*
* Send or receive packet. * Send or receive packet. Return a positive value on success and
* negtive value on failue, and never return 0.
*/ */
static int sock_xmit(struct nbd_device *nbd, int index, int send, static int sock_xmit(struct nbd_device *nbd, int index, int send,
struct iov_iter *iter, int msg_flags, int *sent) struct iov_iter *iter, int msg_flags, int *sent)
...@@ -621,7 +622,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) ...@@ -621,7 +622,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
result = sock_xmit(nbd, index, 1, &from, result = sock_xmit(nbd, index, 1, &from,
(type == NBD_CMD_WRITE) ? MSG_MORE : 0, &sent); (type == NBD_CMD_WRITE) ? MSG_MORE : 0, &sent);
trace_nbd_header_sent(req, handle); trace_nbd_header_sent(req, handle);
if (result <= 0) { if (result < 0) {
if (was_interrupted(result)) { if (was_interrupted(result)) {
/* If we havne't sent anything we can just return BUSY, /* If we havne't sent anything we can just return BUSY,
* however if we have sent something we need to make * however if we have sent something we need to make
...@@ -665,7 +666,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index) ...@@ -665,7 +666,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
skip = 0; skip = 0;
} }
result = sock_xmit(nbd, index, 1, &from, flags, &sent); result = sock_xmit(nbd, index, 1, &from, flags, &sent);
if (result <= 0) { if (result < 0) {
if (was_interrupted(result)) { if (was_interrupted(result)) {
/* We've already sent the header, we /* We've already sent the header, we
* have no choice but to set pending and * have no choice but to set pending and
...@@ -717,7 +718,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) ...@@ -717,7 +718,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
reply.magic = 0; reply.magic = 0;
iov_iter_kvec(&to, READ, &iov, 1, sizeof(reply)); iov_iter_kvec(&to, READ, &iov, 1, sizeof(reply));
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL); result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
if (result <= 0) { if (result < 0) {
if (!nbd_disconnected(config)) if (!nbd_disconnected(config))
dev_err(disk_to_dev(nbd->disk), dev_err(disk_to_dev(nbd->disk),
"Receive control failed (result %d)\n", result); "Receive control failed (result %d)\n", result);
...@@ -788,7 +789,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) ...@@ -788,7 +789,7 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index)
rq_for_each_segment(bvec, req, iter) { rq_for_each_segment(bvec, req, iter) {
iov_iter_bvec(&to, READ, &bvec, 1, bvec.bv_len); iov_iter_bvec(&to, READ, &bvec, 1, bvec.bv_len);
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL); result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
if (result <= 0) { if (result < 0) {
dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n", dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n",
result); result);
/* /*
...@@ -1234,7 +1235,7 @@ static void send_disconnects(struct nbd_device *nbd) ...@@ -1234,7 +1235,7 @@ static void send_disconnects(struct nbd_device *nbd)
iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request)); iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request));
mutex_lock(&nsock->tx_lock); mutex_lock(&nsock->tx_lock);
ret = sock_xmit(nbd, i, 1, &from, 0, NULL); ret = sock_xmit(nbd, i, 1, &from, 0, NULL);
if (ret <= 0) if (ret < 0)
dev_err(disk_to_dev(nbd->disk), dev_err(disk_to_dev(nbd->disk),
"Send disconnect failed %d\n", ret); "Send disconnect failed %d\n", ret);
mutex_unlock(&nsock->tx_lock); mutex_unlock(&nsock->tx_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment