Skip to content

Commit ea7b082

Browse files
author
Darrick J. Wong
committed
xfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c
Move the code that adds the incore xfs_rmap_update_item deferred work data to a transaction to live with the RUI log item code. This means that the rmap code no longer has to know about the inner workings of the RUI log items. As a consequence, we can get rid of the _{get,put}_group helpers. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent 905af72 commit ea7b082

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

fs/xfs/libxfs/xfs_rmap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "xfs_inode.h"
2525
#include "xfs_ag.h"
2626
#include "xfs_health.h"
27+
#include "xfs_rmap_item.h"
2728

2829
struct kmem_cache *xfs_rmap_intent_cache;
2930

@@ -2656,10 +2657,7 @@ __xfs_rmap_add(
26562657
ri->ri_whichfork = whichfork;
26572658
ri->ri_bmap = *bmap;
26582659

2659-
trace_xfs_rmap_defer(tp->t_mountp, ri);
2660-
2661-
xfs_rmap_update_get_group(tp->t_mountp, ri);
2662-
xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type);
2660+
xfs_rmap_defer_add(tp, ri);
26632661
}
26642662

26652663
/* Map an extent into a file. */

fs/xfs/libxfs/xfs_rmap.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ struct xfs_rmap_intent {
176176
struct xfs_perag *ri_pag;
177177
};
178178

179-
void xfs_rmap_update_get_group(struct xfs_mount *mp,
180-
struct xfs_rmap_intent *ri);
181-
182179
/* functions for updating the rmapbt based on bmbt map/unmap operations */
183180
void xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
184181
int whichfork, struct xfs_bmbt_irec *imap);

fs/xfs/xfs_rmap_item.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "xfs_log_recover.h"
2323
#include "xfs_ag.h"
2424
#include "xfs_btree.h"
25+
#include "xfs_trace.h"
2526

2627
struct kmem_cache *xfs_rui_cache;
2728
struct kmem_cache *xfs_rud_cache;
@@ -342,21 +343,18 @@ xfs_rmap_update_create_done(
342343
return &rudp->rud_item;
343344
}
344345

345-
/* Take a passive ref to the AG containing the space we're rmapping. */
346+
/* Add this deferred RUI to the transaction. */
346347
void
347-
xfs_rmap_update_get_group(
348-
struct xfs_mount *mp,
348+
xfs_rmap_defer_add(
349+
struct xfs_trans *tp,
349350
struct xfs_rmap_intent *ri)
350351
{
351-
ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock);
352-
}
352+
struct xfs_mount *mp = tp->t_mountp;
353353

354-
/* Release a passive AG ref after finishing rmapping work. */
355-
static inline void
356-
xfs_rmap_update_put_group(
357-
struct xfs_rmap_intent *ri)
358-
{
359-
xfs_perag_intent_put(ri->ri_pag);
354+
trace_xfs_rmap_defer(mp, ri);
355+
356+
ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock);
357+
xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type);
360358
}
361359

362360
/* Cancel a deferred rmap update. */
@@ -366,7 +364,7 @@ xfs_rmap_update_cancel_item(
366364
{
367365
struct xfs_rmap_intent *ri = ri_entry(item);
368366

369-
xfs_rmap_update_put_group(ri);
367+
xfs_perag_intent_put(ri->ri_pag);
370368
kmem_cache_free(xfs_rmap_intent_cache, ri);
371369
}
372370

@@ -496,7 +494,7 @@ xfs_rui_recover_work(
496494
ri->ri_bmap.br_blockcount = map->me_len;
497495
ri->ri_bmap.br_state = (map->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
498496
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
499-
xfs_rmap_update_get_group(mp, ri);
497+
ri->ri_pag = xfs_perag_intent_get(mp, map->me_startblock);
500498

501499
xfs_defer_add_item(dfp, &ri->ri_list);
502500
}

fs/xfs/xfs_rmap_item.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ struct xfs_rud_log_item {
7171
extern struct kmem_cache *xfs_rui_cache;
7272
extern struct kmem_cache *xfs_rud_cache;
7373

74+
struct xfs_rmap_intent;
75+
76+
void xfs_rmap_defer_add(struct xfs_trans *tp, struct xfs_rmap_intent *ri);
77+
7478
#endif /* __XFS_RMAP_ITEM_H__ */

0 commit comments

Comments
 (0)