Skip to content

Commit e5e5cae

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: store a generic group structure in the intents
Replace the pag pointers in the extent free, bmap, rmap and refcount intent structures with a pointer to the generic group to prepare for adding intents for realtime groups. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent ba102a6 commit e5e5cae

12 files changed

+63
-55
lines changed

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ struct xfs_extent_free_item {
248248
uint64_t xefi_owner;
249249
xfs_fsblock_t xefi_startblock;/* starting fs block number */
250250
xfs_extlen_t xefi_blockcount;/* number of blocks in extent */
251-
struct xfs_perag *xefi_pag;
251+
struct xfs_group *xefi_group;
252252
unsigned int xefi_flags;
253253
enum xfs_ag_resv_type xefi_agresv;
254254
};

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ struct xfs_bmap_intent {
248248
enum xfs_bmap_intent_type bi_type;
249249
int bi_whichfork;
250250
struct xfs_inode *bi_owner;
251-
struct xfs_perag *bi_pag;
251+
struct xfs_group *bi_group;
252252
struct xfs_bmbt_irec bi_bmap;
253253
};
254254

fs/xfs/libxfs/xfs_refcount.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,21 +1358,22 @@ xfs_refcount_finish_one(
13581358
* If we haven't gotten a cursor or the cursor AG doesn't match
13591359
* the startblock, get one now.
13601360
*/
1361-
if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) {
1361+
if (rcur != NULL && rcur->bc_group != ri->ri_group) {
13621362
nr_ops = rcur->bc_refc.nr_ops;
13631363
shape_changes = rcur->bc_refc.shape_changes;
13641364
xfs_btree_del_cursor(rcur, 0);
13651365
rcur = NULL;
13661366
*pcur = NULL;
13671367
}
13681368
if (rcur == NULL) {
1369-
error = xfs_alloc_read_agf(ri->ri_pag, tp,
1369+
struct xfs_perag *pag = to_perag(ri->ri_group);
1370+
1371+
error = xfs_alloc_read_agf(pag, tp,
13701372
XFS_ALLOC_FLAG_FREEING, &agbp);
13711373
if (error)
13721374
return error;
13731375

1374-
*pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp,
1375-
ri->ri_pag);
1376+
*pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, pag);
13761377
rcur->bc_refc.nr_ops = nr_ops;
13771378
rcur->bc_refc.shape_changes = shape_changes;
13781379
}

fs/xfs/libxfs/xfs_refcount.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ enum xfs_refcount_intent_type {
5656

5757
struct xfs_refcount_intent {
5858
struct list_head ri_list;
59-
struct xfs_perag *ri_pag;
59+
struct xfs_group *ri_group;
6060
enum xfs_refcount_intent_type ri_type;
6161
xfs_extlen_t ri_blockcount;
6262
xfs_fsblock_t ri_startblock;

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,28 +2586,30 @@ xfs_rmap_finish_one(
25862586
* If we haven't gotten a cursor or the cursor AG doesn't match
25872587
* the startblock, get one now.
25882588
*/
2589-
if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) {
2589+
if (rcur != NULL && rcur->bc_group != ri->ri_group) {
25902590
xfs_btree_del_cursor(rcur, 0);
25912591
rcur = NULL;
25922592
*pcur = NULL;
25932593
}
25942594
if (rcur == NULL) {
2595+
struct xfs_perag *pag = to_perag(ri->ri_group);
2596+
25952597
/*
25962598
* Refresh the freelist before we start changing the
25972599
* rmapbt, because a shape change could cause us to
25982600
* allocate blocks.
25992601
*/
2600-
error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp);
2602+
error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
26012603
if (error) {
2602-
xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
2604+
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL);
26032605
return error;
26042606
}
26052607
if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) {
2606-
xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
2608+
xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL);
26072609
return -EFSCORRUPTED;
26082610
}
26092611

2610-
*pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
2612+
*pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
26112613
}
26122614

26132615
xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
@@ -2620,8 +2622,8 @@ xfs_rmap_finish_one(
26202622
if (error)
26212623
return error;
26222624

2623-
xfs_rmap_update_hook(tp, pag_group(ri->ri_pag), ri->ri_type, bno,
2624-
ri->ri_bmap.br_blockcount, unwritten, &oinfo);
2625+
xfs_rmap_update_hook(tp, ri->ri_group, 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ struct xfs_rmap_intent {
173173
int ri_whichfork;
174174
uint64_t ri_owner;
175175
struct xfs_bmbt_irec ri_bmap;
176-
struct xfs_perag *ri_pag;
176+
struct xfs_group *ri_group;
177177
};
178178

179179
/* functions for updating the rmapbt based on bmbt map/unmap operations */

fs/xfs/xfs_bmap_item.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ xfs_bmap_update_get_group(
334334
* intent drops the intent count, ensuring that the intent count
335335
* remains nonzero across the transaction roll.
336336
*/
337-
bi->bi_pag = xfs_perag_intent_get(mp, bi->bi_bmap.br_startblock);
337+
bi->bi_group = xfs_group_intent_get(mp, bi->bi_bmap.br_startblock,
338+
XG_TYPE_AG);
338339
}
339340

340341
/* Add this deferred BUI to the transaction. */
@@ -368,7 +369,7 @@ xfs_bmap_update_put_group(
368369
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
369370
return;
370371

371-
xfs_perag_intent_put(bi->bi_pag);
372+
xfs_group_intent_put(bi->bi_group);
372373
}
373374

374375
/* Cancel a deferred bmap update. */

fs/xfs/xfs_drain.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,39 @@ static inline int xfs_defer_drain_wait(struct xfs_defer_drain *dr)
9494
}
9595

9696
/*
97-
* Get a passive reference to the AG that contains a fsbno and declare an
97+
* Get a passive reference to the group that contains a fsbno and declare an
9898
* intent to update its metadata.
9999
*
100100
* Other threads that need exclusive access can decide to back off if they see
101101
* declared intentions.
102102
*/
103-
struct xfs_perag *
104-
xfs_perag_intent_get(
103+
struct xfs_group *
104+
xfs_group_intent_get(
105105
struct xfs_mount *mp,
106-
xfs_fsblock_t fsbno)
106+
xfs_fsblock_t fsbno,
107+
enum xfs_group_type type)
107108
{
108-
struct xfs_perag *pag;
109+
struct xfs_group *xg;
109110

110-
pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, fsbno));
111-
if (!pag)
111+
xg = xfs_group_get_by_fsb(mp, fsbno, type);
112+
if (!xg)
112113
return NULL;
113-
114-
trace_xfs_group_intent_hold(pag_group(pag), __return_address);
115-
xfs_defer_drain_grab(pag_group(pag).xg_intents_drain);
116-
return pag;
114+
trace_xfs_group_intent_hold(xg, __return_address);
115+
xfs_defer_drain_grab(&xg->xg_intents_drain);
116+
return xg;
117117
}
118118

119119
/*
120-
* Release our intent to update this AG's metadata, and then release our
121-
* passive ref to the AG.
120+
* Release our intent to update this groups metadata, and then release our
121+
* passive ref to it.
122122
*/
123123
void
124-
xfs_perag_intent_put(
125-
struct xfs_perag *pag)
124+
xfs_group_intent_put(
125+
struct xfs_group *xg)
126126
{
127-
trace_xfs_group_intent_rele(pag_group(pag), __return_address);
128-
xfs_defer_drain_rele(pag_group(pag).xg_intents_drain);
129-
xfs_perag_put(pag);
127+
trace_xfs_group_intent_rele(xg, __return_address);
128+
xfs_defer_drain_rele(&xg->xg_intents_drain);
129+
xfs_group_put(xg);
130130
}
131131

132132
/*

fs/xfs/xfs_drain.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ void xfs_drain_wait_enable(void);
6262
* soon as the item is added to the transaction and cannot drop the counter
6363
* until the item is finished or cancelled.
6464
*/
65-
struct xfs_perag *xfs_perag_intent_get(struct xfs_mount *mp,
66-
xfs_fsblock_t fsbno);
67-
void xfs_perag_intent_put(struct xfs_perag *pag);
65+
struct xfs_group *xfs_group_intent_get(struct xfs_mount *mp,
66+
xfs_fsblock_t fsbno, enum xfs_group_type type);
67+
void xfs_group_intent_put(struct xfs_group *rtg);
6868

6969
int xfs_group_intent_drain(struct xfs_group *xg);
7070
bool xfs_group_intent_busy(struct xfs_group *xg);
@@ -75,9 +75,9 @@ struct xfs_defer_drain { /* empty */ };
7575
#define xfs_defer_drain_free(dr) ((void)0)
7676
#define xfs_defer_drain_init(dr) ((void)0)
7777

78-
#define xfs_perag_intent_get(mp, fsbno) \
79-
xfs_perag_get((mp), XFS_FSB_TO_AGNO(mp, fsbno))
80-
#define xfs_perag_intent_put(pag) xfs_perag_put(pag)
78+
#define xfs_group_intent_get(_mp, _fsbno, _type) \
79+
xfs_group_get_by_fsb((_mp), (_fsbno), (_type))
80+
#define xfs_group_intent_put(xg) xfs_group_put(xg)
8181

8282
#endif /* CONFIG_XFS_DRAIN_INTENTS */
8383

fs/xfs/xfs_extfree_item.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ xfs_extent_free_diff_items(
362362
struct xfs_extent_free_item *ra = xefi_entry(a);
363363
struct xfs_extent_free_item *rb = xefi_entry(b);
364364

365-
return pag_agno(ra->xefi_pag) - pag_agno(rb->xefi_pag);
365+
return ra->xefi_group->xg_gno - rb->xefi_group->xg_gno;
366366
}
367367

368368
/* Log a free extent to the intent item. */
@@ -447,7 +447,8 @@ xfs_extent_free_defer_add(
447447

448448
trace_xfs_extent_free_defer(mp, xefi);
449449

450-
xefi->xefi_pag = xfs_perag_intent_get(mp, xefi->xefi_startblock);
450+
xefi->xefi_group = xfs_group_intent_get(mp, xefi->xefi_startblock,
451+
XG_TYPE_AG);
451452
if (xefi->xefi_agresv == XFS_AG_RESV_AGFL)
452453
*dfpp = xfs_defer_add(tp, &xefi->xefi_list,
453454
&xfs_agfl_free_defer_type);
@@ -463,7 +464,7 @@ xfs_extent_free_cancel_item(
463464
{
464465
struct xfs_extent_free_item *xefi = xefi_entry(item);
465466

466-
xfs_perag_intent_put(xefi->xefi_pag);
467+
xfs_group_intent_put(xefi->xefi_group);
467468
kmem_cache_free(xfs_extfree_item_cache, xefi);
468469
}
469470

@@ -499,7 +500,7 @@ xfs_extent_free_finish_item(
499500
* in this EFI to the EFD so this works correctly.
500501
*/
501502
if (!(xefi->xefi_flags & XFS_EFI_CANCELLED))
502-
error = __xfs_free_extent(tp, xefi->xefi_pag, agbno,
503+
error = __xfs_free_extent(tp, to_perag(xefi->xefi_group), agbno,
503504
xefi->xefi_blockcount, &oinfo, xefi->xefi_agresv,
504505
xefi->xefi_flags & XFS_EFI_SKIP_DISCARD);
505506
if (error == -EAGAIN) {
@@ -545,7 +546,7 @@ xfs_agfl_free_finish_item(
545546

546547
trace_xfs_agfl_free_deferred(mp, xefi);
547548

548-
error = xfs_alloc_read_agf(xefi->xefi_pag, tp, 0, &agbp);
549+
error = xfs_alloc_read_agf(to_perag(xefi->xefi_group), tp, 0, &agbp);
549550
if (!error)
550551
error = xfs_free_ag_extent(tp, agbp, agbno, 1, &oinfo,
551552
XFS_AG_RESV_AGFL);
@@ -578,7 +579,8 @@ xfs_efi_recover_work(
578579
xefi->xefi_blockcount = extp->ext_len;
579580
xefi->xefi_agresv = XFS_AG_RESV_NONE;
580581
xefi->xefi_owner = XFS_RMAP_OWN_UNKNOWN;
581-
xefi->xefi_pag = xfs_perag_intent_get(mp, extp->ext_start);
582+
xefi->xefi_group = xfs_group_intent_get(mp, extp->ext_start,
583+
XG_TYPE_AG);
582584

583585
xfs_defer_add_item(dfp, &xefi->xefi_list);
584586
}

0 commit comments

Comments
 (0)