Commit 776a75fa authored by Lachlan McIlroy's avatar Lachlan McIlroy Committed by Tim Shimmin

[XFS] Ensure file size updates have been completed before writing inode to disk.

SGI-PV: 968767
SGI-Modid: xfs-linux-melb:xfs-kern:29675a
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: default avatarDavid Chinner <dgc@sgi.com>
Signed-off-by: default avatarTim Shimmin <tes@sgi.com>
parent 65de5567
...@@ -181,6 +181,7 @@ xfs_setfilesize( ...@@ -181,6 +181,7 @@ xfs_setfilesize(
ip->i_d.di_size = isize; ip->i_d.di_size = isize;
ip->i_update_core = 1; ip->i_update_core = 1;
ip->i_update_size = 1; ip->i_update_size = 1;
mark_inode_dirty_sync(vn_to_inode(ioend->io_vnode));
} }
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
......
...@@ -415,8 +415,10 @@ xfs_fs_write_inode( ...@@ -415,8 +415,10 @@ xfs_fs_write_inode(
if (vp) { if (vp) {
vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
if (sync) if (sync) {
filemap_fdatawait(inode->i_mapping);
flags |= FLUSH_SYNC; flags |= FLUSH_SYNC;
}
error = bhv_vop_iflush(vp, flags); error = bhv_vop_iflush(vp, flags);
if (error == EAGAIN) if (error == EAGAIN)
error = sync? bhv_vop_iflush(vp, flags | FLUSH_LOG) : 0; error = sync? bhv_vop_iflush(vp, flags | FLUSH_LOG) : 0;
......
...@@ -1082,6 +1082,9 @@ xfs_fsync( ...@@ -1082,6 +1082,9 @@ xfs_fsync(
if (XFS_FORCED_SHUTDOWN(ip->i_mount)) if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
if (flag & FSYNC_DATA)
filemap_fdatawait(vn_to_inode(XFS_ITOV(ip))->i_mapping);
/* /*
* We always need to make sure that the required inode state * We always need to make sure that the required inode state
* is safe on disk. The vnode might be clean but because * is safe on disk. The vnode might be clean but because
...@@ -3769,12 +3772,16 @@ xfs_inode_flush( ...@@ -3769,12 +3772,16 @@ xfs_inode_flush(
sync_lsn = log->l_last_sync_lsn; sync_lsn = log->l_last_sync_lsn;
GRANT_UNLOCK(log, s); GRANT_UNLOCK(log, s);
if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) <= 0)) if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) > 0)) {
return 0; if (flags & FLUSH_SYNC)
log_flags |= XFS_LOG_SYNC;
error = xfs_log_force(mp, iip->ili_last_lsn, log_flags);
if (error)
return error;
}
if (flags & FLUSH_SYNC) if (ip->i_update_core == 0)
log_flags |= XFS_LOG_SYNC; return 0;
return xfs_log_force(mp, iip->ili_last_lsn, log_flags);
} }
} }
...@@ -3788,9 +3795,6 @@ xfs_inode_flush( ...@@ -3788,9 +3795,6 @@ xfs_inode_flush(
if (flags & FLUSH_INODE) { if (flags & FLUSH_INODE) {
int flush_flags; int flush_flags;
if (xfs_ipincount(ip))
return EAGAIN;
if (flags & FLUSH_SYNC) { if (flags & FLUSH_SYNC) {
xfs_ilock(ip, XFS_ILOCK_SHARED); xfs_ilock(ip, XFS_ILOCK_SHARED);
xfs_iflock(ip); xfs_iflock(ip);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment