From patchwork Thu Oct 11 14:41:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 982519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42WDDt5Krdz9s9J; Fri, 12 Oct 2018 01:41:34 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gAc9X-0001lZ-OI; Thu, 11 Oct 2018 14:41:27 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gAc9V-0001kj-20 for kernel-team@lists.ubuntu.com; Thu, 11 Oct 2018 14:41:25 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gAc9U-0005ag-PH; Thu, 11 Oct 2018 14:41:24 +0000 From: Colin King To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/5][SRU][XENIAL] nbd: Timeouts are not user requested disconnects Date: Thu, 11 Oct 2018 15:41:20 +0100 Message-Id: <20181011144123.24543-3-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011144123.24543-1-colin.king@canonical.com> References: <20181011144123.24543-1-colin.king@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Markus Pargmann BugLink: https://bugs.launchpad.net/bugs/1793464 It may be useful to know in the client that a connection timed out. The current code returns success for a timeout. This patch reports the error code -ETIMEDOUT for a timeout. Signed-off-by: Markus Pargmann (backported from commit 1f7b5cf1be4351e60cf8ae7aab976503dd73c5f8) Signed-off-by: Colin Ian King --- drivers/block/nbd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index d65a6f5..cc2844f 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -57,6 +57,7 @@ struct nbd_device { loff_t blksize; loff_t bytesize; int xmit_timeout; + bool timedout; bool disconnect; /* a disconnect has been requested by user */ struct timer_list timeout_timer; @@ -195,10 +196,9 @@ static void nbd_xmit_timeout(unsigned long arg) if (list_empty(&nbd->queue_head)) return; - nbd->disconnect = true; - spin_lock_irqsave(&nbd->sock_lock, flags); + nbd->timedout = true; if (nbd->sock) kernel_sock_shutdown(nbd->sock, SHUT_RDWR); @@ -791,7 +791,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, if (max_part > 0) blkdev_reread_part(bdev); if (nbd->disconnect) /* user requested, ignore socket errors */ - return 0; + error = 0; + if (nbd->timedout) + error = -ETIMEDOUT; + return error; }