Skip to content

Commit 649c0c2

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: add a xefi_entry helper
Add a helper to translate from the item list head to the xfs_extent_free_item structure and use it so shorten assignments and avoid the need for extra local variables. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 62d597a commit 649c0c2

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

fs/xfs/xfs_extfree_item.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ static const struct xfs_item_ops xfs_efd_item_ops = {
303303
.iop_intent = xfs_efd_item_intent,
304304
};
305305

306+
static inline struct xfs_extent_free_item *xefi_entry(const struct list_head *e)
307+
{
308+
return list_entry(e, struct xfs_extent_free_item, xefi_list);
309+
}
310+
306311
/*
307312
* Fill the EFD with all extents from the EFI when we need to roll the
308313
* transaction and continue with a new EFI.
@@ -338,11 +343,8 @@ xfs_extent_free_diff_items(
338343
const struct list_head *a,
339344
const struct list_head *b)
340345
{
341-
struct xfs_extent_free_item *ra;
342-
struct xfs_extent_free_item *rb;
343-
344-
ra = container_of(a, struct xfs_extent_free_item, xefi_list);
345-
rb = container_of(b, struct xfs_extent_free_item, xefi_list);
346+
struct xfs_extent_free_item *ra = xefi_entry(a);
347+
struct xfs_extent_free_item *rb = xefi_entry(b);
346348

347349
return ra->xefi_pag->pag_agno - rb->xefi_pag->pag_agno;
348350
}
@@ -444,15 +446,14 @@ xfs_extent_free_finish_item(
444446
struct xfs_btree_cur **state)
445447
{
446448
struct xfs_owner_info oinfo = { };
447-
struct xfs_extent_free_item *xefi;
449+
struct xfs_extent_free_item *xefi = xefi_entry(item);
448450
struct xfs_efd_log_item *efdp = EFD_ITEM(done);
449451
struct xfs_mount *mp = tp->t_mountp;
450452
struct xfs_extent *extp;
451453
uint next_extent;
452454
xfs_agblock_t agbno;
453455
int error = 0;
454456

455-
xefi = container_of(item, struct xfs_extent_free_item, xefi_list);
456457
agbno = XFS_FSB_TO_AGBNO(mp, xefi->xefi_startblock);
457458

458459
oinfo.oi_owner = xefi->xefi_owner;
@@ -504,9 +505,7 @@ STATIC void
504505
xfs_extent_free_cancel_item(
505506
struct list_head *item)
506507
{
507-
struct xfs_extent_free_item *xefi;
508-
509-
xefi = container_of(item, struct xfs_extent_free_item, xefi_list);
508+
struct xfs_extent_free_item *xefi = xefi_entry(item);
510509

511510
xfs_extent_free_put_group(xefi);
512511
kmem_cache_free(xfs_extfree_item_cache, xefi);
@@ -526,14 +525,13 @@ xfs_agfl_free_finish_item(
526525
struct xfs_owner_info oinfo = { };
527526
struct xfs_mount *mp = tp->t_mountp;
528527
struct xfs_efd_log_item *efdp = EFD_ITEM(done);
529-
struct xfs_extent_free_item *xefi;
528+
struct xfs_extent_free_item *xefi = xefi_entry(item);
530529
struct xfs_extent *extp;
531530
struct xfs_buf *agbp;
532531
int error;
533532
xfs_agblock_t agbno;
534533
uint next_extent;
535534

536-
xefi = container_of(item, struct xfs_extent_free_item, xefi_list);
537535
ASSERT(xefi->xefi_blockcount == 1);
538536
agbno = XFS_FSB_TO_AGBNO(mp, xefi->xefi_startblock);
539537
oinfo.oi_owner = xefi->xefi_owner;

0 commit comments

Comments
 (0)