Skip to content

Commit 062efdb

Browse files
dgchinnerdchinner
authored andcommitted
xfs: combine iunlink inode update functions
Combine the logging of the inode unlink list update into the calling function that looks up the buffer we end up logging. These do not need to be separate functions as they are both short, simple operations and there's only a single call path through them. This new function will end up being the core of the iunlink log item processing... Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
1 parent 5301f87 commit 062efdb

1 file changed

Lines changed: 16 additions & 36 deletions

File tree

fs/xfs/xfs_inode.c

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,38 +1905,9 @@ xfs_iunlink_update_bucket(
19051905
return 0;
19061906
}
19071907

1908-
/* Set an on-disk inode's next_unlinked pointer. */
1909-
STATIC void
1910-
xfs_iunlink_update_dinode(
1911-
struct xfs_trans *tp,
1912-
struct xfs_perag *pag,
1913-
xfs_agino_t agino,
1914-
struct xfs_buf *ibp,
1915-
struct xfs_dinode *dip,
1916-
struct xfs_imap *imap,
1917-
xfs_agino_t next_agino)
1918-
{
1919-
struct xfs_mount *mp = tp->t_mountp;
1920-
int offset;
1921-
1922-
ASSERT(xfs_verify_agino_or_null(pag, next_agino));
1923-
1924-
trace_xfs_iunlink_update_dinode(mp, pag->pag_agno, agino,
1925-
be32_to_cpu(dip->di_next_unlinked), next_agino);
1926-
1927-
dip->di_next_unlinked = cpu_to_be32(next_agino);
1928-
offset = imap->im_boffset +
1929-
offsetof(struct xfs_dinode, di_next_unlinked);
1930-
1931-
/* need to recalc the inode CRC if appropriate */
1932-
xfs_dinode_calc_crc(mp, dip);
1933-
xfs_trans_inode_buf(tp, ibp);
1934-
xfs_trans_log_buf(tp, ibp, offset, offset + sizeof(xfs_agino_t) - 1);
1935-
}
1936-
19371908
/* Set an in-core inode's unlinked pointer and return the old value. */
19381909
static int
1939-
xfs_iunlink_update_inode(
1910+
xfs_iunlink_log_inode(
19401911
struct xfs_trans *tp,
19411912
struct xfs_inode *ip,
19421913
struct xfs_perag *pag,
@@ -1946,6 +1917,7 @@ xfs_iunlink_update_inode(
19461917
struct xfs_dinode *dip;
19471918
struct xfs_buf *ibp;
19481919
xfs_agino_t old_value;
1920+
int offset;
19491921
int error;
19501922

19511923
ASSERT(xfs_verify_agino_or_null(pag, next_agino));
@@ -1979,9 +1951,17 @@ xfs_iunlink_update_inode(
19791951
goto out;
19801952
}
19811953

1982-
/* Ok, update the new pointer. */
1983-
xfs_iunlink_update_dinode(tp, pag, XFS_INO_TO_AGINO(mp, ip->i_ino),
1984-
ibp, dip, &ip->i_imap, next_agino);
1954+
trace_xfs_iunlink_update_dinode(mp, pag->pag_agno,
1955+
XFS_INO_TO_AGINO(mp, ip->i_ino),
1956+
be32_to_cpu(dip->di_next_unlinked), next_agino);
1957+
1958+
dip->di_next_unlinked = cpu_to_be32(next_agino);
1959+
offset = ip->i_imap.im_boffset +
1960+
offsetof(struct xfs_dinode, di_next_unlinked);
1961+
1962+
xfs_dinode_calc_crc(mp, dip);
1963+
xfs_trans_inode_buf(tp, ibp);
1964+
xfs_trans_log_buf(tp, ibp, offset, offset + sizeof(xfs_agino_t) - 1);
19851965
return 0;
19861966
out:
19871967
xfs_trans_brelse(tp, ibp);
@@ -2027,7 +2007,7 @@ xfs_iunlink_insert_inode(
20272007
* There is already another inode in the bucket, so point this
20282008
* inode to the current head of the list.
20292009
*/
2030-
error = xfs_iunlink_update_inode(tp, ip, pag, next_agino);
2010+
error = xfs_iunlink_log_inode(tp, ip, pag, next_agino);
20312011
if (error)
20322012
return error;
20332013
ip->i_next_unlinked = next_agino;
@@ -2103,7 +2083,7 @@ xfs_iunlink_remove_inode(
21032083
* the old pointer value so that we can update whatever was previous
21042084
* to us in the list to point to whatever was next in the list.
21052085
*/
2106-
error = xfs_iunlink_update_inode(tp, ip, pag, NULLAGINO);
2086+
error = xfs_iunlink_log_inode(tp, ip, pag, NULLAGINO);
21072087
if (error)
21082088
return error;
21092089

@@ -2123,7 +2103,7 @@ xfs_iunlink_remove_inode(
21232103
if (!prev_ip)
21242104
return -EFSCORRUPTED;
21252105

2126-
error = xfs_iunlink_update_inode(tp, prev_ip, pag,
2106+
error = xfs_iunlink_log_inode(tp, prev_ip, pag,
21272107
ip->i_next_unlinked);
21282108
prev_ip->i_next_unlinked = ip->i_next_unlinked;
21292109
} else {

0 commit comments

Comments
 (0)