Skip to content

Commit b3b5ff4

Browse files
author
Darrick J. Wong
committed
xfs: reduce the size of struct xfs_extent_free_item
We only use EFIs to free metadata blocks -- not regular data/attr fork extents. Remove all the fields that we never use, for a net reduction of 16 bytes. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Chandan Babu R <[email protected]>
1 parent c201d9c commit b3b5ff4

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,12 +2462,11 @@ xfs_defer_agfl_block(
24622462
ASSERT(xfs_extfree_item_cache != NULL);
24632463
ASSERT(oinfo != NULL);
24642464

2465-
new = kmem_cache_alloc(xfs_extfree_item_cache,
2465+
new = kmem_cache_zalloc(xfs_extfree_item_cache,
24662466
GFP_KERNEL | __GFP_NOFAIL);
24672467
new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
24682468
new->xefi_blockcount = 1;
2469-
new->xefi_oinfo = *oinfo;
2470-
new->xefi_skip_discard = false;
2469+
new->xefi_owner = oinfo->oi_owner;
24712470

24722471
trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
24732472

@@ -2505,15 +2504,23 @@ __xfs_free_extent_later(
25052504
#endif
25062505
ASSERT(xfs_extfree_item_cache != NULL);
25072506

2508-
new = kmem_cache_alloc(xfs_extfree_item_cache,
2507+
new = kmem_cache_zalloc(xfs_extfree_item_cache,
25092508
GFP_KERNEL | __GFP_NOFAIL);
25102509
new->xefi_startblock = bno;
25112510
new->xefi_blockcount = (xfs_extlen_t)len;
2512-
if (oinfo)
2513-
new->xefi_oinfo = *oinfo;
2514-
else
2515-
new->xefi_oinfo = XFS_RMAP_OINFO_SKIP_UPDATE;
2516-
new->xefi_skip_discard = skip_discard;
2511+
if (skip_discard)
2512+
new->xefi_flags |= XFS_EFI_SKIP_DISCARD;
2513+
if (oinfo) {
2514+
ASSERT(oinfo->oi_offset == 0);
2515+
2516+
if (oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK)
2517+
new->xefi_flags |= XFS_EFI_ATTR_FORK;
2518+
if (oinfo->oi_flags & XFS_OWNER_INFO_BMBT_BLOCK)
2519+
new->xefi_flags |= XFS_EFI_BMBT_BLOCK;
2520+
new->xefi_owner = oinfo->oi_owner;
2521+
} else {
2522+
new->xefi_owner = XFS_RMAP_OWN_NULL;
2523+
}
25172524
trace_xfs_bmap_free_defer(tp->t_mountp,
25182525
XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
25192526
XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len);

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,16 @@ void __xfs_free_extent_later(struct xfs_trans *tp, xfs_fsblock_t bno,
258258
*/
259259
struct xfs_extent_free_item {
260260
struct list_head xefi_list;
261+
uint64_t xefi_owner;
261262
xfs_fsblock_t xefi_startblock;/* starting fs block number */
262263
xfs_extlen_t xefi_blockcount;/* number of blocks in extent */
263-
bool xefi_skip_discard;
264-
struct xfs_owner_info xefi_oinfo; /* extent owner */
264+
unsigned int xefi_flags;
265265
};
266266

267+
#define XFS_EFI_SKIP_DISCARD (1U << 0) /* don't issue discard */
268+
#define XFS_EFI_ATTR_FORK (1U << 1) /* freeing attr fork block */
269+
#define XFS_EFI_BMBT_BLOCK (1U << 2) /* freeing bmap btree block */
270+
267271
static inline void
268272
xfs_free_extent_later(
269273
struct xfs_trans *tp,

fs/xfs/xfs_extfree_item.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,20 @@ xfs_extent_free_finish_item(
474474
struct list_head *item,
475475
struct xfs_btree_cur **state)
476476
{
477+
struct xfs_owner_info oinfo = { };
477478
struct xfs_extent_free_item *free;
478479
int error;
479480

480481
free = container_of(item, struct xfs_extent_free_item, xefi_list);
482+
oinfo.oi_owner = free->xefi_owner;
483+
if (free->xefi_flags & XFS_EFI_ATTR_FORK)
484+
oinfo.oi_flags |= XFS_OWNER_INFO_ATTR_FORK;
485+
if (free->xefi_flags & XFS_EFI_BMBT_BLOCK)
486+
oinfo.oi_flags |= XFS_OWNER_INFO_BMBT_BLOCK;
481487
error = xfs_trans_free_extent(tp, EFD_ITEM(done),
482488
free->xefi_startblock,
483489
free->xefi_blockcount,
484-
&free->xefi_oinfo, free->xefi_skip_discard);
490+
&oinfo, free->xefi_flags & XFS_EFI_SKIP_DISCARD);
485491
kmem_cache_free(xfs_extfree_item_cache, free);
486492
return error;
487493
}
@@ -525,6 +531,7 @@ xfs_agfl_free_finish_item(
525531
struct list_head *item,
526532
struct xfs_btree_cur **state)
527533
{
534+
struct xfs_owner_info oinfo = { };
528535
struct xfs_mount *mp = tp->t_mountp;
529536
struct xfs_efd_log_item *efdp = EFD_ITEM(done);
530537
struct xfs_extent_free_item *free;
@@ -539,13 +546,13 @@ xfs_agfl_free_finish_item(
539546
ASSERT(free->xefi_blockcount == 1);
540547
agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock);
541548
agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock);
549+
oinfo.oi_owner = free->xefi_owner;
542550

543551
trace_xfs_agfl_free_deferred(mp, agno, 0, agbno, free->xefi_blockcount);
544552

545553
error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
546554
if (!error)
547-
error = xfs_free_agfl_block(tp, agno, agbno, agbp,
548-
&free->xefi_oinfo);
555+
error = xfs_free_agfl_block(tp, agno, agbno, agbp, &oinfo);
549556

550557
/*
551558
* Mark the transaction dirty, even on error. This ensures the

0 commit comments

Comments
 (0)