mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
337eb00a2c
commit
d5aacad548
2 changed files with 27 additions and 0 deletions
25
fs/libfs.c
25
fs/libfs.c
|
@ -9,6 +9,8 @@
|
|||
#include <linux/vfs.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/exportfs.h>
|
||||
#include <linux/writeback.h>
|
||||
#include <linux/buffer_head.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
|
@ -807,6 +809,29 @@ 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, struct dentry *dentry, int datasync)
|
||||
{
|
||||
struct writeback_control wbc = {
|
||||
.sync_mode = WB_SYNC_ALL,
|
||||
.nr_to_write = 0, /* metadata-only; caller takes care of data */
|
||||
};
|
||||
struct inode *inode = dentry->d_inode;
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
ret = sync_mapping_buffers(inode->i_mapping);
|
||||
if (!(inode->i_state & I_DIRTY))
|
||||
return ret;
|
||||
if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
|
||||
return ret;
|
||||
|
||||
err = sync_inode(inode, &wbc);
|
||||
if (ret == 0)
|
||||
ret = err;
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(simple_fsync);
|
||||
|
||||
EXPORT_SYMBOL(dcache_dir_close);
|
||||
EXPORT_SYMBOL(dcache_dir_lseek);
|
||||
EXPORT_SYMBOL(dcache_dir_open);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue