All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout
@ 2017-11-06 21:11 Josef Bacik
  2017-11-06 21:11 ` [PATCH 2/2][RESEND] nbd: don't start req until after the dead connection logic Josef Bacik
  2017-11-06 21:15 ` [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2017-11-06 21:11 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

From: Josef Bacik <jbacik@fb.com>

If we have a pending signal or the user kills their application then
it'll bring down the whole device, which is less than awesome.  Instead
wait uninterruptible for the dead timeout so we're sure we gave it our
best shot.

Fixes: 560bc4b39952 ("nbd: handle dead connections")
Cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9adfb5445f8d..fdef8efcdabc 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -723,9 +723,9 @@ static int wait_for_reconnect(struct nbd_device *nbd)
 		return 0;
 	if (test_bit(NBD_DISCONNECTED, &config->runtime_flags))
 		return 0;
-	wait_event_interruptible_timeout(config->conn_wait,
-					 atomic_read(&config->live_connections),
-					 config->dead_conn_timeout);
+	wait_event_timeout(config->conn_wait,
+			   atomic_read(&config->live_connections),
+			   config->dead_conn_timeout);
 	return atomic_read(&config->live_connections);
 }
 
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2][RESEND] nbd: don't start req until after the dead connection logic
  2017-11-06 21:11 [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Josef Bacik
@ 2017-11-06 21:11 ` Josef Bacik
  2017-11-06 21:15 ` [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2017-11-06 21:11 UTC (permalink / raw)
  To: axboe, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

From: Josef Bacik <jbacik@fb.com>

We can end up sleeping for a while waiting for the dead timeout, which
means we could get the per request timer to fire.  We did handle this
case, but if the dead timeout happened right after we submitted we'd
either tear down the connection or possibly requeue as we're handling an
error and race with the endio which can lead to panics and other
hilarity.

Fixes: 560bc4b39952 ("nbd: handle dead connections")
Cc: stable@vger.kernel.org
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 drivers/block/nbd.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index fdef8efcdabc..5f2a4240a204 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -288,15 +288,6 @@ static enum blk_eh_timer_return nbd_xmit_timeout(struct request *req,
 		cmd->status = BLK_STS_TIMEOUT;
 		return BLK_EH_HANDLED;
 	}
-
-	/* If we are waiting on our dead timer then we could get timeout
-	 * callbacks for our request.  For this we just want to reset the timer
-	 * and let the queue side take care of everything.
-	 */
-	if (!completion_done(&cmd->send_complete)) {
-		nbd_config_put(nbd);
-		return BLK_EH_RESET_TIMER;
-	}
 	config = nbd->config;
 
 	if (config->num_connections > 1) {
@@ -740,6 +731,7 @@ 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;
@@ -748,6 +740,7 @@ 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;
@@ -771,6 +764,7 @@ 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;
@@ -781,6 +775,7 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
 	 * here so that it gets put _after_ the request that is already on the
 	 * dispatch list.
 	 */
+	blk_mq_start_request(req);
 	if (unlikely(nsock->pending && nsock->pending != req)) {
 		blk_mq_requeue_request(req, true);
 		ret = 0;
@@ -793,10 +788,10 @@ static int nbd_handle_cmd(struct nbd_cmd *cmd, int index)
 	ret = nbd_send_cmd(nbd, cmd, index);
 	if (ret == -EAGAIN) {
 		dev_err_ratelimited(disk_to_dev(nbd->disk),
-				    "Request send failed trying another connection\n");
+				    "Request send failed, requeueing\n");
 		nbd_mark_nsock_dead(nbd, nsock, 1);
-		mutex_unlock(&nsock->tx_lock);
-		goto again;
+		blk_mq_requeue_request(req, true);
+		ret = 0;
 	}
 out:
 	mutex_unlock(&nsock->tx_lock);
@@ -820,7 +815,6 @@ static blk_status_t nbd_queue_rq(struct blk_mq_hw_ctx *hctx,
 	 * done sending everything over the wire.
 	 */
 	init_completion(&cmd->send_complete);
-	blk_mq_start_request(bd->rq);
 
 	/* We can be called directly from the user space process, which means we
 	 * could possibly have signals pending so our sendmsg will fail.  In
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout
  2017-11-06 21:11 [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Josef Bacik
  2017-11-06 21:11 ` [PATCH 2/2][RESEND] nbd: don't start req until after the dead connection logic Josef Bacik
@ 2017-11-06 21:15 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2017-11-06 21:15 UTC (permalink / raw)
  To: Josef Bacik, nbd, linux-block, kernel-team; +Cc: Josef Bacik, stable

On 11/06/2017 02:11 PM, Josef Bacik wrote:
> From: Josef Bacik <jbacik@fb.com>
> 
> If we have a pending signal or the user kills their application then
> it'll bring down the whole device, which is less than awesome.  Instead
> wait uninterruptible for the dead timeout so we're sure we gave it our
> best shot.

Applied 1-2 for 4.15, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-06 21:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-06 21:11 [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Josef Bacik
2017-11-06 21:11 ` [PATCH 2/2][RESEND] nbd: don't start req until after the dead connection logic Josef Bacik
2017-11-06 21:15 ` [PATCH 1/2][RESEND] nbd: wait uninterruptible for the dead timeout Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.