Skip to content

Commit

Permalink
rename the generic fsync implementations
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Al Viro committed May 28, 2010
1 parent 7ea8085 commit 1b061d9
Show file tree
Hide file tree
Showing 23 changed files with 44 additions and 32 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const struct file_operations spufs_context_fops = {
.llseek = dcache_dir_lseek,
.read = generic_read_dir,
.readdir = dcache_readdir,
.fsync = simple_sync_file,
.fsync = noop_fsync,
};
EXPORT_SYMBOL_GPL(spufs_context_fops);

Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const struct file_operations adfs_dir_operations = {
.read = generic_read_dir,
.llseek = generic_file_llseek,
.readdir = adfs_readdir,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
};

static int
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const struct file_operations adfs_file_operations = {
.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,
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static int bfs_readdir(struct file *f, void *dirent, filldir_t filldir)
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,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/ext2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int ext2_fsync(struct file *file, int datasync)
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__,
Expand Down
2 changes: 1 addition & 1 deletion fs/ext4/fsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int ext4_sync_file(struct file *file, int datasync)
return ret;

if (!journal) {
ret = simple_fsync(file, datasync);
ret = generic_file_fsync(file, datasync);
if (!ret && !list_empty(&inode->i_dentry))
ext4_sync_parent(inode);
return ret;
Expand Down
2 changes: 1 addition & 1 deletion fs/fat/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int fat_file_fsync(struct file *filp, int datasync)
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;
Expand Down
2 changes: 1 addition & 1 deletion fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
30 changes: 21 additions & 9 deletions fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, struct na
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 = "."};
Expand Down Expand Up @@ -190,7 +185,7 @@ const struct file_operations simple_dir_operations = {
.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 = {
Expand Down Expand Up @@ -851,7 +846,16 @@ struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid,
}
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,
Expand All @@ -872,7 +876,15 @@ int simple_fsync(struct file *file, int datasync)
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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/minix/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const struct file_operations minix_dir_operations = {
.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)
Expand Down
2 changes: 1 addition & 1 deletion fs/minix/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const struct file_operations minix_file_operations = {
.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,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/omfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ const struct file_operations omfs_file_operations = {
.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,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/qnx4/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const struct file_operations qnx4_dir_operations =
.llseek = generic_file_llseek,
.read = generic_read_dir,
.readdir = qnx4_readdir,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
};

const struct inode_operations qnx4_dir_inode_operations =
Expand Down
2 changes: 1 addition & 1 deletion fs/ramfs/file-mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const struct file_operations ramfs_file_operations = {
.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,
Expand Down
2 changes: 1 addition & 1 deletion fs/ramfs/file-nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const struct file_operations ramfs_file_operations = {
.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,
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const struct file_operations sysv_dir_operations = {
.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)
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const struct file_operations sysv_file_operations = {
.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,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/udf/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,5 @@ const struct file_operations udf_dir_operations = {
.read = generic_read_dir,
.readdir = udf_readdir,
.unlocked_ioctl = udf_ioctl,
.fsync = simple_fsync,
.fsync = generic_file_fsync,
};
2 changes: 1 addition & 1 deletion fs/udf/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const struct file_operations udf_file_operations = {
.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,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/ufs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,6 @@ int ufs_empty_dir(struct inode * inode)
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,
};
2 changes: 1 addition & 1 deletion fs/ufs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ const struct file_operations ufs_file_operations = {
.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,
};
4 changes: 2 additions & 2 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,7 @@ extern int simple_link(struct dentry *, struct inode *, 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,
Expand All @@ -2373,7 +2373,7 @@ extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
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 *,
Expand Down
2 changes: 1 addition & 1 deletion mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ static const struct file_operations shmem_file_operations = {
.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
Expand Down

0 comments on commit 1b061d9

Please sign in to comment.