Skip to content

Commit

Permalink
xfs: hoist xfs_trans_add_item calls to defer ops functions
Browse files Browse the repository at this point in the history
Remove even more repeated boilerplate.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Darrick J. Wong committed Dec 7, 2023
1 parent 3e0958b commit b28852a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
7 changes: 6 additions & 1 deletion fs/xfs/libxfs/xfs_defer.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "xfs_da_format.h"
#include "xfs_da_btree.h"
#include "xfs_attr.h"
#include "xfs_trans_priv.h"

static struct kmem_cache *xfs_defer_pending_cache;

Expand Down Expand Up @@ -213,6 +214,7 @@ xfs_defer_create_done(
return;

tp->t_flags |= XFS_TRANS_HAS_INTENT_DONE;
xfs_trans_add_item(tp, lip);
set_bit(XFS_LI_DIRTY, &lip->li_flags);
dfp->dfp_done = lip;
}
Expand Down Expand Up @@ -241,6 +243,7 @@ xfs_defer_create_intent(
return PTR_ERR(lip);

tp->t_flags |= XFS_TRANS_DIRTY;
xfs_trans_add_item(tp, lip);
set_bit(XFS_LI_DIRTY, &lip->li_flags);
dfp->dfp_intent = lip;
return 1;
Expand Down Expand Up @@ -506,8 +509,10 @@ xfs_defer_relog(
xfs_defer_create_done(*tpp, dfp);
lip = xfs_trans_item_relog(dfp->dfp_intent, dfp->dfp_done,
*tpp);
if (lip)
if (lip) {
xfs_trans_add_item(*tpp, lip);
set_bit(XFS_LI_DIRTY, &lip->li_flags);
}
dfp->dfp_done = NULL;
dfp->dfp_intent = lip;
}
Expand Down
4 changes: 0 additions & 4 deletions fs/xfs/xfs_attr_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ xfs_attr_create_intent(
}

attrip = xfs_attri_init(mp, attr->xattri_nameval);
xfs_trans_add_item(tp, &attrip->attri_item);
xfs_attr_log_item(tp, attrip, attr);

return &attrip->attri_item;
Expand Down Expand Up @@ -654,8 +653,6 @@ xfs_attri_item_relog(
new_attrp->alfi_name_len = old_attrp->alfi_name_len;
new_attrp->alfi_attr_filter = old_attrp->alfi_attr_filter;

xfs_trans_add_item(tp, &new_attrip->attri_item);

return &new_attrip->attri_item;
}

Expand Down Expand Up @@ -753,7 +750,6 @@ xfs_trans_get_attrd(struct xfs_trans *tp,
attrdp->attrd_attrip = attrip;
attrdp->attrd_format.alfd_alf_id = attrip->attri_format.alfi_id;

xfs_trans_add_item(tp, &attrdp->attrd_item);
return attrdp;
}

Expand Down
3 changes: 0 additions & 3 deletions fs/xfs/xfs_bmap_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ xfs_trans_get_bud(
budp->bud_buip = buip;
budp->bud_format.bud_bui_id = buip->bui_format.bui_id;

xfs_trans_add_item(tp, &budp->bud_item);
return budp;
}

Expand Down Expand Up @@ -315,7 +314,6 @@ xfs_bmap_update_create_intent(

ASSERT(count == XFS_BUI_MAX_FAST_EXTENTS);

xfs_trans_add_item(tp, &buip->bui_item);
if (sort)
list_sort(mp, items, xfs_bmap_update_diff_items);
list_for_each_entry(bi, items, bi_list)
Expand Down Expand Up @@ -585,7 +583,6 @@ xfs_bui_item_relog(
buip = xfs_bui_init(tp->t_mountp);
memcpy(buip->bui_format.bui_extents, map, count * sizeof(*map));
atomic_set(&buip->bui_next_extent, count);
xfs_trans_add_item(tp, &buip->bui_item);

return &buip->bui_item;
}
Expand Down
3 changes: 0 additions & 3 deletions fs/xfs/xfs_extfree_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ xfs_trans_get_efd(
efdp->efd_format.efd_nextents = nextents;
efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;

xfs_trans_add_item(tp, &efdp->efd_item);
return efdp;
}

Expand Down Expand Up @@ -415,7 +414,6 @@ xfs_extent_free_create_intent(

ASSERT(count > 0);

xfs_trans_add_item(tp, &efip->efi_item);
if (sort)
list_sort(mp, items, xfs_extent_free_diff_items);
list_for_each_entry(xefi, items, xefi_list)
Expand Down Expand Up @@ -708,7 +706,6 @@ xfs_efi_item_relog(
efip = xfs_efi_init(tp->t_mountp, count);
memcpy(efip->efi_format.efi_extents, extp, count * sizeof(*extp));
atomic_set(&efip->efi_next_extent, count);
xfs_trans_add_item(tp, &efip->efi_item);

return &efip->efi_item;
}
Expand Down
3 changes: 0 additions & 3 deletions fs/xfs/xfs_refcount_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ xfs_trans_get_cud(
cudp->cud_cuip = cuip;
cudp->cud_format.cud_cui_id = cuip->cui_format.cui_id;

xfs_trans_add_item(tp, &cudp->cud_item);
return cudp;
}

Expand Down Expand Up @@ -315,7 +314,6 @@ xfs_refcount_update_create_intent(

ASSERT(count > 0);

xfs_trans_add_item(tp, &cuip->cui_item);
if (sort)
list_sort(mp, items, xfs_refcount_update_diff_items);
list_for_each_entry(ri, items, ri_list)
Expand Down Expand Up @@ -546,7 +544,6 @@ xfs_cui_item_relog(
cuip = xfs_cui_init(tp->t_mountp, count);
memcpy(cuip->cui_format.cui_extents, pmap, count * sizeof(*pmap));
atomic_set(&cuip->cui_next_extent, count);
xfs_trans_add_item(tp, &cuip->cui_item);

return &cuip->cui_item;
}
Expand Down
3 changes: 0 additions & 3 deletions fs/xfs/xfs_rmap_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ xfs_trans_get_rud(
rudp->rud_ruip = ruip;
rudp->rud_format.rud_rui_id = ruip->rui_format.rui_id;

xfs_trans_add_item(tp, &rudp->rud_item);
return rudp;
}

Expand Down Expand Up @@ -340,7 +339,6 @@ xfs_rmap_update_create_intent(

ASSERT(count > 0);

xfs_trans_add_item(tp, &ruip->rui_item);
if (sort)
list_sort(mp, items, xfs_rmap_update_diff_items);
list_for_each_entry(ri, items, ri_list)
Expand Down Expand Up @@ -599,7 +597,6 @@ xfs_rui_item_relog(
ruip = xfs_rui_init(tp->t_mountp, count);
memcpy(ruip->rui_format.rui_extents, map, count * sizeof(*map));
atomic_set(&ruip->rui_next_extent, count);
xfs_trans_add_item(tp, &ruip->rui_item);

return &ruip->rui_item;
}
Expand Down

0 comments on commit b28852a

Please sign in to comment.