Skip to content

Commit 1f7b5cf

Browse files
author
Markus Pargmann
committed
nbd: Timeouts are not user requested disconnects
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 <[email protected]>
1 parent 23272a6 commit 1f7b5cf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/block/nbd.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ struct nbd_device {
5757
int blksize;
5858
loff_t bytesize;
5959
int xmit_timeout;
60+
bool timedout;
6061
bool disconnect; /* a disconnect has been requested by user */
6162

6263
struct timer_list timeout_timer;
@@ -154,10 +155,9 @@ static void nbd_xmit_timeout(unsigned long arg)
154155
if (list_empty(&nbd->queue_head))
155156
return;
156157

157-
nbd->disconnect = true;
158-
159158
spin_lock_irqsave(&nbd->sock_lock, flags);
160159

160+
nbd->timedout = true;
161161

162162
if (nbd->sock)
163163
kernel_sock_shutdown(nbd->sock, SHUT_RDWR);
@@ -754,7 +754,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
754754
if (max_part > 0)
755755
blkdev_reread_part(bdev);
756756
if (nbd->disconnect) /* user requested, ignore socket errors */
757-
return 0;
757+
error = 0;
758+
if (nbd->timedout)
759+
error = -ETIMEDOUT;
760+
758761
return error;
759762
}
760763

0 commit comments

Comments
 (0)