Skip to content

Commit 783e8a7

Browse files
author
Darrick J. Wong
committed
xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c
Move the code that adds the incore xfs_refcount_update_item deferred work data to a transaction live with the CUI log item code. This means that the refcount code no longer has to know about the inner workings of the CUI 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 e51987a commit 783e8a7

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

fs/xfs/libxfs/xfs_refcount.c

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

2829
struct kmem_cache *xfs_refcount_intent_cache;
2930

@@ -1435,10 +1436,7 @@ __xfs_refcount_add(
14351436
ri->ri_startblock = startblock;
14361437
ri->ri_blockcount = blockcount;
14371438

1438-
trace_xfs_refcount_defer(tp->t_mountp, ri);
1439-
1440-
xfs_refcount_update_get_group(tp->t_mountp, ri);
1441-
xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
1439+
xfs_refcount_defer_add(tp, ri);
14421440
}
14431441

14441442
/*

fs/xfs/libxfs/xfs_refcount.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ xfs_refcount_check_domain(
7474
return true;
7575
}
7676

77-
void xfs_refcount_update_get_group(struct xfs_mount *mp,
78-
struct xfs_refcount_intent *ri);
79-
8077
void xfs_refcount_increase_extent(struct xfs_trans *tp,
8178
struct xfs_bmbt_irec *irec);
8279
void xfs_refcount_decrease_extent(struct xfs_trans *tp,

fs/xfs/xfs_refcount_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_cui_cache;
2728
struct kmem_cache *xfs_cud_cache;
@@ -319,21 +320,18 @@ xfs_refcount_update_create_done(
319320
return &cudp->cud_item;
320321
}
321322

322-
/* Take a passive ref to the AG containing the space we're refcounting. */
323+
/* Add this deferred CUI to the transaction. */
323324
void
324-
xfs_refcount_update_get_group(
325-
struct xfs_mount *mp,
325+
xfs_refcount_defer_add(
326+
struct xfs_trans *tp,
326327
struct xfs_refcount_intent *ri)
327328
{
328-
ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
329-
}
329+
struct xfs_mount *mp = tp->t_mountp;
330330

331-
/* Release a passive AG ref after finishing refcounting work. */
332-
static inline void
333-
xfs_refcount_update_put_group(
334-
struct xfs_refcount_intent *ri)
335-
{
336-
xfs_perag_intent_put(ri->ri_pag);
331+
trace_xfs_refcount_defer(mp, ri);
332+
333+
ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
334+
xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
337335
}
338336

339337
/* Cancel a deferred refcount update. */
@@ -343,7 +341,7 @@ xfs_refcount_update_cancel_item(
343341
{
344342
struct xfs_refcount_intent *ri = ci_entry(item);
345343

346-
xfs_refcount_update_put_group(ri);
344+
xfs_perag_intent_put(ri->ri_pag);
347345
kmem_cache_free(xfs_refcount_intent_cache, ri);
348346
}
349347

@@ -433,7 +431,7 @@ xfs_cui_recover_work(
433431
ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK;
434432
ri->ri_startblock = pmap->pe_startblock;
435433
ri->ri_blockcount = pmap->pe_len;
436-
xfs_refcount_update_get_group(mp, ri);
434+
ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
437435

438436
xfs_defer_add_item(dfp, &ri->ri_list);
439437
}

fs/xfs/xfs_refcount_item.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ struct xfs_cud_log_item {
7171
extern struct kmem_cache *xfs_cui_cache;
7272
extern struct kmem_cache *xfs_cud_cache;
7373

74+
struct xfs_refcount_intent;
75+
76+
void xfs_refcount_defer_add(struct xfs_trans *tp,
77+
struct xfs_refcount_intent *ri);
78+
7479
#endif /* __XFS_REFCOUNT_ITEM_H__ */

0 commit comments

Comments
 (0)