[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: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: David Chinner <dgc@sgi.com>
Signed-off-by: Tim Shimmin <tes@sgi.com>

authored by Lachlan McIlroy and committed by Tim Shimmin 776a75fa 65de5567

+16 -9
+1
fs/xfs/linux-2.6/xfs_aops.c
··· 181 181 ip->i_d.di_size = isize; 182 182 ip->i_update_core = 1; 183 183 ip->i_update_size = 1; 184 + mark_inode_dirty_sync(vn_to_inode(ioend->io_vnode)); 184 185 } 185 186 186 187 xfs_iunlock(ip, XFS_ILOCK_EXCL);
+3 -1
fs/xfs/linux-2.6/xfs_super.c
··· 415 415 416 416 if (vp) { 417 417 vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address); 418 - if (sync) 418 + if (sync) { 419 + filemap_fdatawait(inode->i_mapping); 419 420 flags |= FLUSH_SYNC; 421 + } 420 422 error = bhv_vop_iflush(vp, flags); 421 423 if (error == EAGAIN) 422 424 error = sync? bhv_vop_iflush(vp, flags | FLUSH_LOG) : 0;
+12 -8
fs/xfs/xfs_vnodeops.c
··· 1082 1082 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) 1083 1083 return XFS_ERROR(EIO); 1084 1084 1085 + if (flag & FSYNC_DATA) 1086 + filemap_fdatawait(vn_to_inode(XFS_ITOV(ip))->i_mapping); 1087 + 1085 1088 /* 1086 1089 * We always need to make sure that the required inode state 1087 1090 * is safe on disk. The vnode might be clean but because ··· 3772 3769 sync_lsn = log->l_last_sync_lsn; 3773 3770 GRANT_UNLOCK(log, s); 3774 3771 3775 - if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) <= 0)) 3776 - return 0; 3772 + if ((XFS_LSN_CMP(iip->ili_last_lsn, sync_lsn) > 0)) { 3773 + if (flags & FLUSH_SYNC) 3774 + log_flags |= XFS_LOG_SYNC; 3775 + error = xfs_log_force(mp, iip->ili_last_lsn, log_flags); 3776 + if (error) 3777 + return error; 3778 + } 3777 3779 3778 - if (flags & FLUSH_SYNC) 3779 - log_flags |= XFS_LOG_SYNC; 3780 - return xfs_log_force(mp, iip->ili_last_lsn, log_flags); 3780 + if (ip->i_update_core == 0) 3781 + return 0; 3781 3782 } 3782 3783 } 3783 3784 ··· 3794 3787 */ 3795 3788 if (flags & FLUSH_INODE) { 3796 3789 int flush_flags; 3797 - 3798 - if (xfs_ipincount(ip)) 3799 - return EAGAIN; 3800 3790 3801 3791 if (flags & FLUSH_SYNC) { 3802 3792 xfs_ilock(ip, XFS_ILOCK_SHARED);