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

Commit 44722352 authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder
Browse files

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: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 3ae4c9de
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1301,7 +1301,8 @@ xfs_file_ioctl(
	case XFS_IOC_ALLOCSP64:
	case XFS_IOC_FREESP64:
	case XFS_IOC_RESVSP64:
	case XFS_IOC_UNRESVSP64: {
	case XFS_IOC_UNRESVSP64:
	case XFS_IOC_ZERO_RANGE: {
		xfs_flock64_t		bf;

		if (copy_from_user(&bf, arg, sizeof(bf)))
+1 −0
Original line number Diff line number Diff line
@@ -574,6 +574,7 @@ xfs_file_compat_ioctl(
	case XFS_IOC_FSGEOMETRY_V1:
	case XFS_IOC_FSGROWFSDATA:
	case XFS_IOC_FSGROWFSRT:
	case XFS_IOC_ZERO_RANGE:
		return xfs_file_ioctl(filp, cmd, p);
#else
	case XFS_IOC_ALLOCSP_32:
+9 −3
Original line number Diff line number Diff line
@@ -4744,8 +4744,12 @@ xfs_bmapi(
		 * Check if writing previously allocated but
		 * unwritten extents.
		 */
		if (wr && mval->br_state == XFS_EXT_UNWRITTEN &&
		    ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_DELAY)) == 0)) {
		if (wr &&
		    ((mval->br_state == XFS_EXT_UNWRITTEN &&
		      ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_DELAY)) == 0)) ||
		     (mval->br_state == XFS_EXT_NORM &&
		      ((flags & (XFS_BMAPI_PREALLOC|XFS_BMAPI_CONVERT)) ==
				(XFS_BMAPI_PREALLOC|XFS_BMAPI_CONVERT))))) {
			/*
			 * Modify (by adding) the state flag, if writing.
			 */
@@ -4757,7 +4761,9 @@ xfs_bmapi(
					*firstblock;
				cur->bc_private.b.flist = flist;
			}
			mval->br_state = XFS_EXT_NORM;
			mval->br_state = (mval->br_state == XFS_EXT_UNWRITTEN)
						? XFS_EXT_NORM
						: XFS_EXT_UNWRITTEN;
			error = xfs_bmap_add_extent(ip, lastx, &cur, mval,
				firstblock, flist, &tmp_logflags,
				whichfork, (flags & XFS_BMAPI_RSVBLOCKS));
+6 −3
Original line number Diff line number Diff line
@@ -74,9 +74,12 @@ typedef struct xfs_bmap_free
#define	XFS_BMAPI_IGSTATE	0x080	/* Ignore state - */
					/* combine contig. space */
#define	XFS_BMAPI_CONTIG	0x100	/* must allocate only one extent */
#define XFS_BMAPI_CONVERT	0x200	/* unwritten extent conversion - */
					/* need write cache flushing and no */
					/* additional allocation alignments */
/*
 * unwritten extent conversion - this needs write cache flushing and no additional
 * allocation alignments. When specified with XFS_BMAPI_PREALLOC it converts
 * from written to unwritten, otherwise convert from unwritten to written.
 */
#define XFS_BMAPI_CONVERT	0x200

#define XFS_BMAPI_FLAGS \
	{ XFS_BMAPI_WRITE,	"WRITE" }, \
+1 −0
Original line number Diff line number Diff line
@@ -448,6 +448,7 @@ typedef struct xfs_handle {
/*	XFS_IOC_SETBIOSIZE ---- deprecated 46	   */
/*	XFS_IOC_GETBIOSIZE ---- deprecated 47	   */
#define XFS_IOC_GETBMAPX	_IOWR('X', 56, struct getbmap)
#define XFS_IOC_ZERO_RANGE	_IOW ('X', 57, struct xfs_flock64)

/*
 * ioctl commands that replace IRIX syssgi()'s
Loading