xfs: factor out everything but the filemap_write_and_wait from xfs_file_fsync Hi, Fsyncing is tricky business, so factor out the bits of the xfs_file_fsync function that can be used from the I/O post-processing path. Signed-off-by: Jeff Moyer diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 54a67dd..e63030f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -153,25 +153,18 @@ xfs_dir_fsync( return _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL); } +/* + * Returns 0 on success, -errno on failure. + */ STATIC int -xfs_file_fsync( - struct file *file, - loff_t start, - loff_t end, +do_xfs_file_fsync( + struct xfs_inode *ip, + struct xfs_mount *mp, int datasync) { - struct inode *inode = file->f_mapping->host; - struct xfs_inode *ip = XFS_I(inode); - struct xfs_mount *mp = ip->i_mount; - int error = 0; int log_flushed = 0; xfs_lsn_t lsn = 0; - - trace_xfs_file_fsync(ip); - - error = filemap_write_and_wait_range(inode->i_mapping, start, end); - if (error) - return error; + int error = 0; if (XFS_FORCED_SHUTDOWN(mp)) return -XFS_ERROR(EIO); @@ -223,6 +216,27 @@ xfs_file_fsync( return -error; } +STATIC int +xfs_file_fsync( + struct file *file, + loff_t start, + loff_t end, + int datasync) +{ + struct inode *inode = file->f_mapping->host; + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + int error = 0; + + trace_xfs_file_fsync(ip); + + error = filemap_write_and_wait_range(inode->i_mapping, start, end); + if (error) + return error; + + return do_xfs_file_fsync(ip, mp, datasync); +} + STATIC ssize_t xfs_file_aio_read( struct kiocb *iocb,