Skip to content

Commit da787d5

Browse files
bharathsm-mssmfrench
authored andcommitted
SMB3: Do not send lease break acknowledgment if all file handles have been closed
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: 59a556a ("SMB3: drop reference to cfile before sending oplock break") Reviewed-by: Tom Talpey <[email protected]> Signed-off-by: Bharath SM <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 45a3e24 commit da787d5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

fs/smb/client/file.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4936,20 +4936,19 @@ void cifs_oplock_break(struct work_struct *work)
49364936

49374937
_cifsFileInfo_put(cfile, false /* do not wait for ourself */, false);
49384938
/*
4939-
* releasing stale oplock after recent reconnect of smb session using
4940-
* a now incorrect file handle is not a data integrity issue but do
4941-
* not bother sending an oplock release if session to server still is
4942-
* disconnected since oplock already released by the server
4939+
* MS-SMB2 3.2.5.19.1 and 3.2.5.19.2 (and MS-CIFS 3.2.5.42) do not require
4940+
* an acknowledgment to be sent when the file has already been closed.
4941+
* check for server null, since can race with kill_sb calling tree disconnect.
49434942
*/
4944-
if (!oplock_break_cancelled) {
4945-
/* check for server null since can race with kill_sb calling tree disconnect */
4946-
if (tcon->ses && tcon->ses->server) {
4947-
rc = tcon->ses->server->ops->oplock_response(tcon, persistent_fid,
4948-
volatile_fid, net_fid, cinode);
4949-
cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
4950-
} else
4951-
pr_warn_once("lease break not sent for unmounted share\n");
4952-
}
4943+
spin_lock(&cinode->open_file_lock);
4944+
if (tcon->ses && tcon->ses->server && !oplock_break_cancelled &&
4945+
!list_empty(&cinode->openFileList)) {
4946+
spin_unlock(&cinode->open_file_lock);
4947+
rc = tcon->ses->server->ops->oplock_response(tcon, persistent_fid,
4948+
volatile_fid, net_fid, cinode);
4949+
cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
4950+
} else
4951+
spin_unlock(&cinode->open_file_lock);
49534952

49544953
cifs_done_oplock_break(cinode);
49554954
}

0 commit comments

Comments
 (0)