]> err.no Git - linux-2.6/blobdiff - fs/9p/vfs_file.c
[XFS] Kill off xfs_count_bits
[linux-2.6] / fs / 9p / vfs_file.c
index 9f17b0cacdd02e42cf5e3c658a99e62f0738f120..6e7678e4852ffa53b2e84fdd06dbf4ae8ce66b5a 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/file.h>
 #include <linux/stat.h>
 #include <linux/string.h>
-#include <linux/smp_lock.h>
 #include <linux/inet.h>
 #include <linux/list.h>
 #include <asm/uaccess.h>
@@ -42,6 +41,8 @@
 #include "v9fs_vfs.h"
 #include "fid.h"
 
+static const struct file_operations v9fs_cached_file_operations;
+
 /**
  * v9fs_file_open - open a file (or directory)
  * @inode: inode to be opened
@@ -79,6 +80,13 @@ int v9fs_file_open(struct inode *inode, struct file *file)
        vfid->filp = file;
        kfree(fcall);
 
+       if((vfid->qid.version) && (v9ses->cache)) {
+               dprintk(DEBUG_VFS, "cached");
+               /* enable cached file options */
+               if(file->f_op == &v9fs_file_operations)
+                       file->f_op = &v9fs_cached_file_operations;
+       }
+
        return 0;
 
 Clunk_Fid:
@@ -110,7 +118,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
 
        if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
                filemap_write_and_wait(inode->i_mapping);
-               invalidate_inode_pages(&inode->i_data);
+               invalidate_mapping_pages(&inode->i_data, 0, -1);
        }
 
        return res;
@@ -234,10 +242,21 @@ v9fs_file_write(struct file *filp, const char __user * data,
                total += result;
        } while (count);
 
-               invalidate_inode_pages2(inode->i_mapping);
+       invalidate_inode_pages2(inode->i_mapping);
        return total;
 }
 
+static const struct file_operations v9fs_cached_file_operations = {
+       .llseek = generic_file_llseek,
+       .read = do_sync_read,
+       .aio_read = generic_file_aio_read,
+       .write = v9fs_file_write,
+       .open = v9fs_file_open,
+       .release = v9fs_dir_release,
+       .lock = v9fs_file_lock,
+       .mmap = generic_file_mmap,
+};
+
 const struct file_operations v9fs_file_operations = {
        .llseek = generic_file_llseek,
        .read = v9fs_file_read,