summaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2016-09-08 21:33:38 +0200
committerJens Axboe <axboe@fb.com>2016-09-08 22:01:34 +0200
commitc261189862c6f65117eb3b1748622a08ef49c262 (patch)
tree17af2c3ead2f500d34264bf78551b9c520efa472 /drivers/block/nbd.c
parentnbd: convert to blkmq (diff)
downloadlinux-c261189862c6f65117eb3b1748622a08ef49c262.tar.xz
linux-c261189862c6f65117eb3b1748622a08ef49c262.zip
nbd: don't shutdown sock with irq's disabled
We hit a warning when shutting down the nbd connection because we have irq's disabled. We don't really need to do the shutdown under the lock, just clear the nbd->sock. So do the shutdown outside of the irq. This gets rid of the warning. Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 15e7c6740873..4b7d0f3c3521 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -161,6 +161,8 @@ static void nbd_end_request(struct nbd_cmd *cmd)
*/
static void sock_shutdown(struct nbd_device *nbd)
{
+ struct socket *sock;
+
spin_lock_irq(&nbd->sock_lock);
if (!nbd->sock) {
@@ -168,18 +170,21 @@ static void sock_shutdown(struct nbd_device *nbd)
return;
}
+ sock = nbd->sock;
dev_warn(disk_to_dev(nbd->disk), "shutting down socket\n");
- kernel_sock_shutdown(nbd->sock, SHUT_RDWR);
- sockfd_put(nbd->sock);
nbd->sock = NULL;
spin_unlock_irq(&nbd->sock_lock);
+ kernel_sock_shutdown(sock, SHUT_RDWR);
+ sockfd_put(sock);
+
del_timer(&nbd->timeout_timer);
}
static void nbd_xmit_timeout(unsigned long arg)
{
struct nbd_device *nbd = (struct nbd_device *)arg;
+ struct socket *sock = NULL;
unsigned long flags;
if (!atomic_read(&nbd->outstanding_cmds))
@@ -189,10 +194,16 @@ static void nbd_xmit_timeout(unsigned long arg)
nbd->timedout = true;
- if (nbd->sock)
- kernel_sock_shutdown(nbd->sock, SHUT_RDWR);
+ if (nbd->sock) {
+ sock = nbd->sock;
+ get_file(sock->file);
+ }
spin_unlock_irqrestore(&nbd->sock_lock, flags);
+ if (sock) {
+ kernel_sock_shutdown(sock, SHUT_RDWR);
+ sockfd_put(sock);
+ }
dev_err(nbd_to_dev(nbd), "Connection timed out, shutting down connection\n");
}