]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - fs/smb/client/file.c
Merge tag '6.5-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6
[thirdparty/linux.git] / fs / smb / client / file.c
index f30f6ddc4b816867ae386904f69aaf512cfc6c78..879bc8e6555c11c904f1da92928ddfb97cd2e4c8 100644 (file)
@@ -4936,20 +4936,19 @@ oplock_break_ack:
 
        _cifsFileInfo_put(cfile, false /* do not wait for ourself */, false);
        /*
-        * releasing stale oplock after recent reconnect of smb session using
-        * a now incorrect file handle is not a data integrity issue but do
-        * not bother sending an oplock release if session to server still is
-        * disconnected since oplock already released by the server
+        * MS-SMB2 3.2.5.19.1 and 3.2.5.19.2 (and MS-CIFS 3.2.5.42) do not require
+        * an acknowledgment to be sent when the file has already been closed.
+        * check for server null, since can race with kill_sb calling tree disconnect.
         */
-       if (!oplock_break_cancelled) {
-               /* 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,
-                               volatile_fid, net_fid, cinode);
-                       cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
-               } else
-                       pr_warn_once("lease break not sent for unmounted share\n");
-       }
+       spin_lock(&cinode->open_file_lock);
+       if (tcon->ses && tcon->ses->server && !oplock_break_cancelled &&
+                                       !list_empty(&cinode->openFileList)) {
+               spin_unlock(&cinode->open_file_lock);
+               rc = tcon->ses->server->ops->oplock_response(tcon, persistent_fid,
+                                               volatile_fid, net_fid, cinode);
+               cifs_dbg(FYI, "Oplock release rc = %d\n", rc);
+       } else
+               spin_unlock(&cinode->open_file_lock);
 
        cifs_done_oplock_break(cinode);
 }