CIFS: Implement cifs_file_strict_mmap (try #2)
authorPavel Shilovsky <piastryyy@gmail.com>
Tue, 14 Dec 2010 08:29:51 +0000 (11:29 +0300)
committerSteve French <sfrench@us.ibm.com>
Thu, 20 Jan 2011 21:42:25 +0000 (21:42 +0000)
Invalidate inode mapping if we don't have at least Level II oplock.

Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/file.c

index f6093e401c5a8461fb160b3ea6d969112a7e5a53..e24d966fb2144ced36236e51f5450650f73dc2cb 100644 (file)
@@ -743,7 +743,7 @@ const struct file_operations cifs_file_strict_ops = {
        .lock = cifs_lock,
        .fsync = cifs_strict_fsync,
        .flush = cifs_flush,
-       .mmap = cifs_file_mmap,
+       .mmap = cifs_file_strict_mmap,
        .splice_read = generic_file_splice_read,
        .llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
@@ -798,7 +798,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = {
        .release = cifs_close,
        .fsync = cifs_strict_fsync,
        .flush = cifs_flush,
-       .mmap = cifs_file_mmap,
+       .mmap = cifs_file_strict_mmap,
        .splice_read = generic_file_splice_read,
        .llseek = cifs_llseek,
 #ifdef CONFIG_CIFS_POSIX
index 10c4303c282de3459fbbf1e2a006b3040454d6e6..710072e36912b4a8e86f4ea9d36a71b80de54ea3 100644 (file)
@@ -89,6 +89,7 @@ extern int cifs_fsync(struct file *, int);
 extern int cifs_strict_fsync(struct file *, int);
 extern int cifs_flush(struct file *, fl_owner_t id);
 extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
+extern int cifs_file_strict_mmap(struct file * , struct vm_area_struct *);
 extern const struct file_operations cifs_dir_ops;
 extern int cifs_dir_open(struct inode *inode, struct file *file);
 extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
index 5790fab7349be0226b6f631b07d4a081bcd1f4cc..0b32377ef8b70003190a232f358677bfe2ad1175 100644 (file)
@@ -1769,6 +1769,21 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
        return total_read;
 }
 
+int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma)
+{
+       int rc, xid;
+       struct inode *inode = file->f_path.dentry->d_inode;
+
+       xid = GetXid();
+
+       if (!CIFS_I(inode)->clientCanCacheRead)
+               cifs_invalidate_mapping(inode);
+
+       rc = generic_file_mmap(file, vma);
+       FreeXid(xid);
+       return rc;
+}
+
 int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
 {
        int rc, xid;