blob: b2c472b733b8a75cb83456fff70808da11dfbca6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fsync.c
3 *
4 * PURPOSE
5 * Fsync handling routines for the OSTA-UDF(tm) filesystem.
6 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * COPYRIGHT
8 * This file is distributed under the terms of the GNU General Public
9 * License (GPL). Copies of the GPL can be obtained from:
10 * ftp://prep.ai.mit.edu/pub/gnu/GPL
11 * Each contributing author retains all rights to their own work.
12 *
13 * (C) 1999-2001 Ben Fennema
14 * (C) 1999-2000 Stelias Computing Inc
15 *
16 * HISTORY
17 *
18 * 05/22/99 blf Created.
19 */
20
21#include "udfdecl.h"
22
23#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25static int udf_fsync_inode(struct inode *, int);
26
27/*
28 * File may be NULL when we are called. Perhaps we shouldn't
29 * even pass file to fsync ?
30 */
31
Cyrill Gorcunovcb00ea32007-07-19 01:47:43 -070032int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
34 struct inode *inode = dentry->d_inode;
Cyrill Gorcunov28de7942007-07-21 04:37:18 -070035
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 return udf_fsync_inode(inode, datasync);
37}
38
39static int udf_fsync_inode(struct inode *inode, int datasync)
40{
41 int err;
42
43 err = sync_mapping_buffers(inode->i_mapping);
44 if (!(inode->i_state & I_DIRTY))
45 return err;
46 if (datasync && !(inode->i_state & I_DIRTY_DATASYNC))
47 return err;
48
Cyrill Gorcunovcb00ea32007-07-19 01:47:43 -070049 err |= udf_sync_inode(inode);
Cyrill Gorcunov28de7942007-07-21 04:37:18 -070050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 return err ? -EIO : 0;
52}