Skip to content

Commit d906be3

Browse files
bharathsm-mssmfrench
authored andcommitted
SMB3: Close deferred file handles in case of handle lease break
We should not cache deferred file handles if we dont have handle lease on a file. And we should immediately close all deferred handles in case of handle lease break. Fixes: 9e31678 ("SMB3: fix lease break timeout when multiple deferred close handles for the same file.") Signed-off-by: Bharath SM <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ab9ddc8 commit d906be3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

fs/cifs/file.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4882,6 +4882,8 @@ void cifs_oplock_break(struct work_struct *work)
48824882
struct TCP_Server_Info *server = tcon->ses->server;
48834883
int rc = 0;
48844884
bool purge_cache = false;
4885+
struct cifs_deferred_close *dclose;
4886+
bool is_deferred = false;
48854887

48864888
wait_on_bit(&cinode->flags, CIFS_INODE_PENDING_WRITERS,
48874889
TASK_UNINTERRUPTIBLE);
@@ -4917,6 +4919,20 @@ void cifs_oplock_break(struct work_struct *work)
49174919
cifs_dbg(VFS, "Push locks rc = %d\n", rc);
49184920

49194921
oplock_break_ack:
4922+
/*
4923+
* When oplock break is received and there are no active
4924+
* file handles but cached, then schedule deferred close immediately.
4925+
* So, new open will not use cached handle.
4926+
*/
4927+
spin_lock(&CIFS_I(inode)->deferred_lock);
4928+
is_deferred = cifs_is_deferred_close(cfile, &dclose);
4929+
spin_unlock(&CIFS_I(inode)->deferred_lock);
4930+
4931+
if (!CIFS_CACHE_HANDLE(cinode) && is_deferred &&
4932+
cfile->deferred_close_scheduled && delayed_work_pending(&cfile->deferred)) {
4933+
cifs_close_deferred_file(cinode);
4934+
}
4935+
49204936
/*
49214937
* releasing stale oplock after recent reconnect of smb session using
49224938
* a now incorrect file handle is not a data integrity issue but do

fs/cifs/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)
764764
spin_unlock(&cifs_inode->open_file_lock);
765765

766766
list_for_each_entry_safe(tmp_list, tmp_next_list, &file_head, list) {
767-
_cifsFileInfo_put(tmp_list->cfile, true, false);
767+
_cifsFileInfo_put(tmp_list->cfile, false, false);
768768
list_del(&tmp_list->list);
769769
kfree(tmp_list);
770770
}

0 commit comments

Comments
 (0)