diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-07 14:56:44 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-11 21:36:11 -0400 |
commit | d5aacad548db1ff547adf35d0a77eb2a8ed4fe14 (patch) | |
tree | fbdf12dbacde76a1bb57738f1f67b87a673ddff2 | |
parent | 337eb00a2c3a421999c39c94ce7e33545ee8baa7 (diff) |
New helper - simple_fsync()
writes associated buffers, then does sync_inode() to write
the inode itself (and to make it clean). Depends on
->write_inode() honouring the second argument.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/libfs.c | 25 | ||||
-rw-r--r-- | include/linux/fs.h | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/fs/libfs.c b/fs/libfs.c index 80046ddf5063..ddfa89948c3f 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
@@ -9,6 +9,8 @@ | |||
9 | #include <linux/vfs.h> | 9 | #include <linux/vfs.h> |
10 | #include <linux/mutex.h> | 10 | #include <linux/mutex.h> |
11 | #include <linux/exportfs.h> | 11 | #include <linux/exportfs.h> |
12 | #include <linux/writeback.h> | ||
13 | #include <linux/buffer_head.h> | ||
12 | 14 | ||
13 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
14 | 16 | ||
@@ -807,6 +809,29 @@ struct dentry *generic_fh_to_parent(struct super_block *sb, struct fid *fid, | |||
807 | } | 809 | } |
808 | EXPORT_SYMBOL_GPL(generic_fh_to_parent); | 810 | EXPORT_SYMBOL_GPL(generic_fh_to_parent); |
809 | 811 | ||
812 | int simple_fsync(struct file *file, struct dentry *dentry, int datasync) | ||
813 | { | ||
814 | struct writeback_control wbc = { | ||
815 | .sync_mode = WB_SYNC_ALL, | ||
816 | .nr_to_write = 0, /* metadata-only; caller takes care of data */ | ||
817 | }; | ||
818 | struct inode *inode = dentry->d_inode; | ||
819 | int err; | ||
820 | int ret; | ||
821 | |||
822 | ret = sync_mapping_buffers(inode->i_mapping); | ||
823 | if (!(inode->i_state & I_DIRTY)) | ||
824 | return ret; | ||
825 | if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) | ||
826 | return ret; | ||
827 | |||
828 | err = sync_inode(inode, &wbc); | ||
829 | if (ret == 0) | ||
830 | ret = err; | ||
831 | return ret; | ||
832 | } | ||
833 | EXPORT_SYMBOL(simple_fsync); | ||
834 | |||
810 | EXPORT_SYMBOL(dcache_dir_close); | 835 | EXPORT_SYMBOL(dcache_dir_close); |
811 | EXPORT_SYMBOL(dcache_dir_lseek); | 836 | EXPORT_SYMBOL(dcache_dir_lseek); |
812 | EXPORT_SYMBOL(dcache_dir_open); | 837 | EXPORT_SYMBOL(dcache_dir_open); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index d883aa1fc2eb..ede84fa7da5d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2345,6 +2345,8 @@ extern void simple_release_fs(struct vfsmount **mount, int *count); | |||
2345 | extern ssize_t simple_read_from_buffer(void __user *to, size_t count, | 2345 | extern ssize_t simple_read_from_buffer(void __user *to, size_t count, |
2346 | loff_t *ppos, const void *from, size_t available); | 2346 | loff_t *ppos, const void *from, size_t available); |
2347 | 2347 | ||
2348 | extern int simple_fsync(struct file *, struct dentry *, int); | ||
2349 | |||
2348 | #ifdef CONFIG_MIGRATION | 2350 | #ifdef CONFIG_MIGRATION |
2349 | extern int buffer_migrate_page(struct address_space *, | 2351 | extern int buffer_migrate_page(struct address_space *, |
2350 | struct page *, struct page *); | 2352 | struct page *, struct page *); |