]> err.no Git - linux-2.6/commitdiff
[PATCH] ufs: fsync implementation
authorEvgeniy Dushistov <dushistov@mail.ru>
Sun, 25 Jun 2006 12:47:30 +0000 (05:47 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sun, 25 Jun 2006 17:01:04 +0000 (10:01 -0700)
Presently ufs doesn't support "fsync", this make some applications unhappy,
for example vim.  This patch fixes this situation.

Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/ufs/file.c

index 312fd3f86313b61a7d6f7230699cc2f763d69008..0e5001512a9d85f0d176c247096aa96ededddda1 100644 (file)
 
 #include <linux/fs.h>
 #include <linux/ufs_fs.h>
+#include <linux/buffer_head.h> /* for sync_mapping_buffers() */
+
+static int ufs_sync_file(struct file *file, struct dentry *dentry, int datasync)
+{
+       struct inode *inode = dentry->d_inode;
+       int err;
+       int ret;
+
+       ret = sync_mapping_buffers(inode->i_mapping);
+       if (!(inode->i_state & I_DIRTY))
+               return ret;
+       if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
+               return ret;
+
+       err = ufs_sync_inode(inode);
+       if (ret == 0)
+               ret = err;
+       return ret;
+}
+
 
 /*
  * We have mostly NULL's here: the current defaults are ok for
@@ -37,6 +57,7 @@ const struct file_operations ufs_file_operations = {
        .write          = generic_file_write,
        .mmap           = generic_file_mmap,
        .open           = generic_file_open,
+       .fsync          = ufs_sync_file,
        .sendfile       = generic_file_sendfile,
 };