diff options
author | Dave Chinner <dchinner@redhat.com> | 2010-08-23 22:02:11 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-10-18 16:07:25 -0400 |
commit | 447223520520b17d3b6d0631aa4838fbaf8eddb4 (patch) | |
tree | 068716a0537e0f7007a037073c4b7bc608233c1e /fs/xfs/xfs_bmap.c | |
parent | 3ae4c9deb30a8d5ee305b461625dcb298c9804a9 (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_bmap.c')
-rw-r--r-- | fs/xfs/xfs_bmap.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index f90dadd5a968..5e33b7862d41 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
@@ -4744,8 +4744,12 @@ xfs_bmapi( | |||
4744 | * Check if writing previously allocated but | 4744 | * Check if writing previously allocated but |
4745 | * unwritten extents. | 4745 | * unwritten extents. |
4746 | */ | 4746 | */ |
4747 | if (wr && mval->br_state == XFS_EXT_UNWRITTEN && | 4747 | if (wr && |
4748 | ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_DELAY)) == 0)) { | 4748 | ((mval->br_state == XFS_EXT_UNWRITTEN && |
4749 | ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_DELAY)) == 0)) || | ||
4750 | (mval->br_state == XFS_EXT_NORM && | ||
4751 | ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_CONVERT)) == | ||
4752 | (XFS_BMAPI_PREALLOC|XFS_BMAPI_CONVERT))))) { | ||
4749 | /* | 4753 | /* |
4750 | * Modify (by adding) the state flag, if writing. | 4754 | * Modify (by adding) the state flag, if writing. |
4751 | */ | 4755 | */ |
@@ -4757,7 +4761,9 @@ xfs_bmapi( | |||
4757 | *firstblock; | 4761 | *firstblock; |
4758 | cur->bc_private.b.flist = flist; | 4762 | cur->bc_private.b.flist = flist; |
4759 | } | 4763 | } |
4760 | mval->br_state = XFS_EXT_NORM; | 4764 | mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN) |
4765 | ? XFS_EXT_NORM | ||
4766 | : XFS_EXT_UNWRITTEN; | ||
4761 | error = xfs_bmap_add_extent(ip, lastx, &cur, mval, | 4767 | error = xfs_bmap_add_extent(ip, lastx, &cur, mval, |
4762 | firstblock, flist, &tmp_logflags, | 4768 | firstblock, flist, &tmp_logflags, |
4763 | whichfork, (flags & XFS_BMAPI_RSVBLOCKS)); | 4769 | whichfork, (flags & XFS_BMAPI_RSVBLOCKS)); |