fs: Use BUG_ON(!mnt) at dentry_open().
[deliverable/linux.git] / fs / sync.c
index 15aa6f03b2da11e5282c564d8d674374d4882a49..92ca208777d562e64bfc769dc41a326f7c3da84e 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -7,6 +7,7 @@
 #include <linux/fs.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/namei.h>
 #include <linux/sched.h>
 #include <linux/writeback.h>
 #include <linux/syscalls.h>
@@ -129,29 +130,27 @@ void emergency_sync(void)
 }
 
 /*
- * Generic function to fsync a file.
+ * sync a single super
  */
-int file_fsync(struct file *filp, int datasync)
+SYSCALL_DEFINE1(syncfs, int, fd)
 {
-       struct inode *inode = filp->f_mapping->host;
-       struct super_block * sb;
-       int ret, err;
+       struct file *file;
+       struct super_block *sb;
+       int ret;
+       int fput_needed;
 
-       /* sync the inode to buffers */
-       ret = write_inode_now(inode, 0);
+       file = fget_light(fd, &fput_needed);
+       if (!file)
+               return -EBADF;
+       sb = file->f_dentry->d_sb;
 
-       /* sync the superblock to buffers */
-       sb = inode->i_sb;
-       if (sb->s_dirt && sb->s_op->write_super)
-               sb->s_op->write_super(sb);
+       down_read(&sb->s_umount);
+       ret = sync_filesystem(sb);
+       up_read(&sb->s_umount);
 
-       /* .. finally sync the buffers to disk */
-       err = sync_blockdev(sb->s_bdev);
-       if (!ret)
-               ret = err;
+       fput_light(file, fput_needed);
        return ret;
 }
-EXPORT_SYMBOL(file_fsync);
 
 /**
  * vfs_fsync_range - helper to sync a range of data & metadata to disk
This page took 0.041046 seconds and 5 git commands to generate.