public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Hou Pu <houpu.main@gmail.com>
To: josef@toxicpanda.com, axboe@kernel.dk, mchristi@redhat.com
Cc: linux-block@vger.kernel.org, nbd@other.debian.org,
	Hou Pu <houpu@bytedance.com>
Subject: [PATCH 2/2] nbd: requeue command if the soecket is changed
Date: Wed, 19 Feb 2020 01:31:07 -0500	[thread overview]
Message-ID: <20200219063107.25550-3-houpu@bytedance.com> (raw)
In-Reply-To: <20200219063107.25550-1-houpu@bytedance.com>

In commit 2da22da5734 (nbd: fix zero cmd timeout handling v2),
it is allowed to reset timer when it fires if tag_set.timeout
is set to zero. If the server is shutdown and a new socket
is reconfigured, the request should be requeued to be processed by
new server instead of waiting for response from the old one.

Signed-off-by: Hou Pu <houpu@bytedance.com>
---
 drivers/block/nbd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 8e348c9c49a4..7bbc5477066c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -434,12 +434,22 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
 		 * Userspace sets timeout=0 to disable socket disconnection,
 		 * so just warn and reset the timer.
 		 */
+		struct nbd_sock *nsock = config->socks[cmd->index];
 		cmd->retries++;
 		dev_info(nbd_to_dev(nbd), "Possible stuck request %p: control (%s@%llu,%uB). Runtime %u seconds\n",
 			req, nbdcmd_to_ascii(req_to_nbd_cmd_type(req)),
 			(unsigned long long)blk_rq_pos(req) << 9,
 			blk_rq_bytes(req), (req->timeout / HZ) * cmd->retries);
 
+		mutex_lock(&nsock->tx_lock);
+		if (cmd->cookie != nsock->cookie) {
+			nbd_requeue_cmd(cmd);
+			mutex_unlock(&nsock->tx_lock);
+			mutex_unlock(&cmd->lock);
+			nbd_config_put(nbd);
+			return BLK_EH_DONE;
+		}
+		mutex_unlock(&nsock->tx_lock);
 		mutex_unlock(&cmd->lock);
 		nbd_config_put(nbd);
 		return BLK_EH_RESET_TIMER;
-- 
2.11.0


  parent reply	other threads:[~2020-02-19  6:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19  6:31 [PATCH 0/2] requeue request if only one connection is configured Hou Pu
2020-02-19  6:31 ` [PATCH 1/2] nbd: enable replace socket " Hou Pu
2020-02-25  6:32   ` Mike Christie
2020-02-25 14:10     ` Hou Pu
2020-02-19  6:31 ` Hou Pu [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-02-28  6:40 [PATCH v2 0/2] nbd: requeue request " Hou Pu
2020-02-28  6:40 ` [PATCH 2/2] nbd: requeue command if the soecket is changed Hou Pu
2020-03-03 21:13   ` Josef Bacik
2020-03-03 22:06     ` Mike Christie
2020-03-03 22:21       ` Mike Christie
2020-03-04  7:13         ` Hou Pu
2020-03-04 18:48   ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200219063107.25550-3-houpu@bytedance.com \
    --to=houpu.main@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=houpu@bytedance.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mchristi@redhat.com \
    --cc=nbd@other.debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox