[Nbd] [PATCH 2/4] nbd: Timeouts are not user requested disconnects
- To: nbd-general@lists.sourceforge.net
- Cc: Christoph Hellwig <hch@...1270...>, Oleg Nesterov <oleg@...696...>, linux-kernel@...25...
- Subject: [Nbd] [PATCH 2/4] nbd: Timeouts are not user requested disconnects
- From: Markus Pargmann <mpa@...1897...>
- Date: Thu, 29 Oct 2015 16:42:38 +0100
- Message-id: <1446133360-30652-3-git-send-email-mpa@...1897...>
- In-reply-to: <1446133360-30652-1-git-send-email-mpa@...1897...>
- References: <1446133360-30652-1-git-send-email-mpa@...1897...>
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 <mpa@...1897...>
---
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 d14102d1e9ba..0a87947f94db 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -57,6 +57,7 @@ struct nbd_device {
int blksize;
loff_t bytesize;
int xmit_timeout;
+ bool timedout;
bool disconnect; /* a disconnect has been requested by user */
struct timer_list timeout_timer;
@@ -153,10 +154,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);
@@ -749,7 +749,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;
}
--
2.6.1
Reply to: