]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: support bmapping delalloc extents in the CoW fork
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 25 Oct 2016 01:37:50 +0000 (12:37 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 25 Oct 2016 01:37:50 +0000 (12:37 +1100)
Source kernel commit: be51f8119c2f5e27437d2c4271f6419f3b8e609f

Allow the creation of delayed allocation extents in the CoW fork.  In
a subsequent patch we'll wire up iomap_begin to actually do this via
reflink helper functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_bmap.c
libxfs/xfs_bmap.h

index 49fc949ea73c3b1b3adee0d3d0e838ef8046bbdc..b936d1eaa094d07d08129fd7a4813d5c76c24fa7 100644 (file)
@@ -2752,6 +2752,7 @@ done:
 STATIC void
 xfs_bmap_add_extent_hole_delay(
        xfs_inode_t             *ip,    /* incore inode pointer */
+       int                     whichfork,
        xfs_extnum_t            *idx,   /* extent number to update/insert */
        xfs_bmbt_irec_t         *new)   /* new data to add to file extents */
 {
@@ -2763,8 +2764,10 @@ xfs_bmap_add_extent_hole_delay(
        int                     state;  /* state bits, accessed thru macros */
        xfs_filblks_t           temp=0; /* temp for indirect calculations */
 
-       ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+       ifp = XFS_IFORK_PTR(ip, whichfork);
        state = 0;
+       if (whichfork == XFS_COW_FORK)
+               state |= BMAP_COWFORK;
        ASSERT(isnullstartblock(new->br_startblock));
 
        /*
@@ -2782,7 +2785,7 @@ xfs_bmap_add_extent_hole_delay(
         * Check and set flags if the current (right) segment exists.
         * If it doesn't exist, we're converting the hole at end-of-file.
         */
-       if (*idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
+       if (*idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
                state |= BMAP_RIGHT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, *idx), &right);
 
@@ -4146,6 +4149,7 @@ xfs_bmapi_read(
 int
 xfs_bmapi_reserve_delalloc(
        struct xfs_inode        *ip,
+       int                     whichfork,
        xfs_fileoff_t           aoff,
        xfs_filblks_t           len,
        struct xfs_bmbt_irec    *got,
@@ -4154,7 +4158,7 @@ xfs_bmapi_reserve_delalloc(
        int                     eof)
 {
        struct xfs_mount        *mp = ip->i_mount;
-       struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+       struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, whichfork);
        xfs_extlen_t            alen;
        xfs_extlen_t            indlen;
        char                    rt = XFS_IS_REALTIME_INODE(ip);
@@ -4213,7 +4217,7 @@ xfs_bmapi_reserve_delalloc(
        got->br_startblock = nullstartblock(indlen);
        got->br_blockcount = alen;
        got->br_state = XFS_EXT_NORM;
-       xfs_bmap_add_extent_hole_delay(ip, lastx, got);
+       xfs_bmap_add_extent_hole_delay(ip, whichfork, lastx, got);
 
        /*
         * Update our extent pointer, given that xfs_bmap_add_extent_hole_delay
index 4924d520681db38dc3d8f07e031ec76bd9b6165c..d4fa06148fe311f9573ce9f2d918f208388b2c1c 100644 (file)
@@ -234,9 +234,10 @@ struct xfs_bmbt_rec_host *
        xfs_bmap_search_extents(struct xfs_inode *ip, xfs_fileoff_t bno,
                int fork, int *eofp, xfs_extnum_t *lastxp,
                struct xfs_bmbt_irec *gotp, struct xfs_bmbt_irec *prevp);
-int    xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, xfs_fileoff_t aoff,
-               xfs_filblks_t len, struct xfs_bmbt_irec *got,
-               struct xfs_bmbt_irec *prev, xfs_extnum_t *lastx, int eof);
+int    xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
+               xfs_fileoff_t aoff, xfs_filblks_t len,
+               struct xfs_bmbt_irec *got, struct xfs_bmbt_irec *prev,
+               xfs_extnum_t *lastx, int eof);
 
 struct xfs_bmbt_rec_host *
        xfs_bmap_search_extents(struct xfs_inode *ip, xfs_fileoff_t bno,