aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2014-09-23 01:39:05 -0400
committerDave Chinner <david@fromorbit.com>2014-09-23 01:39:05 -0400
commit8b5279e33f241a074a9c8649bba8f77a2167b798 (patch)
treefaf3c22feb56241ec43f76bf339414c8afd13f4d /fs
parentf71721d061e872a39b2680d13f309c1eb6893438 (diff)
xfs: only writeback and truncate pages for the freed range
xfs_free_file_space() only affects the range of the file for which space is being freed. It currently writes and truncates the page cache from the start offset of the free to EOF. Modify xfs_free_file_space() to write back and truncate page cache of just the range being freed. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_bmap_util.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index eae763f4600e..809ae7d395c3 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -1205,6 +1205,7 @@ xfs_free_file_space(
1205 xfs_bmap_free_t free_list; 1205 xfs_bmap_free_t free_list;
1206 xfs_bmbt_irec_t imap; 1206 xfs_bmbt_irec_t imap;
1207 xfs_off_t ioffset; 1207 xfs_off_t ioffset;
1208 xfs_off_t iendoffset;
1208 xfs_extlen_t mod=0; 1209 xfs_extlen_t mod=0;
1209 xfs_mount_t *mp; 1210 xfs_mount_t *mp;
1210 int nimap; 1211 int nimap;
@@ -1233,12 +1234,13 @@ xfs_free_file_space(
1233 inode_dio_wait(VFS_I(ip)); 1234 inode_dio_wait(VFS_I(ip));
1234 1235
1235 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE); 1236 rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
1236 ioffset = offset & ~(rounding - 1); 1237 ioffset = round_down(offset, rounding);
1237 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, 1238 iendoffset = round_up(offset + len, rounding) - 1;
1238 ioffset, -1); 1239 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, ioffset,
1240 iendoffset);
1239 if (error) 1241 if (error)
1240 goto out; 1242 goto out;
1241 truncate_pagecache_range(VFS_I(ip), ioffset, -1); 1243 truncate_pagecache_range(VFS_I(ip), ioffset, iendoffset);
1242 1244
1243 /* 1245 /*
1244 * Need to zero the stuff we're not freeing, on disk. 1246 * Need to zero the stuff we're not freeing, on disk.