Skip to content

Commit eb4a84a

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: move the online repair rmap hooks to the generic group structure
Prepare for the upcoming realtime groups feature by moving the online repair rmap hooks to based to the generic xfs_group structure. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 34cf3a6 commit eb4a84a

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
lines changed

fs/xfs/libxfs/xfs_ag.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ xfs_perag_alloc(
235235
INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
236236
init_waitqueue_head(&pag->pagb_wait);
237237
pag->pagb_tree = RB_ROOT;
238-
xfs_hooks_init(&pag->pag_rmap_update_hooks);
239238
#endif /* __KERNEL__ */
240239

241240
error = xfs_buf_cache_init(&pag->pag_bcache);

fs/xfs/libxfs/xfs_ag.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ struct xfs_perag {
9696

9797
/* background prealloc block trimming */
9898
struct delayed_work pag_blockgc_work;
99-
100-
/* Hook to feed rmapbt updates to an active online repair. */
101-
struct xfs_hooks pag_rmap_update_hooks;
10299
#endif /* __KERNEL__ */
103100
};
104101

fs/xfs/libxfs/xfs_group.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ xfs_group_insert(
186186

187187
#ifdef __KERNEL__
188188
spin_lock_init(&xg->xg_state_lock);
189+
xfs_hooks_init(&xg->xg_rmap_update_hooks);
189190
#endif
190191
xfs_defer_drain_init(&xg->xg_intents_drain);
191192

fs/xfs/libxfs/xfs_group.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ struct xfs_group {
3131
* inconsistencies.
3232
*/
3333
struct xfs_defer_drain xg_intents_drain;
34+
35+
/*
36+
* Hook to feed rmapbt updates to an active online repair.
37+
*/
38+
struct xfs_hooks xg_rmap_update_hooks;
3439
#endif /* __KERNEL__ */
3540
};
3641

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ xfs_rmap_hook_enable(void)
835835
static inline void
836836
xfs_rmap_update_hook(
837837
struct xfs_trans *tp,
838-
struct xfs_perag *pag,
838+
struct xfs_group *xg,
839839
enum xfs_rmap_intent_type op,
840840
xfs_agblock_t startblock,
841841
xfs_extlen_t blockcount,
@@ -850,27 +850,27 @@ xfs_rmap_update_hook(
850850
.oinfo = *oinfo, /* struct copy */
851851
};
852852

853-
if (pag)
854-
xfs_hooks_call(&pag->pag_rmap_update_hooks, op, &p);
853+
if (xg)
854+
xfs_hooks_call(&xg->xg_rmap_update_hooks, op, &p);
855855
}
856856
}
857857

858858
/* Call the specified function during a reverse mapping update. */
859859
int
860860
xfs_rmap_hook_add(
861-
struct xfs_perag *pag,
861+
struct xfs_group *xg,
862862
struct xfs_rmap_hook *hook)
863863
{
864-
return xfs_hooks_add(&pag->pag_rmap_update_hooks, &hook->rmap_hook);
864+
return xfs_hooks_add(&xg->xg_rmap_update_hooks, &hook->rmap_hook);
865865
}
866866

867867
/* Stop calling the specified function during a reverse mapping update. */
868868
void
869869
xfs_rmap_hook_del(
870-
struct xfs_perag *pag,
870+
struct xfs_group *xg,
871871
struct xfs_rmap_hook *hook)
872872
{
873-
xfs_hooks_del(&pag->pag_rmap_update_hooks, &hook->rmap_hook);
873+
xfs_hooks_del(&xg->xg_rmap_update_hooks, &hook->rmap_hook);
874874
}
875875

876876
/* Configure rmap update hook functions. */
@@ -905,7 +905,8 @@ xfs_rmap_free(
905905
return 0;
906906

907907
cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
908-
xfs_rmap_update_hook(tp, pag, XFS_RMAP_UNMAP, bno, len, false, oinfo);
908+
xfs_rmap_update_hook(tp, pag_group(pag), XFS_RMAP_UNMAP, bno, len,
909+
false, oinfo);
909910
error = xfs_rmap_unmap(cur, bno, len, false, oinfo);
910911

911912
xfs_btree_del_cursor(cur, error);
@@ -1149,7 +1150,8 @@ xfs_rmap_alloc(
11491150
return 0;
11501151

11511152
cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
1152-
xfs_rmap_update_hook(tp, pag, XFS_RMAP_MAP, bno, len, false, oinfo);
1153+
xfs_rmap_update_hook(tp, pag_group(pag), XFS_RMAP_MAP, bno, len, false,
1154+
oinfo);
11531155
error = xfs_rmap_map(cur, bno, len, false, oinfo);
11541156

11551157
xfs_btree_del_cursor(cur, error);
@@ -2620,8 +2622,8 @@ xfs_rmap_finish_one(
26202622
if (error)
26212623
return error;
26222624

2623-
xfs_rmap_update_hook(tp, ri->ri_pag, ri->ri_type, bno,
2624-
ri->ri_bmap.br_blockcount, unwritten, &oinfo);
2625+
xfs_rmap_update_hook(tp, pag_group(ri->ri_pag), ri->ri_type, bno,
2626+
ri->ri_bmap.br_blockcount, unwritten, &oinfo);
26252627
return 0;
26262628
}
26272629

fs/xfs/libxfs/xfs_rmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ struct xfs_rmap_hook {
264264
void xfs_rmap_hook_disable(void);
265265
void xfs_rmap_hook_enable(void);
266266

267-
int xfs_rmap_hook_add(struct xfs_perag *pag, struct xfs_rmap_hook *hook);
268-
void xfs_rmap_hook_del(struct xfs_perag *pag, struct xfs_rmap_hook *hook);
267+
int xfs_rmap_hook_add(struct xfs_group *xg, struct xfs_rmap_hook *hook);
268+
void xfs_rmap_hook_del(struct xfs_group *xg, struct xfs_rmap_hook *hook);
269269
void xfs_rmap_hook_setup(struct xfs_rmap_hook *hook, notifier_fn_t mod_fn);
270270
#endif
271271

fs/xfs/scrub/rmap_repair.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ xrep_rmap_setup_scan(
16111611
*/
16121612
ASSERT(sc->flags & XCHK_FSGATES_RMAP);
16131613
xfs_rmap_hook_setup(&rr->rhook, xrep_rmapbt_live_update);
1614-
error = xfs_rmap_hook_add(sc->sa.pag, &rr->rhook);
1614+
error = xfs_rmap_hook_add(pag_group(sc->sa.pag), &rr->rhook);
16151615
if (error)
16161616
goto out_iscan;
16171617
return 0;
@@ -1632,7 +1632,7 @@ xrep_rmap_teardown(
16321632
struct xfs_scrub *sc = rr->sc;
16331633

16341634
xchk_iscan_abort(&rr->iscan);
1635-
xfs_rmap_hook_del(sc->sa.pag, &rr->rhook);
1635+
xfs_rmap_hook_del(pag_group(sc->sa.pag), &rr->rhook);
16361636
xchk_iscan_teardown(&rr->iscan);
16371637
xfbtree_destroy(&rr->rmap_btree);
16381638
mutex_destroy(&rr->lock);

0 commit comments

Comments
 (0)