Skip to content

Commit b611fdd

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: don't ifdef around the exact minlen allocations
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 <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent 865469c commit b611fdd

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,6 @@ xfs_alloc_commit_autoreap(
27662766
xfs_defer_item_unpause(tp, aarp->dfp);
27672767
}
27682768

2769-
#ifdef DEBUG
27702769
/*
27712770
* Check if an AGF has a free extent record whose length is equal to
27722771
* args->minlen.
@@ -2806,7 +2805,6 @@ xfs_exact_minlen_extent_available(
28062805

28072806
return error;
28082807
}
2809-
#endif
28102808

28112809
/*
28122810
* Decide whether to use this allocation group for this allocation.
@@ -2880,15 +2878,14 @@ xfs_alloc_fix_freelist(
28802878
if (!xfs_alloc_space_available(args, need, alloc_flags))
28812879
goto out_agbp_relse;
28822880

2883-
#ifdef DEBUG
2884-
if (args->alloc_minlen_only) {
2881+
if (IS_ENABLED(CONFIG_XFS_DEBUG) && args->alloc_minlen_only) {
28852882
int stat;
28862883

28872884
error = xfs_exact_minlen_extent_available(args, agbp, &stat);
28882885
if (error || !stat)
28892886
goto out_agbp_relse;
28902887
}
2891-
#endif
2888+
28922889
/*
28932890
* Make the freelist shorter if it's too long.
28942891
*

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ typedef struct xfs_alloc_arg {
5353
int datatype; /* mask defining data type treatment */
5454
char wasdel; /* set if allocation was prev delayed */
5555
char wasfromfl; /* set if allocation is from freelist */
56+
bool alloc_minlen_only; /* allocate exact minlen extent */
5657
struct xfs_owner_info oinfo; /* owner of blocks being allocated */
5758
enum xfs_ag_resv_type resv; /* block reservation to use */
58-
#ifdef DEBUG
59-
bool alloc_minlen_only; /* allocate exact minlen extent */
60-
#endif
6159
} xfs_alloc_arg_t;
6260

6361
/*

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,6 @@ xfs_bmap_process_allocated_extent(
34773477
xfs_bmap_alloc_account(ap);
34783478
}
34793479

3480-
#ifdef DEBUG
34813480
static int
34823481
xfs_bmap_exact_minlen_extent_alloc(
34833482
struct xfs_bmalloca *ap)
@@ -3539,11 +3538,6 @@ xfs_bmap_exact_minlen_extent_alloc(
35393538

35403539
return 0;
35413540
}
3542-
#else
3543-
3544-
#define xfs_bmap_exact_minlen_extent_alloc(bma) (-EFSCORRUPTED)
3545-
3546-
#endif
35473541

35483542
/*
35493543
* If we are not low on available data blocks and we are allocating at

0 commit comments

Comments
 (0)