Commit 4cdbfe45 authored by Chandan Babu R's avatar Chandan Babu R

Merge tag 'refcount-intent-cleanups-6.11_2024-07-02' of...

Merge tag 'refcount-intent-cleanups-6.11_2024-07-02' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.11-mergeB

xfs: refcount log intent cleanups

This series cleans up the refcount intent code before we start adding
support for realtime devices.  Similar to previous intent cleanup
patchsets, we start transforming the tracepoints so that the data
extraction are done inside the tracepoint code, and then we start
passing the intent itself to the _finish_one function.  This reduces the
boxing and unboxing of parameters.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>

* tag 'refcount-intent-cleanups-6.11_2024-07-02' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c
  xfs: simplify usage of the rcur local variable in xfs_refcount_finish_one
  xfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one
  xfs: reuse xfs_refcount_update_cancel_item
  xfs: add a ci_entry helper
  xfs: remove xfs_trans_set_refcount_flags
  xfs: clean up refcount log intent item tracepoint callsites
  xfs: pass btree cursors to refcount btree tracepoints
  xfs: create specialized classes for refcount tracepoints
  xfs: give refcount btree cursor error tracepoints their own class
parents 584aa150 783e8a7c
This diff is collapsed.
......@@ -48,6 +48,12 @@ enum xfs_refcount_intent_type {
XFS_REFCOUNT_FREE_COW,
};
#define XFS_REFCOUNT_INTENT_STRINGS \
{ XFS_REFCOUNT_INCREASE, "incr" }, \
{ XFS_REFCOUNT_DECREASE, "decr" }, \
{ XFS_REFCOUNT_ALLOC_COW, "alloc_cow" }, \
{ XFS_REFCOUNT_FREE_COW, "free_cow" }
struct xfs_refcount_intent {
struct list_head ri_list;
struct xfs_perag *ri_pag;
......@@ -68,16 +74,11 @@ xfs_refcount_check_domain(
return true;
}
void xfs_refcount_update_get_group(struct xfs_mount *mp,
struct xfs_refcount_intent *ri);
void xfs_refcount_increase_extent(struct xfs_trans *tp,
struct xfs_bmbt_irec *irec);
void xfs_refcount_decrease_extent(struct xfs_trans *tp,
struct xfs_bmbt_irec *irec);
extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
struct xfs_btree_cur *rcur, int error);
extern int xfs_refcount_finish_one(struct xfs_trans *tp,
struct xfs_refcount_intent *ri, struct xfs_btree_cur **pcur);
......
......@@ -21,6 +21,8 @@
#include "xfs_log_priv.h"
#include "xfs_log_recover.h"
#include "xfs_ag.h"
#include "xfs_btree.h"
#include "xfs_trace.h"
struct kmem_cache *xfs_cui_cache;
struct kmem_cache *xfs_cud_cache;
......@@ -227,6 +229,11 @@ static const struct xfs_item_ops xfs_cud_item_ops = {
.iop_intent = xfs_cud_item_intent,
};
static inline struct xfs_refcount_intent *ci_entry(const struct list_head *e)
{
return list_entry(e, struct xfs_refcount_intent, ri_list);
}
/* Sort refcount intents by AG. */
static int
xfs_refcount_update_diff_items(
......@@ -234,34 +241,12 @@ xfs_refcount_update_diff_items(
const struct list_head *a,
const struct list_head *b)
{
struct xfs_refcount_intent *ra;
struct xfs_refcount_intent *rb;
ra = container_of(a, struct xfs_refcount_intent, ri_list);
rb = container_of(b, struct xfs_refcount_intent, ri_list);
struct xfs_refcount_intent *ra = ci_entry(a);
struct xfs_refcount_intent *rb = ci_entry(b);
return ra->ri_pag->pag_agno - rb->ri_pag->pag_agno;
}
/* Set the phys extent flags for this reverse mapping. */
static void
xfs_trans_set_refcount_flags(
struct xfs_phys_extent *pmap,
enum xfs_refcount_intent_type type)
{
pmap->pe_flags = 0;
switch (type) {
case XFS_REFCOUNT_INCREASE:
case XFS_REFCOUNT_DECREASE:
case XFS_REFCOUNT_ALLOC_COW:
case XFS_REFCOUNT_FREE_COW:
pmap->pe_flags |= type;
break;
default:
ASSERT(0);
}
}
/* Log refcount updates in the intent item. */
STATIC void
xfs_refcount_update_log_item(
......@@ -282,7 +267,18 @@ xfs_refcount_update_log_item(
pmap = &cuip->cui_format.cui_extents[next_extent];
pmap->pe_startblock = ri->ri_startblock;
pmap->pe_len = ri->ri_blockcount;
xfs_trans_set_refcount_flags(pmap, ri->ri_type);
pmap->pe_flags = 0;
switch (ri->ri_type) {
case XFS_REFCOUNT_INCREASE:
case XFS_REFCOUNT_DECREASE:
case XFS_REFCOUNT_ALLOC_COW:
case XFS_REFCOUNT_FREE_COW:
pmap->pe_flags |= ri->ri_type;
break;
default:
ASSERT(0);
}
}
static struct xfs_log_item *
......@@ -324,21 +320,29 @@ xfs_refcount_update_create_done(
return &cudp->cud_item;
}
/* Take a passive ref to the AG containing the space we're refcounting. */
/* Add this deferred CUI to the transaction. */
void
xfs_refcount_update_get_group(
struct xfs_mount *mp,
xfs_refcount_defer_add(
struct xfs_trans *tp,
struct xfs_refcount_intent *ri)
{
struct xfs_mount *mp = tp->t_mountp;
trace_xfs_refcount_defer(mp, ri);
ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
}
/* Release a passive AG ref after finishing refcounting work. */
static inline void
xfs_refcount_update_put_group(
struct xfs_refcount_intent *ri)
/* Cancel a deferred refcount update. */
STATIC void
xfs_refcount_update_cancel_item(
struct list_head *item)
{
struct xfs_refcount_intent *ri = ci_entry(item);
xfs_perag_intent_put(ri->ri_pag);
kmem_cache_free(xfs_refcount_intent_cache, ri);
}
/* Process a deferred refcount update. */
......@@ -349,11 +353,9 @@ xfs_refcount_update_finish_item(
struct list_head *item,
struct xfs_btree_cur **state)
{
struct xfs_refcount_intent *ri;
struct xfs_refcount_intent *ri = ci_entry(item);
int error;
ri = container_of(item, struct xfs_refcount_intent, ri_list);
/* Did we run out of reservation? Requeue what we didn't finish. */
error = xfs_refcount_finish_one(tp, ri, state);
if (!error && ri->ri_blockcount > 0) {
......@@ -362,30 +364,33 @@ xfs_refcount_update_finish_item(
return -EAGAIN;
}
xfs_refcount_update_put_group(ri);
kmem_cache_free(xfs_refcount_intent_cache, ri);
xfs_refcount_update_cancel_item(item);
return error;
}
/* Abort all pending CUIs. */
/* Clean up after calling xfs_refcount_finish_one. */
STATIC void
xfs_refcount_update_abort_intent(
struct xfs_log_item *intent)
xfs_refcount_finish_one_cleanup(
struct xfs_trans *tp,
struct xfs_btree_cur *rcur,
int error)
{
xfs_cui_release(CUI_ITEM(intent));
struct xfs_buf *agbp;
if (rcur == NULL)
return;
agbp = rcur->bc_ag.agbp;
xfs_btree_del_cursor(rcur, error);
if (error)
xfs_trans_brelse(tp, agbp);
}
/* Cancel a deferred refcount update. */
/* Abort all pending CUIs. */
STATIC void
xfs_refcount_update_cancel_item(
struct list_head *item)
xfs_refcount_update_abort_intent(
struct xfs_log_item *intent)
{
struct xfs_refcount_intent *ri;
ri = container_of(item, struct xfs_refcount_intent, ri_list);
xfs_refcount_update_put_group(ri);
kmem_cache_free(xfs_refcount_intent_cache, ri);
xfs_cui_release(CUI_ITEM(intent));
}
/* Is this recovered CUI ok? */
......@@ -426,7 +431,7 @@ xfs_cui_recover_work(
ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK;
ri->ri_startblock = pmap->pe_startblock;
ri->ri_blockcount = pmap->pe_len;
xfs_refcount_update_get_group(mp, ri);
ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
xfs_defer_add_item(dfp, &ri->ri_list);
}
......
......@@ -71,4 +71,9 @@ struct xfs_cud_log_item {
extern struct kmem_cache *xfs_cui_cache;
extern struct kmem_cache *xfs_cud_cache;
struct xfs_refcount_intent;
void xfs_refcount_defer_add(struct xfs_trans *tp,
struct xfs_refcount_intent *ri);
#endif /* __XFS_REFCOUNT_ITEM_H__ */
......@@ -42,6 +42,7 @@
#include "xfs_exchrange.h"
#include "xfs_parent.h"
#include "xfs_rmap.h"
#include "xfs_refcount.h"
/*
* We include this last to have the helpers above available for the trace
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment