xfs: move small allocation helper
authorBrian Foster <bfoster@redhat.com>
Sat, 29 Jun 2019 02:30:19 +0000 (19:30 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sat, 29 Jun 2019 02:30:19 +0000 (19:30 -0700)
Move the small allocation helper further up in the file to avoid the
need for a function declaration. The remaining declarations will be
removed by followup patches. No functional changes.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_alloc.c

index 795e39b..15850ca 100644 (file)
@@ -41,8 +41,6 @@ struct workqueue_struct *xfs_alloc_wq;
 STATIC int xfs_alloc_ag_vextent_exact(xfs_alloc_arg_t *);
 STATIC int xfs_alloc_ag_vextent_near(xfs_alloc_arg_t *);
 STATIC int xfs_alloc_ag_vextent_size(xfs_alloc_arg_t *);
-STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,
-               xfs_btree_cur_t *, xfs_agblock_t *, xfs_extlen_t *, int *);
 
 /*
  * Size of the AGFL.  For CRC-enabled filesystes we steal a couple of slots in
@@ -700,6 +698,100 @@ xfs_alloc_update_counters(
  */
 
 /*
+ * Deal with the case where only small freespaces remain. Either return the
+ * contents of the last freespace record, or allocate space from the freelist if
+ * there is nothing in the tree.
+ */
+STATIC int                     /* error */
+xfs_alloc_ag_vextent_small(
+       struct xfs_alloc_arg    *args,  /* allocation argument structure */
+       struct xfs_btree_cur    *ccur,  /* optional by-size cursor */
+       xfs_agblock_t           *fbnop, /* result block number */
+       xfs_extlen_t            *flenp, /* result length */
+       int                     *stat)  /* status: 0-freelist, 1-normal/none */
+{
+       int                     error = 0;
+       xfs_agblock_t           fbno = NULLAGBLOCK;
+       xfs_extlen_t            flen = 0;
+       int                     i;
+
+       error = xfs_btree_decrement(ccur, 0, &i);
+       if (error)
+               goto error;
+       if (i) {
+               error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i);
+               if (error)
+                       goto error;
+               XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error);
+               goto out;
+       }
+
+       if (args->minlen != 1 || args->alignment != 1 ||
+           args->resv == XFS_AG_RESV_AGFL ||
+           (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) <=
+            args->minleft))
+               goto out;
+
+       error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0);
+       if (error)
+               goto error;
+       if (fbno == NULLAGBLOCK)
+               goto out;
+
+       xfs_extent_busy_reuse(args->mp, args->agno, fbno, 1,
+                             xfs_alloc_allow_busy_reuse(args->datatype));
+
+       if (xfs_alloc_is_userdata(args->datatype)) {
+               struct xfs_buf  *bp;
+
+               bp = xfs_btree_get_bufs(args->mp, args->tp, args->agno, fbno);
+               if (!bp) {
+                       error = -EFSCORRUPTED;
+                       goto error;
+               }
+               xfs_trans_binval(args->tp, bp);
+       }
+       args->len = 1;
+       args->agbno = fbno;
+       XFS_WANT_CORRUPTED_GOTO(args->mp,
+               fbno < be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
+               error);
+       args->wasfromfl = 1;
+       trace_xfs_alloc_small_freelist(args);
+
+       /*
+        * If we're feeding an AGFL block to something that doesn't live in the
+        * free space, we need to clear out the OWN_AG rmap.
+        */
+       error = xfs_rmap_free(args->tp, args->agbp, args->agno, fbno, 1,
+                             &XFS_RMAP_OINFO_AG);
+       if (error)
+               goto error;
+
+       *stat = 0;
+       return 0;
+
+out:
+       /*
+        * Can't do the allocation, give up.
+        */
+       if (flen < args->minlen) {
+               args->agbno = NULLAGBLOCK;
+               trace_xfs_alloc_small_notenough(args);
+               flen = 0;
+       }
+       *fbnop = fbno;
+       *flenp = flen;
+       *stat = 1;
+       trace_xfs_alloc_small_done(args);
+       return 0;
+
+error:
+       trace_xfs_alloc_small_error(args);
+       return error;
+}
+
+/*
  * Allocate a variable extent in the allocation group agno.
  * Type and bno are used to determine where in the allocation group the
  * extent will start.
@@ -1583,100 +1675,6 @@ out_nominleft:
 }
 
 /*
- * Deal with the case where only small freespaces remain. Either return the
- * contents of the last freespace record, or allocate space from the freelist if
- * there is nothing in the tree.
- */
-STATIC int                     /* error */
-xfs_alloc_ag_vextent_small(
-       struct xfs_alloc_arg    *args,  /* allocation argument structure */
-       struct xfs_btree_cur    *ccur,  /* optional by-size cursor */
-       xfs_agblock_t           *fbnop, /* result block number */
-       xfs_extlen_t            *flenp, /* result length */
-       int                     *stat)  /* status: 0-freelist, 1-normal/none */
-{
-       int                     error = 0;
-       xfs_agblock_t           fbno = NULLAGBLOCK;
-       xfs_extlen_t            flen = 0;
-       int                     i;
-
-       error = xfs_btree_decrement(ccur, 0, &i);
-       if (error)
-               goto error;
-       if (i) {
-               error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i);
-               if (error)
-                       goto error;
-               XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error);
-               goto out;
-       }
-
-       if (args->minlen != 1 || args->alignment != 1 ||
-           args->resv == XFS_AG_RESV_AGFL ||
-           (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) <=
-            args->minleft))
-               goto out;
-
-       error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0);
-       if (error)
-               goto error;
-       if (fbno == NULLAGBLOCK)
-               goto out;
-
-       xfs_extent_busy_reuse(args->mp, args->agno, fbno, 1,
-                             xfs_alloc_allow_busy_reuse(args->datatype));
-
-       if (xfs_alloc_is_userdata(args->datatype)) {
-               struct xfs_buf  *bp;
-
-               bp = xfs_btree_get_bufs(args->mp, args->tp, args->agno, fbno);
-               if (!bp) {
-                       error = -EFSCORRUPTED;
-                       goto error;
-               }
-               xfs_trans_binval(args->tp, bp);
-       }
-       args->len = 1;
-       args->agbno = fbno;
-       XFS_WANT_CORRUPTED_GOTO(args->mp,
-               fbno < be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
-               error);
-       args->wasfromfl = 1;
-       trace_xfs_alloc_small_freelist(args);
-
-       /*
-        * If we're feeding an AGFL block to something that doesn't live in the
-        * free space, we need to clear out the OWN_AG rmap.
-        */
-       error = xfs_rmap_free(args->tp, args->agbp, args->agno, fbno, 1,
-                             &XFS_RMAP_OINFO_AG);
-       if (error)
-               goto error;
-
-       *stat = 0;
-       return 0;
-
-out:
-       /*
-        * Can't do the allocation, give up.
-        */
-       if (flen < args->minlen) {
-               args->agbno = NULLAGBLOCK;
-               trace_xfs_alloc_small_notenough(args);
-               flen = 0;
-       }
-       *fbnop = fbno;
-       *flenp = flen;
-       *stat = 1;
-       trace_xfs_alloc_small_done(args);
-       return 0;
-
-error:
-       trace_xfs_alloc_small_error(args);
-       return error;
-}
-
-/*
  * Free the extent starting at agno/bno for length.
  */
 STATIC int