aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_vnodeops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r--fs/xfs/xfs_vnodeops.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index f2fea868d4db..96ff03421753 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -226,7 +226,14 @@ xfs_free_eofblocks(
226 xfs_ilock(ip, XFS_ILOCK_EXCL); 226 xfs_ilock(ip, XFS_ILOCK_EXCL);
227 xfs_trans_ijoin(tp, ip, 0); 227 xfs_trans_ijoin(tp, ip, 0);
228 228
229 error = xfs_itruncate_data(&tp, ip, ip->i_size); 229 /*
230 * Do not update the on-disk file size. If we update the
231 * on-disk file size and then the system crashes before the
232 * contents of the file are flushed to disk then the files
233 * may be full of holes (ie NULL files bug).
234 */
235 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK,
236 ip->i_size);
230 if (error) { 237 if (error) {
231 /* 238 /*
232 * If we get an error at this point we simply don't 239 * If we get an error at this point we simply don't
@@ -670,13 +677,19 @@ xfs_inactive(
670 xfs_ilock(ip, XFS_ILOCK_EXCL); 677 xfs_ilock(ip, XFS_ILOCK_EXCL);
671 xfs_trans_ijoin(tp, ip, 0); 678 xfs_trans_ijoin(tp, ip, 0);
672 679
673 error = xfs_itruncate_data(&tp, ip, 0); 680 ip->i_d.di_size = 0;
681 ip->i_size = 0;
682 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
683
684 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0);
674 if (error) { 685 if (error) {
675 xfs_trans_cancel(tp, 686 xfs_trans_cancel(tp,
676 XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); 687 XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
677 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL); 688 xfs_iunlock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
678 return VN_INACTIVE_CACHE; 689 return VN_INACTIVE_CACHE;
679 } 690 }
691
692 ASSERT(ip->i_d.di_nextents == 0);
680 } else if (S_ISLNK(ip->i_d.di_mode)) { 693 } else if (S_ISLNK(ip->i_d.di_mode)) {
681 694
682 /* 695 /*