]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: create agfl block free helper function
authorBrian Foster <bfoster@redhat.com>
Thu, 28 Jun 2018 20:11:55 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:55 +0000 (15:11 -0500)
Source kernel commit: 4223f659dd3edd9e561d90488c6ae332a0a05148

Refactor the AGFL block free code into a new helper such that it can
be invoked from deferred context. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h

index bbb9f11e3b5eb2b5a1d68ffcec197f9f0bfd45ce..79f94fbdbf9d392ff469b4955cdf518f05092e4f 100644 (file)
@@ -2056,6 +2056,30 @@ xfs_alloc_space_available(
        return true;
 }
 
+int
+xfs_free_agfl_block(
+       struct xfs_trans        *tp,
+       xfs_agnumber_t          agno,
+       xfs_agblock_t           agbno,
+       struct xfs_buf          *agbp,
+       struct xfs_owner_info   *oinfo)
+{
+       int                     error;
+       struct xfs_buf          *bp;
+
+       error = xfs_free_ag_extent(tp, agbp, agno, agbno, 1, oinfo,
+                                  XFS_AG_RESV_AGFL);
+       if (error)
+               return error;
+
+       bp = xfs_btree_get_bufs(tp->t_mountp, tp, agno, agbno, 0);
+       if (!bp)
+               return -EFSCORRUPTED;
+       xfs_trans_binval(tp, bp);
+
+       return 0;
+}
+
 /*
  * Check the agfl fields of the agf for inconsistency or corruption. The purpose
  * is to detect an agfl header padding mismatch between current and early v5
@@ -2243,21 +2267,14 @@ xfs_alloc_fix_freelist(
        else
                xfs_rmap_ag_owner(&targs.oinfo, XFS_RMAP_OWN_AG);
        while (!(flags & XFS_ALLOC_FLAG_NOSHRINK) && pag->pagf_flcount > need) {
-               struct xfs_buf  *bp;
-
                error = xfs_alloc_get_freelist(tp, agbp, &bno, 0);
                if (error)
                        goto out_agbp_relse;
-               error = xfs_free_ag_extent(tp, agbp, args->agno, bno, 1,
-                                          &targs.oinfo, XFS_AG_RESV_AGFL);
+
+               error = xfs_free_agfl_block(tp, args->agno, bno, agbp,
+                                           &targs.oinfo);
                if (error)
                        goto out_agbp_relse;
-               bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0);
-               if (!bp) {
-                       error = -EFSCORRUPTED;
-                       goto out_agbp_relse;
-               }
-               xfs_trans_binval(tp, bp);
        }
 
        targs.tp = tp;
index cbf789ea5a4e35749d55061ead620cf4a0c25738..949e21326066ffa67427fee9409e3379791f044e 100644 (file)
@@ -223,6 +223,8 @@ int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
                        xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
 int xfs_alloc_read_agfl(struct xfs_mount *mp, struct xfs_trans *tp,
                        xfs_agnumber_t agno, struct xfs_buf **bpp);
+int xfs_free_agfl_block(struct xfs_trans *, xfs_agnumber_t, xfs_agblock_t,
+                       struct xfs_buf *, struct xfs_owner_info *);
 int xfs_alloc_fix_freelist(struct xfs_alloc_arg *args, int flags);
 int xfs_free_extent_fix_freelist(struct xfs_trans *tp, xfs_agnumber_t agno,
                struct xfs_buf **agbp);