We don't name our generic fsync implementations very well currently. The no-op implementation for in-memory filesystems currently is called simple_sync_file which doesn't make too much sense to start with, the the generic one for simple filesystems is called simple_fsync which can lead to some confusion. This patch renames the generic file fsync method to generic_file_fsync to match the other generic_file_* routines it is supposed to be used with, and the no-op implementation to noop_fsync to make it obvious what to expect. In addition add some documentation for both methods. Signed-off-by: Christoph Hellwig <hch@xxxxxx> Index: linux-2.6/arch/powerpc/platforms/cell/spufs/inode.c =================================================================== --- linux-2.6.orig/arch/powerpc/platforms/cell/spufs/inode.c 2010-05-26 16:32:19.643254294 +0200 +++ linux-2.6/arch/powerpc/platforms/cell/spufs/inode.c 2010-05-26 16:38:40.045006912 +0200 @@ -251,7 +251,7 @@ const struct file_operations spufs_conte .llseek = dcache_dir_lseek, .read = generic_read_dir, .readdir = dcache_readdir, - .fsync = simple_sync_file, + .fsync = noop_fsync, }; EXPORT_SYMBOL_GPL(spufs_context_fops); Index: linux-2.6/fs/adfs/dir.c =================================================================== --- linux-2.6.orig/fs/adfs/dir.c 2010-05-26 16:34:54.827004261 +0200 +++ linux-2.6/fs/adfs/dir.c 2010-05-26 16:37:47.533004051 +0200 @@ -197,7 +197,7 @@ const struct file_operations adfs_dir_op .read = generic_read_dir, .llseek = generic_file_llseek, .readdir = adfs_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, }; static int Index: linux-2.6/fs/adfs/file.c =================================================================== --- linux-2.6.orig/fs/adfs/file.c 2010-05-26 16:34:54.839003911 +0200 +++ linux-2.6/fs/adfs/file.c 2010-05-26 16:35:07.517253108 +0200 @@ -26,7 +26,7 @@ const struct file_operations adfs_file_o .read = do_sync_read, .aio_read = generic_file_aio_read, .mmap = generic_file_mmap, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .write = do_sync_write, .aio_write = generic_file_aio_write, .splice_read = generic_file_splice_read, Index: linux-2.6/fs/bfs/dir.c =================================================================== --- linux-2.6.orig/fs/bfs/dir.c 2010-05-26 16:34:54.853011664 +0200 +++ linux-2.6/fs/bfs/dir.c 2010-05-26 16:35:09.686254505 +0200 @@ -78,7 +78,7 @@ static int bfs_readdir(struct file *f, v const struct file_operations bfs_dir_operations = { .read = generic_read_dir, .readdir = bfs_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .llseek = generic_file_llseek, }; Index: linux-2.6/fs/ext2/file.c =================================================================== --- linux-2.6.orig/fs/ext2/file.c 2010-05-26 16:34:54.865004261 +0200 +++ linux-2.6/fs/ext2/file.c 2010-05-26 16:35:11.779033175 +0200 @@ -46,7 +46,7 @@ int ext2_fsync(struct file *file, int da struct super_block *sb = file->f_mapping->host->i_sb; struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; - ret = simple_fsync(file, datasync); + ret = generic_file_fsync(file, datasync); if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) { /* We don't really know where the IO error happened... */ ext2_error(sb, __func__, Index: linux-2.6/fs/ext4/fsync.c =================================================================== --- linux-2.6.orig/fs/ext4/fsync.c 2010-05-26 16:34:54.883254994 +0200 +++ linux-2.6/fs/ext4/fsync.c 2010-05-26 16:35:14.455254853 +0200 @@ -68,7 +68,7 @@ int ext4_sync_file(struct file *file, in return ret; if (!journal) - return simple_fsync(file, datasync); + return generic_file_fsync(file, datasync); /* * data=writeback,ordered: Index: linux-2.6/fs/fat/file.c =================================================================== --- linux-2.6.orig/fs/fat/file.c 2010-05-26 16:34:54.903253736 +0200 +++ linux-2.6/fs/fat/file.c 2010-05-26 16:35:16.751004050 +0200 @@ -154,7 +154,7 @@ int fat_file_fsync(struct file *filp, in struct inode *inode = filp->f_mapping->host; int res, err; - res = simple_fsync(filp, datasync); + res = generic_file_fsync(filp, datasync); err = sync_mapping_buffers(MSDOS_SB(inode->i_sb)->fat_inode->i_mapping); return res ? res : err; Index: linux-2.6/fs/hugetlbfs/inode.c =================================================================== --- linux-2.6.orig/fs/hugetlbfs/inode.c 2010-05-26 16:32:19.660254154 +0200 +++ linux-2.6/fs/hugetlbfs/inode.c 2010-05-26 16:38:04.606005657 +0200 @@ -688,7 +688,7 @@ static void init_once(void *foo) const struct file_operations hugetlbfs_file_operations = { .read = hugetlbfs_read, .mmap = hugetlbfs_file_mmap, - .fsync = simple_sync_file, + .fsync = noop_fsync, .get_unmapped_area = hugetlb_get_unmapped_area, }; Index: linux-2.6/fs/libfs.c =================================================================== --- linux-2.6.orig/fs/libfs.c 2010-05-26 16:32:19.677253666 +0200 +++ linux-2.6/fs/libfs.c 2010-05-26 17:47:37.198029053 +0200 @@ -58,11 +58,6 @@ struct dentry *simple_lookup(struct inod return NULL; } -int simple_sync_file(struct file *file, int datasync) -{ - return 0; -} - int dcache_dir_open(struct inode *inode, struct file *file) { static struct qstr cursor_name = {.len = 1, .name = "."}; @@ -190,7 +185,7 @@ const struct file_operations simple_dir_ .llseek = dcache_dir_lseek, .read = generic_read_dir, .readdir = dcache_readdir, - .fsync = simple_sync_file, + .fsync = noop_fsync, }; const struct inode_operations simple_dir_inode_operations = { @@ -851,7 +846,16 @@ struct dentry *generic_fh_to_parent(stru } EXPORT_SYMBOL_GPL(generic_fh_to_parent); -int simple_fsync(struct file *file, int datasync) +/** + * generic_file_fsync - generic fsync implementation for simple filesystems + * @file: file to synchronize + * @datasync: only synchronize essential metadata if true + * + * This is a generic implementation of the fsync method for simple + * filesystems which track all non-inode metadata in the buffers list + * hanging off the address_space structure. + */ +int generic_file_fsync(struct file *file, int datasync) { struct writeback_control wbc = { .sync_mode = WB_SYNC_ALL, @@ -872,7 +876,15 @@ int simple_fsync(struct file *file, int ret = err; return ret; } -EXPORT_SYMBOL(simple_fsync); +EXPORT_SYMBOL(generic_file_fsync); + +/* + * No-op implementation of ->fsync for in-memory filesystems. + */ +int noop_fsync(struct file *file, int datasync) +{ + return 0; +} EXPORT_SYMBOL(dcache_dir_close); EXPORT_SYMBOL(dcache_dir_lseek); @@ -895,7 +907,7 @@ EXPORT_SYMBOL(simple_release_fs); EXPORT_SYMBOL(simple_rename); EXPORT_SYMBOL(simple_rmdir); EXPORT_SYMBOL(simple_statfs); -EXPORT_SYMBOL(simple_sync_file); +EXPORT_SYMBOL(noop_fsync); EXPORT_SYMBOL(simple_unlink); EXPORT_SYMBOL(simple_read_from_buffer); EXPORT_SYMBOL(simple_write_to_buffer); Index: linux-2.6/fs/minix/dir.c =================================================================== --- linux-2.6.orig/fs/minix/dir.c 2010-05-26 16:34:54.926253247 +0200 +++ linux-2.6/fs/minix/dir.c 2010-05-26 16:37:19.604258067 +0200 @@ -22,7 +22,7 @@ const struct file_operations minix_dir_o .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = minix_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, }; static inline void dir_put_page(struct page *page) Index: linux-2.6/fs/minix/file.c =================================================================== --- linux-2.6.orig/fs/minix/file.c 2010-05-26 16:34:54.942003841 +0200 +++ linux-2.6/fs/minix/file.c 2010-05-26 16:37:21.908004330 +0200 @@ -19,7 +19,7 @@ const struct file_operations minix_file_ .write = do_sync_write, .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .splice_read = generic_file_splice_read, }; Index: linux-2.6/fs/omfs/file.c =================================================================== --- linux-2.6.orig/fs/omfs/file.c 2010-05-26 16:34:54.969004261 +0200 +++ linux-2.6/fs/omfs/file.c 2010-05-26 16:37:24.056019205 +0200 @@ -329,7 +329,7 @@ const struct file_operations omfs_file_o .aio_read = generic_file_aio_read, .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .splice_read = generic_file_splice_read, }; Index: linux-2.6/fs/qnx4/dir.c =================================================================== --- linux-2.6.orig/fs/qnx4/dir.c 2010-05-26 16:34:54.993254854 +0200 +++ linux-2.6/fs/qnx4/dir.c 2010-05-26 16:37:26.781257509 +0200 @@ -79,7 +79,7 @@ const struct file_operations qnx4_dir_op { .read = generic_read_dir, .readdir = qnx4_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, }; const struct inode_operations qnx4_dir_inode_operations = Index: linux-2.6/fs/ramfs/file-mmu.c =================================================================== --- linux-2.6.orig/fs/ramfs/file-mmu.c 2010-05-26 16:32:19.689253875 +0200 +++ linux-2.6/fs/ramfs/file-mmu.c 2010-05-26 16:38:30.342255831 +0200 @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_ .write = do_sync_write, .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, - .fsync = simple_sync_file, + .fsync = noop_fsync, .splice_read = generic_file_splice_read, .splice_write = generic_file_splice_write, .llseek = generic_file_llseek, Index: linux-2.6/fs/ramfs/file-nommu.c =================================================================== --- linux-2.6.orig/fs/ramfs/file-nommu.c 2010-05-26 16:32:19.701004050 +0200 +++ linux-2.6/fs/ramfs/file-nommu.c 2010-05-26 16:38:32.553008730 +0200 @@ -42,7 +42,7 @@ const struct file_operations ramfs_file_ .aio_read = generic_file_aio_read, .write = do_sync_write, .aio_write = generic_file_aio_write, - .fsync = simple_sync_file, + .fsync = noop_fsync, .splice_read = generic_file_splice_read, .splice_write = generic_file_splice_write, .llseek = generic_file_llseek, Index: linux-2.6/fs/sysv/dir.c =================================================================== --- linux-2.6.orig/fs/sysv/dir.c 2010-05-26 16:34:55.007005448 +0200 +++ linux-2.6/fs/sysv/dir.c 2010-05-26 16:37:29.090254085 +0200 @@ -24,7 +24,7 @@ const struct file_operations sysv_dir_op .llseek = generic_file_llseek, .read = generic_read_dir, .readdir = sysv_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, }; static inline void dir_put_page(struct page *page) Index: linux-2.6/fs/sysv/file.c =================================================================== --- linux-2.6.orig/fs/sysv/file.c 2010-05-26 16:34:55.028254365 +0200 +++ linux-2.6/fs/sysv/file.c 2010-05-26 16:37:31.455038692 +0200 @@ -26,7 +26,7 @@ const struct file_operations sysv_file_o .write = do_sync_write, .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .splice_read = generic_file_splice_read, }; Index: linux-2.6/fs/udf/dir.c =================================================================== --- linux-2.6.orig/fs/udf/dir.c 2010-05-26 16:34:55.049004260 +0200 +++ linux-2.6/fs/udf/dir.c 2010-05-26 16:37:33.565006356 +0200 @@ -210,5 +210,5 @@ const struct file_operations udf_dir_ope .read = generic_read_dir, .readdir = udf_readdir, .unlocked_ioctl = udf_ioctl, - .fsync = simple_fsync, + .fsync = generic_file_fsync, }; Index: linux-2.6/fs/udf/file.c =================================================================== --- linux-2.6.orig/fs/udf/file.c 2010-05-26 16:34:55.064003841 +0200 +++ linux-2.6/fs/udf/file.c 2010-05-26 16:37:35.876005448 +0200 @@ -224,7 +224,7 @@ const struct file_operations udf_file_op .write = do_sync_write, .aio_write = udf_file_aio_write, .release = udf_release_file, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .splice_read = generic_file_splice_read, .llseek = generic_file_llseek, }; Index: linux-2.6/fs/ufs/dir.c =================================================================== --- linux-2.6.orig/fs/ufs/dir.c 2010-05-26 16:34:55.083003841 +0200 +++ linux-2.6/fs/ufs/dir.c 2010-05-26 16:37:38.368005098 +0200 @@ -666,6 +666,6 @@ not_empty: const struct file_operations ufs_dir_operations = { .read = generic_read_dir, .readdir = ufs_readdir, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .llseek = generic_file_llseek, }; Index: linux-2.6/fs/ufs/file.c =================================================================== --- linux-2.6.orig/fs/ufs/file.c 2010-05-26 16:34:55.099004470 +0200 +++ linux-2.6/fs/ufs/file.c 2010-05-26 16:37:40.645004259 +0200 @@ -42,6 +42,6 @@ const struct file_operations ufs_file_op .aio_write = generic_file_aio_write, .mmap = generic_file_mmap, .open = dquot_file_open, - .fsync = simple_fsync, + .fsync = generic_file_fsync, .splice_read = generic_file_splice_read, }; Index: linux-2.6/include/linux/fs.h =================================================================== --- linux-2.6.orig/include/linux/fs.h 2010-05-26 16:32:19.719004260 +0200 +++ linux-2.6/include/linux/fs.h 2010-05-26 16:38:34.918257228 +0200 @@ -2341,7 +2341,7 @@ extern int simple_link(struct dentry *, extern int simple_unlink(struct inode *, struct dentry *); extern int simple_rmdir(struct inode *, struct dentry *); extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); -extern int simple_sync_file(struct file *, int); +extern int noop_fsync(struct file *, int); extern int simple_empty(struct dentry *); extern int simple_readpage(struct file *file, struct page *page); extern int simple_write_begin(struct file *file, struct address_space *mapping, @@ -2366,7 +2366,7 @@ extern ssize_t simple_read_from_buffer(v extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, const void __user *from, size_t count); -extern int simple_fsync(struct file *, int); +extern int generic_file_fsync(struct file *, int); #ifdef CONFIG_MIGRATION extern int buffer_migrate_page(struct address_space *, Index: linux-2.6/mm/shmem.c =================================================================== --- linux-2.6.orig/mm/shmem.c 2010-05-26 16:32:19.737004190 +0200 +++ linux-2.6/mm/shmem.c 2010-05-26 16:38:37.331007822 +0200 @@ -2433,7 +2433,7 @@ static const struct file_operations shme .write = do_sync_write, .aio_read = shmem_file_aio_read, .aio_write = generic_file_aio_write, - .fsync = simple_sync_file, + .fsync = noop_fsync, .splice_read = generic_file_splice_read, .splice_write = generic_file_splice_write, #endif -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html