In case if all existing file handles are deferred handles and if all of them gets closed due to handle lease break then we dont need to send lease break acknowledgment to server, because last handle close will be considered as lease break ack. After closing deferred handels, we check for openfile list of inode, if its empty then we skip sending lease break ack. Fixes: 59a556aebc43 ("SMB3: drop reference to cfile before sending oplock break") Signed-off-by: Bharath SM <bharathsm@xxxxxxxxxxxxx> --- fs/smb/client/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 051283386e22..b8a3d60e7ac4 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -4941,7 +4941,9 @@ void cifs_oplock_break(struct work_struct *work) * not bother sending an oplock release if session to server still is * disconnected since oplock already released by the server */ - if (!oplock_break_cancelled) { + spin_lock(&cinode->open_file_lock); + if (!oplock_break_cancelled && !list_empty(&cinode->openFileList)) { + spin_unlock(&cinode->open_file_lock); /* check for server null since can race with kill_sb calling tree disconnect */ if (tcon->ses && tcon->ses->server) { rc = tcon->ses->server->ops->oplock_response(tcon, persistent_fid, @@ -4949,7 +4951,8 @@ void cifs_oplock_break(struct work_struct *work) cifs_dbg(FYI, "Oplock release rc = %d\n", rc); } else pr_warn_once("lease break not sent for unmounted share\n"); - } + } else + spin_unlock(&cinode->open_file_lock); cifs_done_oplock_break(cinode); } -- 2.34.1