Skip to content

Commit a47bd1e

Browse files
author
Darrick J. Wong
committed
xfs: introduce bitmap type for AG blocks
Create a typechecked bitmap for extents within an AG. Online repair uses bitmaps to store various different types of numbers, so let's make it obvious when we're storing xfs_agblock_t (and later xfs_fsblock_t) versus anything else. In subsequent patches, we're going to use agblock bitmaps to enhance the rmapbt checker to look for discrepancies between the rmapbt records and AG metadata block usage. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 6772fcc commit a47bd1e

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

fs/xfs/scrub/bitmap.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,52 @@ int xbitmap_walk_bits(struct xbitmap *bitmap, xbitmap_walk_bits_fn fn,
3939

4040
bool xbitmap_empty(struct xbitmap *bitmap);
4141

42+
/* Bitmaps, but for type-checked for xfs_agblock_t */
43+
44+
struct xagb_bitmap {
45+
struct xbitmap agbitmap;
46+
};
47+
48+
static inline void xagb_bitmap_init(struct xagb_bitmap *bitmap)
49+
{
50+
xbitmap_init(&bitmap->agbitmap);
51+
}
52+
53+
static inline void xagb_bitmap_destroy(struct xagb_bitmap *bitmap)
54+
{
55+
xbitmap_destroy(&bitmap->agbitmap);
56+
}
57+
58+
static inline int xagb_bitmap_clear(struct xagb_bitmap *bitmap,
59+
xfs_agblock_t start, xfs_extlen_t len)
60+
{
61+
return xbitmap_clear(&bitmap->agbitmap, start, len);
62+
}
63+
static inline int xagb_bitmap_set(struct xagb_bitmap *bitmap,
64+
xfs_agblock_t start, xfs_extlen_t len)
65+
{
66+
return xbitmap_set(&bitmap->agbitmap, start, len);
67+
}
68+
69+
static inline int xagb_bitmap_disunion(struct xagb_bitmap *bitmap,
70+
struct xagb_bitmap *sub)
71+
{
72+
return xbitmap_disunion(&bitmap->agbitmap, &sub->agbitmap);
73+
}
74+
75+
static inline uint32_t xagb_bitmap_hweight(struct xagb_bitmap *bitmap)
76+
{
77+
return xbitmap_hweight(&bitmap->agbitmap);
78+
}
79+
static inline bool xagb_bitmap_empty(struct xagb_bitmap *bitmap)
80+
{
81+
return xbitmap_empty(&bitmap->agbitmap);
82+
}
83+
84+
static inline int xagb_bitmap_walk(struct xagb_bitmap *bitmap,
85+
xbitmap_walk_fn fn, void *priv)
86+
{
87+
return xbitmap_walk(&bitmap->agbitmap, fn, priv);
88+
}
89+
4290
#endif /* __XFS_SCRUB_BITMAP_H__ */

fs/xfs/scrub/repair.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
3131
const struct xfs_buf_ops *ops);
3232

3333
struct xbitmap;
34+
struct xagb_bitmap;
3435

3536
int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
3637
int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xbitmap *btlist);

0 commit comments

Comments
 (0)