diff options
author | Simon Rettberg | 2020-08-13 16:01:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-08-13 16:01:24 +0200 |
commit | 33fea772862dc8d9dba7c2afb18b8d5442a70ee7 (patch) | |
tree | 57f80d821f9dd988477ef50db88ac60716b7b2c9 /src | |
parent | [KERNEL] Fix leaks, check return codes in module init (diff) | |
download | dnbd3-ng-master.tar.gz dnbd3-ng-master.tar.xz dnbd3-ng-master.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/core.c | 1 | ||||
-rw-r--r-- | src/kernel/mq.c | 27 | ||||
-rw-r--r-- | src/kernel/net-txrx.c | 3 |
3 files changed, 16 insertions, 15 deletions
diff --git a/src/kernel/core.c b/src/kernel/core.c index a0854dd..a7b1048 100644 --- a/src/kernel/core.c +++ b/src/kernel/core.c @@ -404,6 +404,7 @@ error: if (dnbd3_wq) { destroy_workqueue(dnbd3_wq); } + return retval; } /** diff --git a/src/kernel/mq.c b/src/kernel/mq.c index cc710b2..67b33df 100644 --- a/src/kernel/mq.c +++ b/src/kernel/mq.c @@ -178,14 +178,14 @@ static int dnbd3_handle_cmd(struct dnbd3_cmd *cmd, int index) struct request *req = blk_mq_rq_from_pdu(cmd); struct dnbd3_device *dev = cmd->dnbd3; struct dnbd3_sock *sock; - int ret = -1; + int ret; // debug_dev(dev, "handle request at position %lu, size %d, index %d", // blk_rq_pos(req), blk_rq_bytes(req), index); - if (!dev->socks || !dnbd3_is_sock_alive(dev->socks[index])) { - error_dev(dev, "ending request device not connected"); + if (!dev->socks) { + error_dev(dev, "ending request: device not connected"); dnbd3_end_cmd(cmd, BLK_STS_IOERR); return -EIO; } @@ -193,27 +193,24 @@ static int dnbd3_handle_cmd(struct dnbd3_cmd *cmd, int index) mutex_lock(&sock->tx_lock); if (unlikely(!sock->sock)) { - mutex_unlock(&sock->tx_lock); - warn_sock(sock, "not connected"); - return -EIO; + goto err; } blk_mq_start_request(req); if (unlikely(sock->pending && sock->pending != req)) { - dnbd3_requeue_cmd(cmd); - ret = 0; - goto out; + goto err; } ret = dnbd3_send_request(sock, blk_mq_rq_from_pdu(cmd), cmd); - if (ret == -EAGAIN) { - error_dev(dev, "request send failed, requeueing"); - dnbd3_requeue_cmd(cmd); - ret = 0; + if (ret > 0) { + mutex_unlock(&sock->tx_lock); + return 0; } -out: + error_dev(dev, "request send failed, requeueing"); +err: mutex_unlock(&sock->tx_lock); - return ret; + dnbd3_requeue_cmd(cmd); + return 0; } /** diff --git a/src/kernel/net-txrx.c b/src/kernel/net-txrx.c index 51c684d..0402619 100644 --- a/src/kernel/net-txrx.c +++ b/src/kernel/net-txrx.c @@ -171,6 +171,9 @@ int dnbd3_send_request(struct dnbd3_sock *sock, struct request *req, result = kernel_sendmsg(sock->sock, &msg, iov, iov_num, lng); if (result != lng) { error_sock(sock, "connection to server lost"); + if (result >= 0) { + result = -EIO; // QnD fix + } /* * this triggers: * kernel BUG at block/blk-mq.c:704! |