@@ -46,7 +46,6 @@ static struct oplock_info *alloc_opinfo(struct ksmbd_work *work,
4646 opinfo -> fid = id ;
4747 opinfo -> Tid = Tid ;
4848 INIT_LIST_HEAD (& opinfo -> op_entry );
49- INIT_LIST_HEAD (& opinfo -> interim_list );
5049 init_waitqueue_head (& opinfo -> oplock_q );
5150 init_waitqueue_head (& opinfo -> oplock_brk );
5251 atomic_set (& opinfo -> refcount , 1 );
@@ -635,6 +634,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
635634{
636635 struct smb2_oplock_break * rsp = NULL ;
637636 struct ksmbd_work * work = container_of (wk , struct ksmbd_work , work );
637+ struct ksmbd_conn * conn = work -> conn ;
638638 struct oplock_break_info * br_info = work -> request_buf ;
639639 struct smb2_hdr * rsp_hdr ;
640640 struct ksmbd_file * fp ;
@@ -690,6 +690,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
690690
691691out :
692692 ksmbd_free_work_struct (work );
693+ ksmbd_conn_r_count_dec (conn );
693694}
694695
695696/**
@@ -724,6 +725,7 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo)
724725 work -> sess = opinfo -> sess ;
725726
726727 if (opinfo -> op_state == OPLOCK_ACK_WAIT ) {
728+ ksmbd_conn_r_count_inc (conn );
727729 INIT_WORK (& work -> work , __smb2_oplock_break_noti );
728730 ksmbd_queue_work (work );
729731
@@ -745,6 +747,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
745747{
746748 struct smb2_lease_break * rsp = NULL ;
747749 struct ksmbd_work * work = container_of (wk , struct ksmbd_work , work );
750+ struct ksmbd_conn * conn = work -> conn ;
748751 struct lease_break_info * br_info = work -> request_buf ;
749752 struct smb2_hdr * rsp_hdr ;
750753
@@ -791,6 +794,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
791794
792795out :
793796 ksmbd_free_work_struct (work );
797+ ksmbd_conn_r_count_dec (conn );
794798}
795799
796800/**
@@ -803,7 +807,6 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
803807static int smb2_lease_break_noti (struct oplock_info * opinfo )
804808{
805809 struct ksmbd_conn * conn = opinfo -> conn ;
806- struct list_head * tmp , * t ;
807810 struct ksmbd_work * work ;
808811 struct lease_break_info * br_info ;
809812 struct lease * lease = opinfo -> o_lease ;
@@ -831,16 +834,7 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo)
831834 work -> sess = opinfo -> sess ;
832835
833836 if (opinfo -> op_state == OPLOCK_ACK_WAIT ) {
834- list_for_each_safe (tmp , t , & opinfo -> interim_list ) {
835- struct ksmbd_work * in_work ;
836-
837- in_work = list_entry (tmp , struct ksmbd_work ,
838- interim_entry );
839- setup_async_work (in_work , NULL , NULL );
840- smb2_send_interim_resp (in_work , STATUS_PENDING );
841- list_del_init (& in_work -> interim_entry );
842- release_async_work (in_work );
843- }
837+ ksmbd_conn_r_count_inc (conn );
844838 INIT_WORK (& work -> work , __smb2_lease_break_noti );
845839 ksmbd_queue_work (work );
846840 wait_for_break_ack (opinfo );
@@ -871,7 +865,8 @@ static void wait_lease_breaking(struct oplock_info *opinfo)
871865 }
872866}
873867
874- static int oplock_break (struct oplock_info * brk_opinfo , int req_op_level )
868+ static int oplock_break (struct oplock_info * brk_opinfo , int req_op_level ,
869+ struct ksmbd_work * in_work )
875870{
876871 int err = 0 ;
877872
@@ -914,9 +909,15 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level)
914909 }
915910
916911 if (lease -> state & (SMB2_LEASE_WRITE_CACHING_LE |
917- SMB2_LEASE_HANDLE_CACHING_LE ))
912+ SMB2_LEASE_HANDLE_CACHING_LE )) {
913+ if (in_work ) {
914+ setup_async_work (in_work , NULL , NULL );
915+ smb2_send_interim_resp (in_work , STATUS_PENDING );
916+ release_async_work (in_work );
917+ }
918+
918919 brk_opinfo -> op_state = OPLOCK_ACK_WAIT ;
919- else
920+ } else
920921 atomic_dec (& brk_opinfo -> breaking_cnt );
921922 } else {
922923 err = oplock_break_pending (brk_opinfo , req_op_level );
@@ -1116,7 +1117,7 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,
11161117 if (ksmbd_conn_releasing (opinfo -> conn ))
11171118 continue ;
11181119
1119- oplock_break (opinfo , SMB2_OPLOCK_LEVEL_NONE );
1120+ oplock_break (opinfo , SMB2_OPLOCK_LEVEL_NONE , NULL );
11201121 opinfo_put (opinfo );
11211122 }
11221123 }
@@ -1152,7 +1153,7 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp)
11521153
11531154 if (ksmbd_conn_releasing (opinfo -> conn ))
11541155 continue ;
1155- oplock_break (opinfo , SMB2_OPLOCK_LEVEL_NONE );
1156+ oplock_break (opinfo , SMB2_OPLOCK_LEVEL_NONE , NULL );
11561157 opinfo_put (opinfo );
11571158 }
11581159 }
@@ -1252,8 +1253,7 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
12521253 goto op_break_not_needed ;
12531254 }
12541255
1255- list_add (& work -> interim_entry , & prev_opinfo -> interim_list );
1256- err = oplock_break (prev_opinfo , SMB2_OPLOCK_LEVEL_II );
1256+ err = oplock_break (prev_opinfo , SMB2_OPLOCK_LEVEL_II , work );
12571257 opinfo_put (prev_opinfo );
12581258 if (err == - ENOENT )
12591259 goto set_lev ;
@@ -1322,8 +1322,7 @@ static void smb_break_all_write_oplock(struct ksmbd_work *work,
13221322 }
13231323
13241324 brk_opinfo -> open_trunc = is_trunc ;
1325- list_add (& work -> interim_entry , & brk_opinfo -> interim_list );
1326- oplock_break (brk_opinfo , SMB2_OPLOCK_LEVEL_II );
1325+ oplock_break (brk_opinfo , SMB2_OPLOCK_LEVEL_II , work );
13271326 opinfo_put (brk_opinfo );
13281327}
13291328
@@ -1386,7 +1385,7 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
13861385 SMB2_LEASE_KEY_SIZE ))
13871386 goto next ;
13881387 brk_op -> open_trunc = is_trunc ;
1389- oplock_break (brk_op , SMB2_OPLOCK_LEVEL_NONE );
1388+ oplock_break (brk_op , SMB2_OPLOCK_LEVEL_NONE , NULL );
13901389next :
13911390 opinfo_put (brk_op );
13921391 rcu_read_lock ();
0 commit comments