Commit 0de2b7a4 authored by Yu Kuai's avatar Yu Kuai Committed by Jens Axboe
Browse files

nbd: don't start request if nbd_queue_rq() failed



commit 6a468d59 ("nbd: don't start req until after the dead
connection logic") move blk_mq_start_request() from nbd_queue_rq()
to nbd_handle_cmd() to skip starting request if the connection is
dead. However, request is still started in other error paths.

Currently, blk_mq_end_request() will be called immediately if
nbd_queue_rq() failed, thus start request in such situation is
useless. So remove blk_mq_start_request() from error paths in
nbd_handle_cmd().

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-5-yukuai3@huawei.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fcf3d633
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -939,7 +939,6 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
	if (!refcount_inc_not_zero(&nbd->config_refs)) {
		dev_err_ratelimited(disk_to_dev(nbd->disk),
				    "Socks array is empty\n");
		blk_mq_start_request(req);
		return -EINVAL;
	}
	config = nbd->config;
@@ -948,7 +947,6 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
		dev_err_ratelimited(disk_to_dev(nbd->disk),
				    "Attempted send on invalid socket\n");
		nbd_config_put(nbd);
		blk_mq_start_request(req);
		return -EINVAL;
	}
	cmd->status = BLK_STS_OK;
@@ -972,7 +970,6 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
			 */
			sock_shutdown(nbd);
			nbd_config_put(nbd);
			blk_mq_start_request(req);
			return -EIO;
		}
		goto again;