Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1291265
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/4] nbd: Timeouts are not user requested disconnects |
| Date | 2015-12-14 16:20 +0100 |
| Message-ID | <qFD4T-7Rv-33@gated-at.bofh.it> (permalink) |
| References | <qFD4S-7Rv-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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@pengutronix.de>
---
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 88762f640527..0ba3149c48bb 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;
@@ -154,10 +155,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);
@@ -754,7 +754,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.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/4] nbd: Remove signal usage Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100 [PATCH v2 1/4] nbd: Remove signal usage Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100 [PATCH v2 2/4] nbd: Timeouts are not user requested disconnects Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100 [PATCH v2 3/4] nbd: Cleanup reset of nbd and bdev after a disconnect Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100 [PATCH v2 4/4] nbd: Move flag parsing to a function Markus Pargmann <mpa@pengutronix.de> - 2015-12-14 16:20 +0100
csiph-web