xfs: const-ify xfs_owner_info arguments
Only certain functions actually change the contents of an xfs_owner_info; the rest can accept a const struct pointer. This will enable us to save stack space by hoisting static owner info types to be const global variables. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
@@ -583,31 +583,32 @@ xchk_btree_block_keys(
|
||||
*/
|
||||
int
|
||||
xchk_btree(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_btree_cur *cur,
|
||||
xchk_btree_rec_fn scrub_fn,
|
||||
struct xfs_owner_info *oinfo,
|
||||
void *private)
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_btree_cur *cur,
|
||||
xchk_btree_rec_fn scrub_fn,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
void *private)
|
||||
{
|
||||
struct xchk_btree bs = { NULL };
|
||||
union xfs_btree_ptr ptr;
|
||||
union xfs_btree_ptr *pp;
|
||||
union xfs_btree_rec *recp;
|
||||
struct xfs_btree_block *block;
|
||||
int level;
|
||||
struct xfs_buf *bp;
|
||||
struct check_owner *co;
|
||||
struct check_owner *n;
|
||||
int i;
|
||||
int error = 0;
|
||||
struct xchk_btree bs = {
|
||||
.cur = cur,
|
||||
.scrub_rec = scrub_fn,
|
||||
.oinfo = oinfo,
|
||||
.firstrec = true,
|
||||
.private = private,
|
||||
.sc = sc,
|
||||
};
|
||||
union xfs_btree_ptr ptr;
|
||||
union xfs_btree_ptr *pp;
|
||||
union xfs_btree_rec *recp;
|
||||
struct xfs_btree_block *block;
|
||||
int level;
|
||||
struct xfs_buf *bp;
|
||||
struct check_owner *co;
|
||||
struct check_owner *n;
|
||||
int i;
|
||||
int error = 0;
|
||||
|
||||
/* Initialize scrub state */
|
||||
bs.cur = cur;
|
||||
bs.scrub_rec = scrub_fn;
|
||||
bs.oinfo = oinfo;
|
||||
bs.firstrec = true;
|
||||
bs.private = private;
|
||||
bs.sc = sc;
|
||||
for (i = 0; i < XFS_BTREE_MAXLEVELS; i++)
|
||||
bs.firstkey[i] = true;
|
||||
INIT_LIST_HEAD(&bs.to_check);
|
||||
|
@@ -31,21 +31,21 @@ typedef int (*xchk_btree_rec_fn)(
|
||||
|
||||
struct xchk_btree {
|
||||
/* caller-provided scrub state */
|
||||
struct xfs_scrub *sc;
|
||||
struct xfs_btree_cur *cur;
|
||||
xchk_btree_rec_fn scrub_rec;
|
||||
struct xfs_owner_info *oinfo;
|
||||
void *private;
|
||||
struct xfs_scrub *sc;
|
||||
struct xfs_btree_cur *cur;
|
||||
xchk_btree_rec_fn scrub_rec;
|
||||
const struct xfs_owner_info *oinfo;
|
||||
void *private;
|
||||
|
||||
/* internal scrub state */
|
||||
union xfs_btree_rec lastrec;
|
||||
bool firstrec;
|
||||
union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS];
|
||||
bool firstkey[XFS_BTREE_MAXLEVELS];
|
||||
struct list_head to_check;
|
||||
union xfs_btree_rec lastrec;
|
||||
bool firstrec;
|
||||
union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS];
|
||||
bool firstkey[XFS_BTREE_MAXLEVELS];
|
||||
struct list_head to_check;
|
||||
};
|
||||
int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
||||
xchk_btree_rec_fn scrub_fn, struct xfs_owner_info *oinfo,
|
||||
xchk_btree_rec_fn scrub_fn, const struct xfs_owner_info *oinfo,
|
||||
void *private);
|
||||
|
||||
#endif /* __XFS_SCRUB_BTREE_H__ */
|
||||
|
@@ -313,8 +313,8 @@ xchk_set_incomplete(
|
||||
*/
|
||||
|
||||
struct xchk_rmap_ownedby_info {
|
||||
struct xfs_owner_info *oinfo;
|
||||
xfs_filblks_t *blocks;
|
||||
const struct xfs_owner_info *oinfo;
|
||||
xfs_filblks_t *blocks;
|
||||
};
|
||||
|
||||
STATIC int
|
||||
@@ -347,15 +347,15 @@ int
|
||||
xchk_count_rmap_ownedby_ag(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_btree_cur *cur,
|
||||
struct xfs_owner_info *oinfo,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
xfs_filblks_t *blocks)
|
||||
{
|
||||
struct xchk_rmap_ownedby_info sroi;
|
||||
struct xchk_rmap_ownedby_info sroi = {
|
||||
.oinfo = oinfo,
|
||||
.blocks = blocks,
|
||||
};
|
||||
|
||||
sroi.oinfo = oinfo;
|
||||
*blocks = 0;
|
||||
sroi.blocks = blocks;
|
||||
|
||||
return xfs_rmap_query_all(cur, xchk_count_rmap_ownedby_irec,
|
||||
&sroi);
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ int xchk_ag_read_headers(struct xfs_scrub *sc, xfs_agnumber_t agno,
|
||||
void xchk_ag_btcur_free(struct xchk_ag *sa);
|
||||
int xchk_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa);
|
||||
int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
||||
struct xfs_owner_info *oinfo, xfs_filblks_t *blocks);
|
||||
const struct xfs_owner_info *oinfo, xfs_filblks_t *blocks);
|
||||
|
||||
int xchk_setup_ag_btree(struct xfs_scrub *sc, struct xfs_inode *ip,
|
||||
bool force_log);
|
||||
|
@@ -383,9 +383,9 @@ xchk_refcountbt_rec(
|
||||
STATIC void
|
||||
xchk_refcount_xref_rmap(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_owner_info *oinfo,
|
||||
xfs_filblks_t cow_blocks)
|
||||
{
|
||||
struct xfs_owner_info oinfo;
|
||||
xfs_extlen_t refcbt_blocks = 0;
|
||||
xfs_filblks_t blocks;
|
||||
int error;
|
||||
@@ -394,10 +394,11 @@ xchk_refcount_xref_rmap(
|
||||
return;
|
||||
|
||||
/* Check that we saw as many refcbt blocks as the rmap knows about. */
|
||||
xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_REFC);
|
||||
error = xfs_btree_count_blocks(sc->sa.refc_cur, &refcbt_blocks);
|
||||
if (!xchk_btree_process_error(sc, sc->sa.refc_cur, 0, &error))
|
||||
return;
|
||||
error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, oinfo,
|
||||
error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, &oinfo,
|
||||
&blocks);
|
||||
if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur))
|
||||
return;
|
||||
@@ -405,8 +406,8 @@ xchk_refcount_xref_rmap(
|
||||
xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0);
|
||||
|
||||
/* Check that we saw as many cow blocks as the rmap knows about. */
|
||||
xfs_rmap_ag_owner(oinfo, XFS_RMAP_OWN_COW);
|
||||
error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, oinfo,
|
||||
xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_COW);
|
||||
error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, &oinfo,
|
||||
&blocks);
|
||||
if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur))
|
||||
return;
|
||||
@@ -429,7 +430,7 @@ xchk_refcountbt(
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
xchk_refcount_xref_rmap(sc, &oinfo, cow_blocks);
|
||||
xchk_refcount_xref_rmap(sc, cow_blocks);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -299,14 +299,14 @@ xrep_calc_ag_resblks(
|
||||
/* Allocate a block in an AG. */
|
||||
int
|
||||
xrep_alloc_ag_block(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_owner_info *oinfo,
|
||||
xfs_fsblock_t *fsbno,
|
||||
enum xfs_ag_resv_type resv)
|
||||
struct xfs_scrub *sc,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
xfs_fsblock_t *fsbno,
|
||||
enum xfs_ag_resv_type resv)
|
||||
{
|
||||
struct xfs_alloc_arg args = {0};
|
||||
xfs_agblock_t bno;
|
||||
int error;
|
||||
struct xfs_alloc_arg args = {0};
|
||||
xfs_agblock_t bno;
|
||||
int error;
|
||||
|
||||
switch (resv) {
|
||||
case XFS_AG_RESV_AGFL:
|
||||
@@ -538,17 +538,17 @@ xrep_put_freelist(
|
||||
/* Dispose of a single block. */
|
||||
STATIC int
|
||||
xrep_reap_block(
|
||||
struct xfs_scrub *sc,
|
||||
xfs_fsblock_t fsbno,
|
||||
struct xfs_owner_info *oinfo,
|
||||
enum xfs_ag_resv_type resv)
|
||||
struct xfs_scrub *sc,
|
||||
xfs_fsblock_t fsbno,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
enum xfs_ag_resv_type resv)
|
||||
{
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_buf *agf_bp = NULL;
|
||||
xfs_agnumber_t agno;
|
||||
xfs_agblock_t agbno;
|
||||
bool has_other_rmap;
|
||||
int error;
|
||||
struct xfs_btree_cur *cur;
|
||||
struct xfs_buf *agf_bp = NULL;
|
||||
xfs_agnumber_t agno;
|
||||
xfs_agblock_t agbno;
|
||||
bool has_other_rmap;
|
||||
int error;
|
||||
|
||||
agno = XFS_FSB_TO_AGNO(sc->mp, fsbno);
|
||||
agbno = XFS_FSB_TO_AGBNO(sc->mp, fsbno);
|
||||
@@ -612,15 +612,15 @@ out_free:
|
||||
/* Dispose of every block of every extent in the bitmap. */
|
||||
int
|
||||
xrep_reap_extents(
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_bitmap *bitmap,
|
||||
struct xfs_owner_info *oinfo,
|
||||
enum xfs_ag_resv_type type)
|
||||
struct xfs_scrub *sc,
|
||||
struct xfs_bitmap *bitmap,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
enum xfs_ag_resv_type type)
|
||||
{
|
||||
struct xfs_bitmap_range *bmr;
|
||||
struct xfs_bitmap_range *n;
|
||||
xfs_fsblock_t fsbno;
|
||||
int error = 0;
|
||||
struct xfs_bitmap_range *bmr;
|
||||
struct xfs_bitmap_range *n;
|
||||
xfs_fsblock_t fsbno;
|
||||
int error = 0;
|
||||
|
||||
ASSERT(xfs_sb_version_hasrmapbt(&sc->mp->m_sb));
|
||||
|
||||
|
@@ -21,8 +21,9 @@ int xrep_roll_ag_trans(struct xfs_scrub *sc);
|
||||
bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
|
||||
enum xfs_ag_resv_type type);
|
||||
xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
|
||||
int xrep_alloc_ag_block(struct xfs_scrub *sc, struct xfs_owner_info *oinfo,
|
||||
xfs_fsblock_t *fsbno, enum xfs_ag_resv_type resv);
|
||||
int xrep_alloc_ag_block(struct xfs_scrub *sc,
|
||||
const struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno,
|
||||
enum xfs_ag_resv_type resv);
|
||||
int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
|
||||
struct xfs_buf **bpp, xfs_btnum_t btnum,
|
||||
const struct xfs_buf_ops *ops);
|
||||
@@ -32,7 +33,7 @@ struct xfs_bitmap;
|
||||
int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
|
||||
int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xfs_bitmap *btlist);
|
||||
int xrep_reap_extents(struct xfs_scrub *sc, struct xfs_bitmap *exlist,
|
||||
struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
|
||||
const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
|
||||
|
||||
struct xrep_find_ag_btree {
|
||||
/* in: rmap owner of the btree we're looking for */
|
||||
|
@@ -184,14 +184,14 @@ xchk_rmapbt(
|
||||
/* xref check that the extent is owned by a given owner */
|
||||
static inline void
|
||||
xchk_xref_check_owner(
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
struct xfs_owner_info *oinfo,
|
||||
bool should_have_rmap)
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
const struct xfs_owner_info *oinfo,
|
||||
bool should_have_rmap)
|
||||
{
|
||||
bool has_rmap;
|
||||
int error;
|
||||
bool has_rmap;
|
||||
int error;
|
||||
|
||||
if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
|
||||
return;
|
||||
@@ -207,10 +207,10 @@ xchk_xref_check_owner(
|
||||
/* xref check that the extent is owned by a given owner */
|
||||
void
|
||||
xchk_xref_is_owned_by(
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
struct xfs_owner_info *oinfo)
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
const struct xfs_owner_info *oinfo)
|
||||
{
|
||||
xchk_xref_check_owner(sc, bno, len, oinfo, true);
|
||||
}
|
||||
@@ -218,10 +218,10 @@ xchk_xref_is_owned_by(
|
||||
/* xref check that the extent is not owned by a given owner */
|
||||
void
|
||||
xchk_xref_is_not_owned_by(
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
struct xfs_owner_info *oinfo)
|
||||
struct xfs_scrub *sc,
|
||||
xfs_agblock_t bno,
|
||||
xfs_extlen_t len,
|
||||
const struct xfs_owner_info *oinfo)
|
||||
{
|
||||
xchk_xref_check_owner(sc, bno, len, oinfo, false);
|
||||
}
|
||||
|
@@ -122,9 +122,9 @@ void xchk_xref_is_not_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
|
||||
void xchk_xref_is_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
|
||||
xfs_extlen_t len);
|
||||
void xchk_xref_is_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
|
||||
xfs_extlen_t len, struct xfs_owner_info *oinfo);
|
||||
xfs_extlen_t len, const struct xfs_owner_info *oinfo);
|
||||
void xchk_xref_is_not_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
|
||||
xfs_extlen_t len, struct xfs_owner_info *oinfo);
|
||||
xfs_extlen_t len, const struct xfs_owner_info *oinfo);
|
||||
void xchk_xref_has_no_owner(struct xfs_scrub *sc, xfs_agblock_t agbno,
|
||||
xfs_extlen_t len);
|
||||
void xchk_xref_is_cow_staging(struct xfs_scrub *sc, xfs_agblock_t bno,
|
||||
|
Reference in New Issue
Block a user