File tree Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Expand file tree Collapse file tree 5 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ struct ksmbd_conn *ksmbd_conn_alloc(void)
70
70
atomic_set (& conn -> req_running , 0 );
71
71
atomic_set (& conn -> r_count , 0 );
72
72
atomic_set (& conn -> refcnt , 1 );
73
+ atomic_set (& conn -> mux_smb_requests , 0 );
73
74
conn -> total_credits = 1 ;
74
75
conn -> outstanding_credits = 0 ;
75
76
Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ struct ksmbd_conn {
107
107
__le16 signing_algorithm ;
108
108
bool binding ;
109
109
atomic_t refcnt ;
110
+ atomic_t mux_smb_requests ;
110
111
};
111
112
112
113
struct ksmbd_conn_ops {
Original file line number Diff line number Diff line change @@ -270,6 +270,7 @@ static void handle_ksmbd_work(struct work_struct *wk)
270
270
271
271
ksmbd_conn_try_dequeue_request (work );
272
272
ksmbd_free_work_struct (work );
273
+ atomic_dec (& conn -> mux_smb_requests );
273
274
/*
274
275
* Checking waitqueue to dropping pending requests on
275
276
* disconnection. waitqueue_active is safe because it
@@ -291,6 +292,15 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn)
291
292
struct ksmbd_work * work ;
292
293
int err ;
293
294
295
+ err = ksmbd_init_smb_server (conn );
296
+ if (err )
297
+ return 0 ;
298
+
299
+ if (atomic_inc_return (& conn -> mux_smb_requests ) >= conn -> vals -> max_credits ) {
300
+ atomic_dec_return (& conn -> mux_smb_requests );
301
+ return - ENOSPC ;
302
+ }
303
+
294
304
work = ksmbd_alloc_work_struct ();
295
305
if (!work ) {
296
306
pr_err ("allocation for work failed\n" );
@@ -301,12 +311,6 @@ static int queue_ksmbd_work(struct ksmbd_conn *conn)
301
311
work -> request_buf = conn -> request_buf ;
302
312
conn -> request_buf = NULL ;
303
313
304
- err = ksmbd_init_smb_server (work );
305
- if (err ) {
306
- ksmbd_free_work_struct (work );
307
- return 0 ;
308
- }
309
-
310
314
ksmbd_conn_enqueue_request (work );
311
315
atomic_inc (& conn -> r_count );
312
316
/* update activity on connection */
Original file line number Diff line number Diff line change @@ -388,6 +388,10 @@ static struct smb_version_ops smb1_server_ops = {
388
388
.set_rsp_status = set_smb1_rsp_status ,
389
389
};
390
390
391
+ static struct smb_version_values smb1_server_values = {
392
+ .max_credits = SMB2_MAX_CREDITS ,
393
+ };
394
+
391
395
static int smb1_negotiate (struct ksmbd_work * work )
392
396
{
393
397
return ksmbd_smb_negotiate_common (work , SMB_COM_NEGOTIATE );
@@ -399,18 +403,18 @@ static struct smb_version_cmds smb1_server_cmds[1] = {
399
403
400
404
static int init_smb1_server (struct ksmbd_conn * conn )
401
405
{
406
+ conn -> vals = & smb1_server_values ;
402
407
conn -> ops = & smb1_server_ops ;
403
408
conn -> cmds = smb1_server_cmds ;
404
409
conn -> max_cmds = ARRAY_SIZE (smb1_server_cmds );
405
410
return 0 ;
406
411
}
407
412
408
- int ksmbd_init_smb_server (struct ksmbd_work * work )
413
+ int ksmbd_init_smb_server (struct ksmbd_conn * conn )
409
414
{
410
- struct ksmbd_conn * conn = work -> conn ;
411
415
__le32 proto ;
412
416
413
- proto = * (__le32 * )((struct smb_hdr * )work -> request_buf )-> Protocol ;
417
+ proto = * (__le32 * )((struct smb_hdr * )conn -> request_buf )-> Protocol ;
414
418
if (conn -> need_neg == false) {
415
419
if (proto == SMB1_PROTO_NUMBER )
416
420
return - EINVAL ;
Original file line number Diff line number Diff line change @@ -427,7 +427,7 @@ bool ksmbd_smb_request(struct ksmbd_conn *conn);
427
427
428
428
int ksmbd_lookup_dialect_by_id (__le16 * cli_dialects , __le16 dialects_count );
429
429
430
- int ksmbd_init_smb_server (struct ksmbd_work * work );
430
+ int ksmbd_init_smb_server (struct ksmbd_conn * conn );
431
431
432
432
struct ksmbd_kstat ;
433
433
int ksmbd_populate_dot_dotdot_entries (struct ksmbd_work * work ,
You can’t perform that action at this time.
0 commit comments