Skip to content

Commit

Permalink
nbd: don't shutdown sock with irq's disabled
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Bacik authored and Jens Axboe committed Sep 8, 2016
1 parent fd8383f commit c261189
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,30 @@ 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) {
spin_unlock_irq(&nbd->sock_lock);
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))
Expand All @@ -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");
}
Expand Down

0 comments on commit c261189

Please sign in to comment.