Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b5279e3 authored by Brian Foster's avatar Brian Foster Committed by Dave Chinner
Browse files

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: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent f71721d0
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -1205,6 +1205,7 @@ xfs_free_file_space(
	xfs_bmap_free_t		free_list;
	xfs_bmap_free_t		free_list;
	xfs_bmbt_irec_t		imap;
	xfs_bmbt_irec_t		imap;
	xfs_off_t		ioffset;
	xfs_off_t		ioffset;
	xfs_off_t		iendoffset;
	xfs_extlen_t		mod=0;
	xfs_extlen_t		mod=0;
	xfs_mount_t		*mp;
	xfs_mount_t		*mp;
	int			nimap;
	int			nimap;
@@ -1233,12 +1234,13 @@ xfs_free_file_space(
	inode_dio_wait(VFS_I(ip));
	inode_dio_wait(VFS_I(ip));


	rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
	rounding = max_t(xfs_off_t, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
	ioffset = offset & ~(rounding - 1);
	ioffset = round_down(offset, rounding);
	error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
	iendoffset = round_up(offset + len, rounding) - 1;
					      ioffset, -1);
	error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, ioffset,
					     iendoffset);
	if (error)
	if (error)
		goto out;
		goto out;
	truncate_pagecache_range(VFS_I(ip), ioffset, -1);
	truncate_pagecache_range(VFS_I(ip), ioffset, iendoffset);


	/*
	/*
	 * Need to zero the stuff we're not freeing, on disk.
	 * Need to zero the stuff we're not freeing, on disk.