]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Defer close only when lease is enabled.
authorRohith Surabattula <rohiths@microsoft.com>
Mon, 17 May 2021 11:28:34 +0000 (11:28 +0000)
committerSteve French <stfrench@microsoft.com>
Thu, 20 May 2021 02:11:28 +0000 (21:11 -0500)
When smb2 lease parameter is disabled on server. Server grants
batch oplock instead of RHW lease by default on open, inode page cache
needs to be zapped immediatley upon close as cache is not valid.

Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsglob.h
fs/cifs/file.c
fs/cifs/smb2ops.c

index ea90c53386b81cefa12c22e66282db565af08931..8488d70244620b40e5c37eb73ab60de99f061a24 100644 (file)
@@ -1417,6 +1417,7 @@ struct cifsInodeInfo {
        struct inode vfs_inode;
        struct list_head deferred_closes; /* list of deferred closes */
        spinlock_t deferred_lock; /* protection on deferred list */
+       bool lease_granted; /* Flag to indicate whether lease or oplock is granted. */
 };
 
 static inline struct cifsInodeInfo *
index 304d9d3783c660d6d80a9d6723799813bf137cae..a1abd3da1d442c28fb032c7b0098721391fbd8e7 100644 (file)
@@ -896,6 +896,7 @@ int cifs_close(struct inode *inode, struct file *file)
                file->private_data = NULL;
                dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL);
                if ((cinode->oplock == CIFS_CACHE_RHW_FLG) &&
+                   cinode->lease_granted &&
                    dclose) {
                        if (test_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags))
                                inode->i_ctime = inode->i_mtime = current_time(inode);
index c693624a7267bf2429d2576908cd009e3b1916b6..21ef51d338e0ca333e21a81610ab0cec1d6567b6 100644 (file)
@@ -3983,6 +3983,7 @@ smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
                      unsigned int epoch, bool *purge_cache)
 {
        oplock &= 0xFF;
+       cinode->lease_granted = false;
        if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
                return;
        if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
@@ -4009,6 +4010,7 @@ smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock,
        unsigned int new_oplock = 0;
 
        oplock &= 0xFF;
+       cinode->lease_granted = true;
        if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
                return;