Skip to content

Commit 97c2ec6

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: avoid to send duplicate lease break notifications
This patch fixes generic/011 when enable smb2 leases. if ksmbd sends multiple notifications for a file, cifs increments the reference count of the file but it does not decrement the count by the failure of queue_work. So even if the file is closed, cifs does not send a SMB2_CLOSE request. Cc: [email protected] Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent cc00bc8 commit 97c2ec6

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

fs/smb/server/oplock.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,23 @@ static int oplock_break_pending(struct oplock_info *opinfo, int req_op_level)
613613

614614
if (opinfo->op_state == OPLOCK_CLOSING)
615615
return -ENOENT;
616-
else if (!opinfo->is_lease && opinfo->level <= req_op_level)
617-
return 1;
616+
else if (opinfo->level <= req_op_level) {
617+
if (opinfo->is_lease &&
618+
opinfo->o_lease->state !=
619+
(SMB2_LEASE_HANDLE_CACHING_LE |
620+
SMB2_LEASE_READ_CACHING_LE))
621+
return 1;
622+
}
618623
}
619624

620-
if (!opinfo->is_lease && opinfo->level <= req_op_level) {
621-
wake_up_oplock_break(opinfo);
622-
return 1;
625+
if (opinfo->level <= req_op_level) {
626+
if (opinfo->is_lease &&
627+
opinfo->o_lease->state !=
628+
(SMB2_LEASE_HANDLE_CACHING_LE |
629+
SMB2_LEASE_READ_CACHING_LE)) {
630+
wake_up_oplock_break(opinfo);
631+
return 1;
632+
}
623633
}
624634
return 0;
625635
}
@@ -887,7 +897,6 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level)
887897
struct lease *lease = brk_opinfo->o_lease;
888898

889899
atomic_inc(&brk_opinfo->breaking_cnt);
890-
891900
err = oplock_break_pending(brk_opinfo, req_op_level);
892901
if (err)
893902
return err < 0 ? err : 0;

0 commit comments

Comments
 (0)