Skip to content

Commit

Permalink
xfs: reap large AG metadata extents when possible
Browse files Browse the repository at this point in the history
When we're freeing extents that have been set in a bitmap, break the
bitmap extent into multiple sub-extents organized by fate, and reap the
extents.  This enables us to dispose of old resources more efficiently
than doing them block by block.

While we're at it, rename the reaping functions to make it clear that
they're reaping per-AG extents.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Darrick J. Wong committed Aug 10, 2023
1 parent 9ed851f commit 1c7ce11
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 121 deletions.
2 changes: 1 addition & 1 deletion fs/xfs/scrub/agheader_repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ xrep_agfl(
goto err;

/* Dump any AGFL overflow. */
error = xrep_reap_extents(sc, &agfl_extents, &XFS_RMAP_OINFO_AG,
error = xrep_reap_ag_metadata(sc, &agfl_extents, &XFS_RMAP_OINFO_AG,
XFS_AG_RESV_AGFL);
err:
xbitmap_destroy(&agfl_extents);
Expand Down
37 changes: 0 additions & 37 deletions fs/xfs/scrub/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,43 +385,6 @@ xbitmap_walk(
return error;
}

struct xbitmap_walk_bits {
xbitmap_walk_bits_fn fn;
void *priv;
};

/* Walk all the bits in a run. */
static int
xbitmap_walk_bits_in_run(
uint64_t start,
uint64_t len,
void *priv)
{
struct xbitmap_walk_bits *wb = priv;
uint64_t i;
int error = 0;

for (i = start; i < start + len; i++) {
error = wb->fn(i, wb->priv);
if (error)
break;
}

return error;
}

/* Call a function for every set bit in this bitmap. */
int
xbitmap_walk_bits(
struct xbitmap *bitmap,
xbitmap_walk_bits_fn fn,
void *priv)
{
struct xbitmap_walk_bits wb = {.fn = fn, .priv = priv};

return xbitmap_walk(bitmap, xbitmap_walk_bits_in_run, &wb);
}

/* Does this bitmap have no bits set at all? */
bool
xbitmap_empty(
Expand Down
4 changes: 0 additions & 4 deletions fs/xfs/scrub/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ typedef int (*xbitmap_walk_fn)(uint64_t start, uint64_t len, void *priv);
int xbitmap_walk(struct xbitmap *bitmap, xbitmap_walk_fn fn,
void *priv);

typedef int (*xbitmap_walk_bits_fn)(uint64_t bit, void *priv);
int xbitmap_walk_bits(struct xbitmap *bitmap, xbitmap_walk_bits_fn fn,
void *priv);

bool xbitmap_empty(struct xbitmap *bitmap);
bool xbitmap_test(struct xbitmap *bitmap, uint64_t start, uint64_t *len);

Expand Down
Loading

0 comments on commit 1c7ce11

Please sign in to comment.