Commit 86dfc406 authored by Steve French's avatar Steve French

Invalidate readahead data properly when file closed, but other client changed it on server

parent fd3282b1
......@@ -171,7 +171,26 @@ cifs_open(struct inode *inode, struct file *file)
list_add(&pCifsFile->flist,&pCifsInode->openFileList);
write_unlock(&GlobalSMBSeslock);
write_unlock(&file->f_owner.lock);
if(pCifsInode->clientCanCacheRead) {
/* we have the inode open somewhere else
no need to discard cache data */
} else {
if(buf) {
/* BB need same check in cifs_create too? */
/* if not oplocked, invalidate inode pages if mtime
or file size changed */
struct timespec temp;
temp = cifs_NTtimeToUnix(le64_to_cpu(buf->LastWriteTime));
if(timespec_equal(&file->f_dentry->d_inode->i_mtime,&temp) &&
(file->f_dentry->d_inode->i_size == le64_to_cpu(buf->EndOfFile))) {
cFYI(1,("inode unchanged on server"));
} else {
cFYI(1,("invalidating remote inode since open detected it changed"));
invalidate_remote_inode(file->f_dentry->d_inode);
}
}
}
if (pTcon->ses->capabilities & CAP_UNIX)
rc = cifs_get_inode_info_unix(&file->f_dentry->d_inode,
full_path, inode->i_sb);
......
......@@ -627,7 +627,7 @@ cifs_revalidate(struct dentry *direntry)
if(timespec_equal(&local_mtime,&direntry->d_inode->i_mtime) &&
(local_size == direntry->d_inode->i_size)) {
cFYI(1,("inode unchanged on server"));
cFYI(1,("cifs_revalidate - inode unchanged"));
} else {
/* file may have changed on server */
if(cifsInode->clientCanCacheRead) {
......@@ -648,7 +648,12 @@ cifs_revalidate(struct dentry *direntry)
}
if(invalidate_inode) {
filemap_fdatawait(direntry->d_inode->i_mapping);
/* invalidate_remote_inode(direntry->d_inode); */ /* BB fixme */
/* may eventually have to do this for open files too */
if(list_empty(&(cifsInode->openFileList))) {
/* Has changed on server - flush read ahead pages */
cFYI(1,("Invalidating read ahead data on closed file"));
invalidate_remote_inode(direntry->d_inode);
}
}
......
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