Skip to content

Commit 136dff3

Browse files
hcbwizsmfrench
authored andcommitted
ksmbd: add smb-direct shutdown
When killing ksmbd server after connecting rdma, ksmbd threads does not terminate properly because the rdma connection is still alive. This patch add shutdown operation to disconnect rdma connection while ksmbd threads terminate. Signed-off-by: Yufan Chen <[email protected]> Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 4d02c4f commit 136dff3

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

fs/ksmbd/connection.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,17 +387,24 @@ int ksmbd_conn_transport_init(void)
387387
static void stop_sessions(void)
388388
{
389389
struct ksmbd_conn *conn;
390+
struct ksmbd_transport *t;
390391

391392
again:
392393
read_lock(&conn_list_lock);
393394
list_for_each_entry(conn, &conn_list, conns_list) {
394395
struct task_struct *task;
395396

396-
task = conn->transport->handler;
397+
t = conn->transport;
398+
task = t->handler;
397399
if (task)
398400
ksmbd_debug(CONN, "Stop session handler %s/%d\n",
399401
task->comm, task_pid_nr(task));
400402
conn->status = KSMBD_SESS_EXITING;
403+
if (t->ops->shutdown) {
404+
read_unlock(&conn_list_lock);
405+
t->ops->shutdown(t);
406+
read_lock(&conn_list_lock);
407+
}
401408
}
402409
read_unlock(&conn_list_lock);
403410

fs/ksmbd/connection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct ksmbd_conn_ops {
117117
struct ksmbd_transport_ops {
118118
int (*prepare)(struct ksmbd_transport *t);
119119
void (*disconnect)(struct ksmbd_transport *t);
120+
void (*shutdown)(struct ksmbd_transport *t);
120121
int (*read)(struct ksmbd_transport *t, char *buf, unsigned int size);
121122
int (*writev)(struct ksmbd_transport *t, struct kvec *iovs, int niov,
122123
int size, bool need_invalidate_rkey,

fs/ksmbd/transport_rdma.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,15 @@ static void smb_direct_disconnect(struct ksmbd_transport *t)
14531453
free_transport(st);
14541454
}
14551455

1456+
static void smb_direct_shutdown(struct ksmbd_transport *t)
1457+
{
1458+
struct smb_direct_transport *st = smb_trans_direct_transfort(t);
1459+
1460+
ksmbd_debug(RDMA, "smb-direct shutdown cm_id=%p\n", st->cm_id);
1461+
1462+
smb_direct_disconnect_rdma_work(&st->disconnect_work);
1463+
}
1464+
14561465
static int smb_direct_cm_handler(struct rdma_cm_id *cm_id,
14571466
struct rdma_cm_event *event)
14581467
{
@@ -2201,6 +2210,7 @@ bool ksmbd_rdma_capable_netdev(struct net_device *netdev)
22012210
static struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {
22022211
.prepare = smb_direct_prepare,
22032212
.disconnect = smb_direct_disconnect,
2213+
.shutdown = smb_direct_shutdown,
22042214
.writev = smb_direct_writev,
22052215
.read = smb_direct_read,
22062216
.rdma_read = smb_direct_rdma_read,

0 commit comments

Comments
 (0)