]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: don't ifdef around the exact minlen allocations
authorChristoph Hellwig <hch@lst.de>
Mon, 21 Oct 2024 00:10:47 +0000 (17:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:04 +0000 (15:45 -0700)
Source kernel commit: b611fddc0435738e64453bbf1dadd4b12a801858

Exact minlen allocations only exist as an error injection tool for debug
builds.  Currently this is implemented using ifdefs, which means the code
isn't even compiled for non-XFS_DEBUG builds.  Enhance the compile test
coverage by always building the code and use the compilers' dead code
elimination to remove it from the generated binary instead.

The only downside is that the alloc_minlen_only field is unconditionally
added to struct xfs_alloc_args now, but by moving it around and packing
it tightly this doesn't actually increase the size of the structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_alloc.c
libxfs/xfs_alloc.h
libxfs/xfs_bmap.c

index 3806a6bc0835a7f156fe73bc232df74cbd1515e7..61453709ae515cf54075df85f081cdb296181671 100644 (file)
@@ -2762,7 +2762,6 @@ xfs_alloc_commit_autoreap(
                xfs_defer_item_unpause(tp, aarp->dfp);
 }
 
-#ifdef DEBUG
 /*
  * Check if an AGF has a free extent record whose length is equal to
  * args->minlen.
@@ -2802,7 +2801,6 @@ out:
 
        return error;
 }
-#endif
 
 /*
  * Decide whether to use this allocation group for this allocation.
@@ -2876,15 +2874,14 @@ xfs_alloc_fix_freelist(
        if (!xfs_alloc_space_available(args, need, alloc_flags))
                goto out_agbp_relse;
 
-#ifdef DEBUG
-       if (args->alloc_minlen_only) {
+       if (IS_ENABLED(CONFIG_XFS_DEBUG) && args->alloc_minlen_only) {
                int stat;
 
                error = xfs_exact_minlen_extent_available(args, agbp, &stat);
                if (error || !stat)
                        goto out_agbp_relse;
        }
-#endif
+
        /*
         * Make the freelist shorter if it's too long.
         *
index fae170825be06463b93d616fc9178f11cf533776..0165452e7cd05593e60450fdcc59dd0cb9287422 100644 (file)
@@ -53,11 +53,9 @@ typedef struct xfs_alloc_arg {
        int             datatype;       /* mask defining data type treatment */
        char            wasdel;         /* set if allocation was prev delayed */
        char            wasfromfl;      /* set if allocation is from freelist */
+       bool            alloc_minlen_only; /* allocate exact minlen extent */
        struct xfs_owner_info   oinfo;  /* owner of blocks being allocated */
        enum xfs_ag_resv_type   resv;   /* block reservation to use */
-#ifdef DEBUG
-       bool            alloc_minlen_only; /* allocate exact minlen extent */
-#endif
 } xfs_alloc_arg_t;
 
 /*
index af493836ecc7eac873d2d2e8f542bfb8f86ecf84..3c4922424f3fd06b47d2d7a3fb82c10130d87ccb 100644 (file)
@@ -3471,7 +3471,6 @@ xfs_bmap_process_allocated_extent(
        xfs_bmap_alloc_account(ap);
 }
 
-#ifdef DEBUG
 static int
 xfs_bmap_exact_minlen_extent_alloc(
        struct xfs_bmalloca     *ap)
@@ -3533,11 +3532,6 @@ xfs_bmap_exact_minlen_extent_alloc(
 
        return 0;
 }
-#else
-
-#define xfs_bmap_exact_minlen_extent_alloc(bma) (-EFSCORRUPTED)
-
-#endif
 
 /*
  * If we are not low on available data blocks and we are allocating at