Skip to content

Commit d2fe5c4

Browse files
Dave Chinnercmaiolino
authored andcommitted
xfs: rearrange code in xfs_buf_item.c
The code to initialise, release and free items is all the way down the bottom of the file. Upcoming fixes need to these functions earlier in the file, so move them to the top. There is one code change in this move - the parameter to xfs_buf_item_relse() is changed from the xfs_buf to the xfs_buf_log_item - the thing that the function is releasing. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Carlos Maiolino <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent fc48627 commit d2fe5c4

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

fs/xfs/xfs_buf_item.c

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,61 @@ static inline struct xfs_buf_log_item *BUF_ITEM(struct xfs_log_item *lip)
3232
return container_of(lip, struct xfs_buf_log_item, bli_item);
3333
}
3434

35+
static void
36+
xfs_buf_item_get_format(
37+
struct xfs_buf_log_item *bip,
38+
int count)
39+
{
40+
ASSERT(bip->bli_formats == NULL);
41+
bip->bli_format_count = count;
42+
43+
if (count == 1) {
44+
bip->bli_formats = &bip->__bli_format;
45+
return;
46+
}
47+
48+
bip->bli_formats = kzalloc(count * sizeof(struct xfs_buf_log_format),
49+
GFP_KERNEL | __GFP_NOFAIL);
50+
}
51+
52+
static void
53+
xfs_buf_item_free_format(
54+
struct xfs_buf_log_item *bip)
55+
{
56+
if (bip->bli_formats != &bip->__bli_format) {
57+
kfree(bip->bli_formats);
58+
bip->bli_formats = NULL;
59+
}
60+
}
61+
62+
static void
63+
xfs_buf_item_free(
64+
struct xfs_buf_log_item *bip)
65+
{
66+
xfs_buf_item_free_format(bip);
67+
kvfree(bip->bli_item.li_lv_shadow);
68+
kmem_cache_free(xfs_buf_item_cache, bip);
69+
}
70+
71+
/*
72+
* xfs_buf_item_relse() is called when the buf log item is no longer needed.
73+
*/
74+
static void
75+
xfs_buf_item_relse(
76+
struct xfs_buf_log_item *bip)
77+
{
78+
struct xfs_buf *bp = bip->bli_buf;
79+
80+
trace_xfs_buf_item_relse(bp, _RET_IP_);
81+
82+
ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags));
83+
ASSERT(atomic_read(&bip->bli_refcount) == 0);
84+
85+
bp->b_log_item = NULL;
86+
xfs_buf_rele(bp);
87+
xfs_buf_item_free(bip);
88+
}
89+
3590
/* Is this log iovec plausibly large enough to contain the buffer log format? */
3691
bool
3792
xfs_buf_log_check_iovec(
@@ -468,7 +523,7 @@ xfs_buf_item_unpin(
468523
ASSERT(list_empty(&bp->b_li_list));
469524
} else {
470525
xfs_trans_ail_delete(lip, SHUTDOWN_LOG_IO_ERROR);
471-
xfs_buf_item_relse(bp);
526+
xfs_buf_item_relse(bip);
472527
ASSERT(bp->b_log_item == NULL);
473528
}
474529
xfs_buf_relse(bp);
@@ -578,7 +633,7 @@ xfs_buf_item_put(
578633
*/
579634
if (aborted)
580635
xfs_trans_ail_delete(lip, 0);
581-
xfs_buf_item_relse(bip->bli_buf);
636+
xfs_buf_item_relse(bip);
582637
return true;
583638
}
584639

@@ -729,33 +784,6 @@ static const struct xfs_item_ops xfs_buf_item_ops = {
729784
.iop_push = xfs_buf_item_push,
730785
};
731786

732-
STATIC void
733-
xfs_buf_item_get_format(
734-
struct xfs_buf_log_item *bip,
735-
int count)
736-
{
737-
ASSERT(bip->bli_formats == NULL);
738-
bip->bli_format_count = count;
739-
740-
if (count == 1) {
741-
bip->bli_formats = &bip->__bli_format;
742-
return;
743-
}
744-
745-
bip->bli_formats = kzalloc(count * sizeof(struct xfs_buf_log_format),
746-
GFP_KERNEL | __GFP_NOFAIL);
747-
}
748-
749-
STATIC void
750-
xfs_buf_item_free_format(
751-
struct xfs_buf_log_item *bip)
752-
{
753-
if (bip->bli_formats != &bip->__bli_format) {
754-
kfree(bip->bli_formats);
755-
bip->bli_formats = NULL;
756-
}
757-
}
758-
759787
/*
760788
* Allocate a new buf log item to go with the given buffer.
761789
* Set the buffer's b_log_item field to point to the new
@@ -976,34 +1004,6 @@ xfs_buf_item_dirty_format(
9761004
return false;
9771005
}
9781006

979-
STATIC void
980-
xfs_buf_item_free(
981-
struct xfs_buf_log_item *bip)
982-
{
983-
xfs_buf_item_free_format(bip);
984-
kvfree(bip->bli_item.li_lv_shadow);
985-
kmem_cache_free(xfs_buf_item_cache, bip);
986-
}
987-
988-
/*
989-
* xfs_buf_item_relse() is called when the buf log item is no longer needed.
990-
*/
991-
void
992-
xfs_buf_item_relse(
993-
struct xfs_buf *bp)
994-
{
995-
struct xfs_buf_log_item *bip = bp->b_log_item;
996-
997-
trace_xfs_buf_item_relse(bp, _RET_IP_);
998-
ASSERT(!test_bit(XFS_LI_IN_AIL, &bip->bli_item.li_flags));
999-
1000-
if (atomic_read(&bip->bli_refcount))
1001-
return;
1002-
bp->b_log_item = NULL;
1003-
xfs_buf_rele(bp);
1004-
xfs_buf_item_free(bip);
1005-
}
1006-
10071007
void
10081008
xfs_buf_item_done(
10091009
struct xfs_buf *bp)
@@ -1023,5 +1023,5 @@ xfs_buf_item_done(
10231023
xfs_trans_ail_delete(&bp->b_log_item->bli_item,
10241024
(bp->b_flags & _XBF_LOGRECOVERY) ? 0 :
10251025
SHUTDOWN_CORRUPT_INCORE);
1026-
xfs_buf_item_relse(bp);
1026+
xfs_buf_item_relse(bp->b_log_item);
10271027
}

fs/xfs/xfs_buf_item.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ struct xfs_buf_log_item {
4949

5050
int xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
5151
void xfs_buf_item_done(struct xfs_buf *bp);
52-
void xfs_buf_item_relse(struct xfs_buf *);
5352
bool xfs_buf_item_put(struct xfs_buf_log_item *);
5453
void xfs_buf_item_log(struct xfs_buf_log_item *, uint, uint);
5554
bool xfs_buf_item_dirty_format(struct xfs_buf_log_item *);

0 commit comments

Comments
 (0)