cifs: if deferred close is disabled then close files immediately
authorSteve French <stfrench@microsoft.com>
Thu, 20 Jul 2023 01:15:20 +0000 (20:15 -0500)
committerSteve French <stfrench@microsoft.com>
Thu, 20 Jul 2023 01:15:20 +0000 (20:15 -0500)
commit3ad4c62eece6c16eda51436c0e90bfc05558bd83
tree293d1a69fd84253f4264c4e08273f3bf41437c88
parent3f12c77335e9b235b004756f14b7145f63f74f09
cifs: if deferred close is disabled then close files immediately

If defer close timeout value is set to 0, then there is no
need to include files in the deferred close list and utilize
the delayed worker for closing. Instead, we can close them
immediately.

Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 879bc8e6555c..fc5acc95cd13 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1080,8 +1080,8 @@ int cifs_close(struct inode *inode, struct file *file)
  cfile = file->private_data;
  file->private_data = NULL;
  dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL);
- if ((cinode->oplock == CIFS_CACHE_RHW_FLG) &&
-     cinode->lease_granted &&
+ if ((cifs_sb->ctx->closetimeo && cinode->oplock == CIFS_CACHE_RHW_FLG)
+     && cinode->lease_granted &&
      !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) &&
      dclose) {
  if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
fs/cifs/file.c