Skip to content

Commit e464d8e

Browse files
author
Darrick J. Wong
committed
xfs: store rtgroup information with a bmap intent
Make the bmap intent items take an active reference to the rtgroup containing the space that is being mapped or unmapped. We will need this functionality once we start enabling rmap and reflink on the rt volume. Technically speaking we need it even for !rtgroups filesystems to prevent the (dummy) rtgroup 0 from going away, even though this will never happen. As a bonus, we can rework the xfs_bmap_deferred_class tracepoint to use the xfs_group object to figure out the type and group number, widen the group block number field to fit 64-bit quantities, and get rid of the now redundant opdev and rtblock fields. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent ee32135 commit e464d8e

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

fs/xfs/xfs_bmap_item.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,16 @@ xfs_bmap_update_create_done(
318318
return &budp->bud_item;
319319
}
320320

321-
/* Take a passive ref to the AG containing the space we're mapping. */
321+
/* Take a passive ref to the group containing the space we're mapping. */
322322
static inline void
323323
xfs_bmap_update_get_group(
324324
struct xfs_mount *mp,
325325
struct xfs_bmap_intent *bi)
326326
{
327+
enum xfs_group_type type = XG_TYPE_AG;
328+
327329
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
328-
return;
330+
type = XG_TYPE_RTG;
329331

330332
/*
331333
* Bump the intent count on behalf of the deferred rmap and refcount
@@ -335,7 +337,7 @@ xfs_bmap_update_get_group(
335337
* remains nonzero across the transaction roll.
336338
*/
337339
bi->bi_group = xfs_group_intent_get(mp, bi->bi_bmap.br_startblock,
338-
XG_TYPE_AG);
340+
type);
339341
}
340342

341343
/* Add this deferred BUI to the transaction. */
@@ -344,8 +346,6 @@ xfs_bmap_defer_add(
344346
struct xfs_trans *tp,
345347
struct xfs_bmap_intent *bi)
346348
{
347-
trace_xfs_bmap_defer(bi);
348-
349349
xfs_bmap_update_get_group(tp->t_mountp, bi);
350350

351351
/*
@@ -358,18 +358,9 @@ xfs_bmap_defer_add(
358358
*/
359359
if (bi->bi_type == XFS_BMAP_MAP)
360360
bi->bi_owner->i_delayed_blks += bi->bi_bmap.br_blockcount;
361-
xfs_defer_add(tp, &bi->bi_list, &xfs_bmap_update_defer_type);
362-
}
363-
364-
/* Release a passive AG ref after finishing mapping work. */
365-
static inline void
366-
xfs_bmap_update_put_group(
367-
struct xfs_bmap_intent *bi)
368-
{
369-
if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
370-
return;
371361

372-
xfs_group_intent_put(bi->bi_group);
362+
trace_xfs_bmap_defer(bi);
363+
xfs_defer_add(tp, &bi->bi_list, &xfs_bmap_update_defer_type);
373364
}
374365

375366
/* Cancel a deferred bmap update. */
@@ -382,7 +373,7 @@ xfs_bmap_update_cancel_item(
382373
if (bi->bi_type == XFS_BMAP_MAP)
383374
bi->bi_owner->i_delayed_blks -= bi->bi_bmap.br_blockcount;
384375

385-
xfs_bmap_update_put_group(bi);
376+
xfs_group_intent_put(bi->bi_group);
386377
kmem_cache_free(xfs_bmap_intent_cache, bi);
387378
}
388379

fs/xfs/xfs_trace.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,11 +3081,10 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
30813081
TP_ARGS(bi),
30823082
TP_STRUCT__entry(
30833083
__field(dev_t, dev)
3084-
__field(dev_t, opdev)
3084+
__field(enum xfs_group_type, type)
30853085
__field(xfs_agnumber_t, agno)
30863086
__field(xfs_ino_t, ino)
3087-
__field(xfs_agblock_t, agbno)
3088-
__field(xfs_fsblock_t, rtbno)
3087+
__field(unsigned long long, gbno)
30893088
__field(int, whichfork)
30903089
__field(xfs_fileoff_t, l_loff)
30913090
__field(xfs_filblks_t, l_len)
@@ -3094,20 +3093,25 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
30943093
),
30953094
TP_fast_assign(
30963095
struct xfs_inode *ip = bi->bi_owner;
3096+
struct xfs_mount *mp = ip->i_mount;
30973097

3098-
__entry->dev = ip->i_mount->m_super->s_dev;
3099-
if (xfs_ifork_is_realtime(ip, bi->bi_whichfork)) {
3100-
__entry->agno = 0;
3101-
__entry->agbno = 0;
3102-
__entry->rtbno = bi->bi_bmap.br_startblock;
3103-
__entry->opdev = ip->i_mount->m_rtdev_targp->bt_dev;
3098+
__entry->dev = mp->m_super->s_dev;
3099+
__entry->type = bi->bi_group->xg_type;
3100+
__entry->agno = bi->bi_group->xg_gno;
3101+
if (bi->bi_group->xg_type == XG_TYPE_RTG &&
3102+
!xfs_has_rtgroups(mp)) {
3103+
/*
3104+
* Legacy rt filesystems do not have allocation groups
3105+
* ondisk. We emulate this incore with one gigantic
3106+
* rtgroup whose size can exceed a 32-bit block number.
3107+
* For this tracepoint, we report group 0 and a 64-bit
3108+
* group block number.
3109+
*/
3110+
__entry->gbno = bi->bi_bmap.br_startblock;
31043111
} else {
3105-
__entry->agno = XFS_FSB_TO_AGNO(ip->i_mount,
3106-
bi->bi_bmap.br_startblock);
3107-
__entry->agbno = XFS_FSB_TO_AGBNO(ip->i_mount,
3108-
bi->bi_bmap.br_startblock);
3109-
__entry->rtbno = 0;
3110-
__entry->opdev = __entry->dev;
3112+
__entry->gbno = xfs_fsb_to_gbno(mp,
3113+
bi->bi_bmap.br_startblock,
3114+
bi->bi_group->xg_type);
31113115
}
31123116
__entry->ino = ip->i_ino;
31133117
__entry->whichfork = bi->bi_whichfork;
@@ -3116,14 +3120,13 @@ DECLARE_EVENT_CLASS(xfs_bmap_deferred_class,
31163120
__entry->l_state = bi->bi_bmap.br_state;
31173121
__entry->op = bi->bi_type;
31183122
),
3119-
TP_printk("dev %d:%d op %s opdev %d:%d ino 0x%llx agno 0x%x agbno 0x%x rtbno 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
3123+
TP_printk("dev %d:%d op %s ino 0x%llx %sno 0x%x gbno 0x%llx %s fileoff 0x%llx fsbcount 0x%llx state %d",
31203124
MAJOR(__entry->dev), MINOR(__entry->dev),
31213125
__print_symbolic(__entry->op, XFS_BMAP_INTENT_STRINGS),
3122-
MAJOR(__entry->opdev), MINOR(__entry->opdev),
31233126
__entry->ino,
3127+
__print_symbolic(__entry->type, XG_TYPE_STRINGS),
31243128
__entry->agno,
3125-
__entry->agbno,
3126-
__entry->rtbno,
3129+
__entry->gbno,
31273130
__print_symbolic(__entry->whichfork, XFS_WHICHFORK_STRINGS),
31283131
__entry->l_loff,
31293132
__entry->l_len,

0 commit comments

Comments
 (0)