aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_vnodeops.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-08-23 22:02:11 -0400
committerAlex Elder <aelder@sgi.com>2010-10-18 16:07:25 -0400
commit447223520520b17d3b6d0631aa4838fbaf8eddb4 (patch)
tree068716a0537e0f7007a037073c4b7bc608233c1e /fs/xfs/xfs_vnodeops.c
parent3ae4c9deb30a8d5ee305b461625dcb298c9804a9 (diff)
xfs: Introduce XFS_IOC_ZERO_RANGE
XFS_IOC_ZERO_RANGE is the equivalent of an atomic XFS_IOC_UNRESVSP/ XFS_IOC_RESVSP call pair. It enabled ranges of written data to be turned into zeroes without requiring IO or having to free and reallocate the extents in the range given as would occur if we had to punch and then preallocate them separately. This enables applications to zero parts of files very quickly without changing the layout of the files in any way. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r--fs/xfs/xfs_vnodeops.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 4c7c7bfb2b2f..dc6e4fb8bbc9 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -2272,7 +2272,7 @@ xfs_alloc_file_space(
2272 count = len; 2272 count = len;
2273 imapp = &imaps[0]; 2273 imapp = &imaps[0];
2274 nimaps = 1; 2274 nimaps = 1;
2275 bmapi_flag = XFS_BMAPI_WRITE | (alloc_type ? XFS_BMAPI_PREALLOC : 0); 2275 bmapi_flag = XFS_BMAPI_WRITE | alloc_type;
2276 startoffset_fsb = XFS_B_TO_FSBT(mp, offset); 2276 startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
2277 allocatesize_fsb = XFS_B_TO_FSB(mp, count); 2277 allocatesize_fsb = XFS_B_TO_FSB(mp, count);
2278 2278
@@ -2711,6 +2711,7 @@ xfs_change_file_space(
2711 xfs_off_t llen; 2711 xfs_off_t llen;
2712 xfs_trans_t *tp; 2712 xfs_trans_t *tp;
2713 struct iattr iattr; 2713 struct iattr iattr;
2714 int prealloc_type;
2714 2715
2715 if (!S_ISREG(ip->i_d.di_mode)) 2716 if (!S_ISREG(ip->i_d.di_mode))
2716 return XFS_ERROR(EINVAL); 2717 return XFS_ERROR(EINVAL);
@@ -2753,12 +2754,17 @@ xfs_change_file_space(
2753 * size to be changed. 2754 * size to be changed.
2754 */ 2755 */
2755 setprealloc = clrprealloc = 0; 2756 setprealloc = clrprealloc = 0;
2757 prealloc_type = XFS_BMAPI_PREALLOC;
2756 2758
2757 switch (cmd) { 2759 switch (cmd) {
2760 case XFS_IOC_ZERO_RANGE:
2761 prealloc_type |= XFS_BMAPI_CONVERT;
2762 xfs_tosspages(ip, startoffset, startoffset + bf->l_len, 0);
2763 /* FALLTHRU */
2758 case XFS_IOC_RESVSP: 2764 case XFS_IOC_RESVSP:
2759 case XFS_IOC_RESVSP64: 2765 case XFS_IOC_RESVSP64:
2760 error = xfs_alloc_file_space(ip, startoffset, bf->l_len, 2766 error = xfs_alloc_file_space(ip, startoffset, bf->l_len,
2761 1, attr_flags); 2767 prealloc_type, attr_flags);
2762 if (error) 2768 if (error)
2763 return error; 2769 return error;
2764 setprealloc = 1; 2770 setprealloc = 1;