Commit fa9b8332 authored by Josef Bacik's avatar Josef Bacik Committed by Khalid Elmously

nbd: don't shutdown sock with irq's disabled

BugLink: https://bugs.launchpad.net/bugs/1793464

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: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
(backported from commit c2611898)
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarKleber Souza <kleber.souza@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent bdefcc4e
......@@ -172,6 +172,8 @@ static void nbd_end_request(struct nbd_device *nbd, struct request *req)
*/
static void sock_shutdown(struct nbd_device *nbd)
{
struct socket *sock;
spin_lock_irq(&nbd->sock_lock);
if (!nbd->sock) {
......@@ -179,18 +181,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 (list_empty(&nbd->queue_head))
......@@ -200,10 +205,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");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment