@@ -25,7 +25,6 @@ static DECLARE_RWSEM(sessions_table_lock);
2525struct ksmbd_session_rpc {
2626 int id ;
2727 unsigned int method ;
28- struct list_head list ;
2928};
3029
3130static void free_channel_list (struct ksmbd_session * sess )
@@ -58,15 +57,14 @@ static void __session_rpc_close(struct ksmbd_session *sess,
5857static void ksmbd_session_rpc_clear_list (struct ksmbd_session * sess )
5958{
6059 struct ksmbd_session_rpc * entry ;
60+ long index ;
6161
62- while (!list_empty (& sess -> rpc_handle_list )) {
63- entry = list_entry (sess -> rpc_handle_list .next ,
64- struct ksmbd_session_rpc ,
65- list );
66-
67- list_del (& entry -> list );
62+ xa_for_each (& sess -> rpc_handle_list , index , entry ) {
63+ xa_erase (& sess -> rpc_handle_list , index );
6864 __session_rpc_close (sess , entry );
6965 }
66+
67+ xa_destroy (& sess -> rpc_handle_list );
7068}
7169
7270static int __rpc_method (char * rpc_name )
@@ -102,13 +100,13 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
102100
103101 entry = kzalloc (sizeof (struct ksmbd_session_rpc ), GFP_KERNEL );
104102 if (!entry )
105- return - EINVAL ;
103+ return - ENOMEM ;
106104
107- list_add (& entry -> list , & sess -> rpc_handle_list );
108105 entry -> method = method ;
109106 entry -> id = ksmbd_ipc_id_alloc ();
110107 if (entry -> id < 0 )
111108 goto free_entry ;
109+ xa_store (& sess -> rpc_handle_list , entry -> id , entry , GFP_KERNEL );
112110
113111 resp = ksmbd_rpc_open (sess , entry -> id );
114112 if (!resp )
@@ -117,9 +115,9 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
117115 kvfree (resp );
118116 return entry -> id ;
119117free_id :
118+ xa_erase (& sess -> rpc_handle_list , entry -> id );
120119 ksmbd_rpc_id_free (entry -> id );
121120free_entry :
122- list_del (& entry -> list );
123121 kfree (entry );
124122 return - EINVAL ;
125123}
@@ -128,24 +126,17 @@ void ksmbd_session_rpc_close(struct ksmbd_session *sess, int id)
128126{
129127 struct ksmbd_session_rpc * entry ;
130128
131- list_for_each_entry (entry , & sess -> rpc_handle_list , list ) {
132- if (entry -> id == id ) {
133- list_del (& entry -> list );
134- __session_rpc_close (sess , entry );
135- break ;
136- }
137- }
129+ entry = xa_erase (& sess -> rpc_handle_list , id );
130+ if (entry )
131+ __session_rpc_close (sess , entry );
138132}
139133
140134int ksmbd_session_rpc_method (struct ksmbd_session * sess , int id )
141135{
142136 struct ksmbd_session_rpc * entry ;
143137
144- list_for_each_entry (entry , & sess -> rpc_handle_list , list ) {
145- if (entry -> id == id )
146- return entry -> method ;
147- }
148- return 0 ;
138+ entry = xa_load (& sess -> rpc_handle_list , id );
139+ return entry ? entry -> method : 0 ;
149140}
150141
151142void ksmbd_session_destroy (struct ksmbd_session * sess )
@@ -327,7 +318,7 @@ static struct ksmbd_session *__session_create(int protocol)
327318 set_session_flag (sess , protocol );
328319 xa_init (& sess -> tree_conns );
329320 xa_init (& sess -> ksmbd_chann_list );
330- INIT_LIST_HEAD (& sess -> rpc_handle_list );
321+ xa_init (& sess -> rpc_handle_list );
331322 sess -> sequence_number = 1 ;
332323
333324 ret = __init_smb2_session (sess );
0 commit comments