get rid of file_fsync()
Al Viro [Sun, 4 Jul 2010 08:24:09 +0000 (12:24 +0400)]
Copy and simplify in the only two users remaining.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

fs/hfs/inode.c
fs/hfsplus/hfsplus_fs.h
fs/hfsplus/inode.c
fs/hfsplus/super.c
fs/sync.c
include/linux/buffer_head.h

index 87de671..93ceec8 100644 (file)
@@ -625,6 +625,30 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr * attr)
        return 0;
 }
 
+static int hfs_file_fsync(struct file *filp, int datasync)
+{
+       struct inode *inode = filp->f_mapping->host;
+       struct super_block * sb;
+       int ret, err;
+
+       /* sync the inode to buffers */
+       ret = write_inode_now(inode, 0);
+
+       /* sync the superblock to buffers */
+       sb = inode->i_sb;
+       if (sb->s_dirt) {
+               lock_super(sb);
+               sb->s_dirt = 0;
+               if (!(sb->s_flags & MS_RDONLY))
+                       hfs_mdb_commit(sb);
+               unlock_super(sb);
+       }
+       /* .. finally sync the buffers to disk */
+       err = sync_blockdev(sb->s_bdev);
+       if (!ret)
+               ret = err;
+       return ret;
+}
 
 static const struct file_operations hfs_file_operations = {
        .llseek         = generic_file_llseek,
@@ -634,7 +658,7 @@ static const struct file_operations hfs_file_operations = {
        .aio_write      = generic_file_aio_write,
        .mmap           = generic_file_mmap,
        .splice_read    = generic_file_splice_read,
-       .fsync          = file_fsync,
+       .fsync          = hfs_file_fsync,
        .open           = hfs_file_open,
        .release        = hfs_file_release,
 };
index 6505c30..dc856be 100644 (file)
@@ -351,6 +351,7 @@ int hfsplus_show_options(struct seq_file *, struct vfsmount *);
 
 /* super.c */
 struct inode *hfsplus_iget(struct super_block *, unsigned long);
+int hfsplus_sync_fs(struct super_block *sb, int wait);
 
 /* tables.c */
 extern u16 hfsplus_case_fold_table[];
index 654c5a8..c5a979d 100644 (file)
@@ -311,6 +311,31 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
        return 0;
 }
 
+static int hfsplus_file_fsync(struct file *filp, int datasync)
+{
+       struct inode *inode = filp->f_mapping->host;
+       struct super_block * sb;
+       int ret, err;
+
+       /* sync the inode to buffers */
+       ret = write_inode_now(inode, 0);
+
+       /* sync the superblock to buffers */
+       sb = inode->i_sb;
+       if (sb->s_dirt) {
+               if (!(sb->s_flags & MS_RDONLY))
+                       hfsplus_sync_fs(sb, 1);
+               else
+                       sb->s_dirt = 0;
+       }
+
+       /* .. finally sync the buffers to disk */
+       err = sync_blockdev(sb->s_bdev);
+       if (!ret)
+               ret = err;
+       return ret;
+}
+
 static const struct inode_operations hfsplus_file_inode_operations = {
        .lookup         = hfsplus_file_lookup,
        .truncate       = hfsplus_file_truncate,
@@ -328,7 +353,7 @@ static const struct file_operations hfsplus_file_operations = {
        .aio_write      = generic_file_aio_write,
        .mmap           = generic_file_mmap,
        .splice_read    = generic_file_splice_read,
-       .fsync          = file_fsync,
+       .fsync          = hfsplus_file_fsync,
        .open           = hfsplus_file_open,
        .release        = hfsplus_file_release,
        .unlocked_ioctl = hfsplus_ioctl,
index 74b473a..a32c241 100644 (file)
@@ -154,7 +154,7 @@ static void hfsplus_clear_inode(struct inode *inode)
        }
 }
 
-static int hfsplus_sync_fs(struct super_block *sb, int wait)
+int hfsplus_sync_fs(struct super_block *sb, int wait)
 {
        struct hfsplus_vh *vhdr = HFSPLUS_SB(sb).s_vhdr;
 
index 15aa6f0..ba76b96 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -128,31 +128,6 @@ void emergency_sync(void)
        }
 }
 
-/*
- * Generic function to fsync a file.
- */
-int file_fsync(struct file *filp, int datasync)
-{
-       struct inode *inode = filp->f_mapping->host;
-       struct super_block * sb;
-       int ret, err;
-
-       /* sync the inode to buffers */
-       ret = write_inode_now(inode, 0);
-
-       /* sync the superblock to buffers */
-       sb = inode->i_sb;
-       if (sb->s_dirt && sb->s_op->write_super)
-               sb->s_op->write_super(sb);
-
-       /* .. finally sync the buffers to disk */
-       err = sync_blockdev(sb->s_bdev);
-       if (!ret)
-               ret = err;
-       return ret;
-}
-EXPORT_SYMBOL(file_fsync);
-
 /**
  * vfs_fsync_range - helper to sync a range of data & metadata to disk
  * @file:              file to sync
index 3f69054..620f1d1 100644 (file)
@@ -225,7 +225,6 @@ int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
 void block_sync_page(struct page *);
 sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);
 int block_truncate_page(struct address_space *, loff_t, get_block_t *);
-int file_fsync(struct file *, int);
 int nobh_write_begin(struct address_space *, loff_t, unsigned, unsigned,
                                struct page **, void **, get_block_t*);
 int nobh_write_end(struct file *, struct address_space *,