diff options
author | Bharath SM <bharathsm@microsoft.com> | 2024-03-13 05:21:41 +0300 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-03-14 21:54:16 +0300 |
commit | dc528770edb138e26a533f8a77de5c4db18ea7f3 (patch) | |
tree | 1f4cd0ce63b1ece35c9ad3b229fc07fb6b954aaf /fs | |
parent | 279d44ceb8a495d287ec563964f2ed04b0d53b0e (diff) | |
download | linux-dc528770edb138e26a533f8a77de5c4db18ea7f3.tar.xz |
cifs: defer close file handles having RH lease
Previously we only deferred closing file handles with RHW
lease. To enhance performance benefits from deferred closes,
we now include handles with RH leases as well.
Signed-off-by: Bharath SM <bharathsm@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/smb/client/file.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index ec25d3c3e1ee..e7d5e8f972a0 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1073,6 +1073,19 @@ void smb2_deferred_work_close(struct work_struct *work) _cifsFileInfo_put(cfile, true, false); } +static bool +smb2_can_defer_close(struct inode *inode, struct cifs_deferred_close *dclose) +{ + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + struct cifsInodeInfo *cinode = CIFS_I(inode); + + return (cifs_sb->ctx->closetimeo && cinode->lease_granted && dclose && + (cinode->oplock == CIFS_CACHE_RHW_FLG || + cinode->oplock == CIFS_CACHE_RH_FLG) && + !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags)); + +} + int cifs_close(struct inode *inode, struct file *file) { struct cifsFileInfo *cfile; @@ -1086,10 +1099,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 ((cifs_sb->ctx->closetimeo && cinode->oplock == CIFS_CACHE_RHW_FLG) - && cinode->lease_granted && - !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) && - dclose && !(cfile->status_file_deleted)) { + if ((cfile->status_file_deleted == false) && + (smb2_can_defer_close(inode, dclose))) { if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) { inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); |