]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nbd: Timeouts are not user requested disconnects
authorMarkus Pargmann <mpa@pengutronix.de>
Thu, 29 Oct 2015 11:01:34 +0000 (12:01 +0100)
committerMarkus Pargmann <mpa@pengutronix.de>
Fri, 5 Feb 2016 07:52:31 +0000 (08:52 +0100)
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

index 438f4dc549dbdf9faabef5228b34dbcfd5732441..2e14e51b5ea34ad1793ba6ee0c1e77bb1642e3e4 100644 (file)
@@ -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;
        }