From: Markus Pargmann <mpa@pengutronix.de>
To: nbd-general@lists.sourceforge.net
Cc: Oleg Nesterov <oleg@redhat.com>,
Christoph Hellwig <hch@infradead.org>,
linux-kernel@vger.kernel.org,
Markus Pargmann <mpa@pengutronix.de>
Subject: [PATCH v2 2/4] nbd: Timeouts are not user requested disconnects
Date: Mon, 14 Dec 2015 16:17:58 +0100 [thread overview]
Message-ID: <1450106280-7223-3-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1450106280-7223-1-git-send-email-mpa@pengutronix.de>
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
next prev parent reply other threads:[~2015-12-14 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 15:17 [PATCH v2 0/4] nbd: Remove signal usage Markus Pargmann
2015-12-14 15:17 ` [PATCH v2 1/4] " Markus Pargmann
2015-12-14 15:17 ` Markus Pargmann [this message]
2015-12-14 15:17 ` [PATCH v2 3/4] nbd: Cleanup reset of nbd and bdev after a disconnect Markus Pargmann
2015-12-14 15:18 ` [PATCH v2 4/4] nbd: Move flag parsing to a function Markus Pargmann
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=1450106280-7223-3-git-send-email-mpa@pengutronix.de \
--to=mpa@pengutronix.de \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd-general@lists.sourceforge.net \
--cc=oleg@redhat.com \
/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
all inboxes | Powered by JetHome®