Skip to content

Commit ad57b8e

Browse files
longlimsftsmfrench
authored andcommitted
CIFS: SMBD: Implement function to reconnect to a SMB Direct transport
Add function to implement a reconnect to SMB Direct. This involves tearing down the current connection and establishing/negotiating a new connection. Signed-off-by: Long Li <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]> Reviewed-by: Ronnie Sahlberg <[email protected]>
1 parent 2f89464 commit ad57b8e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

fs/cifs/smbdirect.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,42 @@ static void idle_connection_timer(struct work_struct *work)
13871387
info->keep_alive_interval*HZ);
13881388
}
13891389

1390+
/*
1391+
* Reconnect this SMBD connection, called from upper layer
1392+
* return value: 0 on success, or actual error code
1393+
*/
1394+
int smbd_reconnect(struct TCP_Server_Info *server)
1395+
{
1396+
log_rdma_event(INFO, "reconnecting rdma session\n");
1397+
1398+
if (!server->smbd_conn) {
1399+
log_rdma_event(ERR, "rdma session already destroyed\n");
1400+
return -EINVAL;
1401+
}
1402+
1403+
/*
1404+
* This is possible if transport is disconnected and we haven't received
1405+
* notification from RDMA, but upper layer has detected timeout
1406+
*/
1407+
if (server->smbd_conn->transport_status == SMBD_CONNECTED) {
1408+
log_rdma_event(INFO, "disconnecting transport\n");
1409+
smbd_disconnect_rdma_connection(server->smbd_conn);
1410+
}
1411+
1412+
/* wait until the transport is destroyed */
1413+
wait_event(server->smbd_conn->wait_destroy,
1414+
server->smbd_conn->transport_status == SMBD_DESTROYED);
1415+
1416+
destroy_workqueue(server->smbd_conn->workqueue);
1417+
kfree(server->smbd_conn);
1418+
1419+
log_rdma_event(INFO, "creating rdma session\n");
1420+
server->smbd_conn = smbd_get_connection(
1421+
server, (struct sockaddr *) &server->dstaddr);
1422+
1423+
return server->smbd_conn ? 0 : -ENOENT;
1424+
}
1425+
13901426
static void destroy_caches_and_workqueue(struct smbd_connection *info)
13911427
{
13921428
destroy_receive_buffers(info);

fs/cifs/smbdirect.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,15 @@ struct smbd_response {
247247
struct smbd_connection *smbd_get_connection(
248248
struct TCP_Server_Info *server, struct sockaddr *dstaddr);
249249

250+
/* Reconnect SMBDirect session */
251+
int smbd_reconnect(struct TCP_Server_Info *server);
252+
250253
#else
251254
#define cifs_rdma_enabled(server) 0
252255
struct smbd_connection {};
253256
static inline void *smbd_get_connection(
254257
struct TCP_Server_Info *server, struct sockaddr *dstaddr) {return NULL;}
258+
static inline int smbd_reconnect(struct TCP_Server_Info *server) {return -1; }
255259
#endif
256260

257261
#endif

0 commit comments

Comments
 (0)