Skip to content

Commit

Permalink
cifs: smbd: avoid reconnect lockup
Browse files Browse the repository at this point in the history
During transport reconnect, other processes may have registered memory
and blocked on transport. This creates a deadlock situation because the
transport resources can't be freed, and reconnect is blocked.

Fix this by returning to upper layer on timeout. Before returning,
transport status is set to reconnecting so other processes will release
memory registration resources.

Upper layer will retry the reconnect. This is not in fast I/O path so
setting the timeout to 5 seconds.

Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
CC: Stable <stable@vger.kernel.org>
  • Loading branch information
Long Li authored and Steve French committed Apr 2, 2018
1 parent 2a18287 commit 48f238a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/cifs/smbdirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,8 +1498,8 @@ int smbd_reconnect(struct TCP_Server_Info *server)
log_rdma_event(INFO, "reconnecting rdma session\n");

if (!server->smbd_conn) {
log_rdma_event(ERR, "rdma session already destroyed\n");
return -EINVAL;
log_rdma_event(INFO, "rdma session already destroyed\n");
goto create_conn;
}

/*
Expand All @@ -1512,15 +1512,19 @@ int smbd_reconnect(struct TCP_Server_Info *server)
}

/* wait until the transport is destroyed */
wait_event(server->smbd_conn->wait_destroy,
server->smbd_conn->transport_status == SMBD_DESTROYED);
if (!wait_event_timeout(server->smbd_conn->wait_destroy,
server->smbd_conn->transport_status == SMBD_DESTROYED, 5*HZ))
return -EAGAIN;

destroy_workqueue(server->smbd_conn->workqueue);
kfree(server->smbd_conn);

create_conn:
log_rdma_event(INFO, "creating rdma session\n");
server->smbd_conn = smbd_get_connection(
server, (struct sockaddr *) &server->dstaddr);
log_rdma_event(INFO, "created rdma session info=%p\n",
server->smbd_conn);

return server->smbd_conn ? 0 : -ENOENT;
}
Expand Down

0 comments on commit 48f238a

Please sign in to comment.