Commit 4efa53f0 authored by Steve French's avatar Steve French

[CIFS] lock inode open file list in close in case racing with open

Harmless since it only protected turning off caching for the
inode, but cleaner to lock around this in case we have a close
racing with open.
Signed-off-by: default avatarShaggy <shaggy@us.ibm.com>
CC: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 15745320
...@@ -545,6 +545,7 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -545,6 +545,7 @@ int cifs_close(struct inode *inode, struct file *file)
} else } else
rc = -EBADF; rc = -EBADF;
read_lock(&GlobalSMBSeslock);
if (list_empty(&(CIFS_I(inode)->openFileList))) { if (list_empty(&(CIFS_I(inode)->openFileList))) {
cFYI(1, ("closing last open instance for inode %p", inode)); cFYI(1, ("closing last open instance for inode %p", inode));
/* if the file is not open we do not know if we can cache info /* if the file is not open we do not know if we can cache info
...@@ -552,6 +553,7 @@ int cifs_close(struct inode *inode, struct file *file) ...@@ -552,6 +553,7 @@ int cifs_close(struct inode *inode, struct file *file)
CIFS_I(inode)->clientCanCacheRead = FALSE; CIFS_I(inode)->clientCanCacheRead = FALSE;
CIFS_I(inode)->clientCanCacheAll = FALSE; CIFS_I(inode)->clientCanCacheAll = FALSE;
} }
read_unlock(&GlobalSMBSeslock);
if ((rc == 0) && CIFS_I(inode)->write_behind_rc) if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
rc = CIFS_I(inode)->write_behind_rc; rc = CIFS_I(inode)->write_behind_rc;
FreeXid(xid); FreeXid(xid);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment