Commit 04110b30 authored by Darrick J. Wong's avatar Darrick J. Wong Committed by Jialin Zhang
Browse files

xfs: replace inode fork size macros with functions

mainline inclusion
from mainline-v5.19-rc5
commit c01147d9
category: bugfix
bugzilla: 187164, https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c01147d929899f02a0a8b15e406d12784768ca72



--------------------------------

Replace the shouty macros here with typechecked helper functions.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>

conflicts:
	fs/xfs/libxfs/xfs_attr_leaf.c
	fs/xfs/libxfs/xfs_bmap.c
	fs/xfs/libxfs/xfs_bmap_btree.c
	fs/xfs/libxfs/xfs_dir2.c
	fs/xfs/libxfs/xfs_inode_fork.h
	fs/xfs/scrub/symlink.c
	fs/xfs/xfs_itable.c
	fs/xfs/xfs_symlink.c
	fs/xfs/xfs_trace.h

Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 75329220
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -559,7 +559,8 @@ xfs_attr_shortform_bytesfit(
	 * to real extents, or the delalloc conversion will take care of the
	 * literal area rebalancing.
	 */
	if (bytes <= XFS_IFORK_ASIZE(dp))
	if (bytes <= xfs_inode_attr_fork_size(dp))

		return dp->i_d.di_forkoff;

	/*
+3 −3
Original line number Diff line number Diff line
@@ -932,7 +932,7 @@ xfs_bmap_add_attrfork_btree(
	int			stat;		/* newroot status */

	mp = ip->i_mount;
	if (ip->i_df.if_broot_bytes <= XFS_IFORK_DSIZE(ip))
	if (ip->i_df.if_broot_bytes <= xfs_inode_data_fork_size(ip))
		*flags |= XFS_ILOG_DBROOT;
	else {
		cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
@@ -972,7 +972,7 @@ xfs_bmap_add_attrfork_extents(
	int			error;		/* error return value */

	if (ip->i_df.if_nextents * sizeof(struct xfs_bmbt_rec) <=
	    XFS_IFORK_DSIZE(ip))
	    xfs_inode_data_fork_size(ip))
		return 0;
	cur = NULL;
	error = xfs_bmap_extents_to_btree(tp, ip, &cur, 0, flags,
@@ -1003,7 +1003,7 @@ xfs_bmap_add_attrfork_local(
{
	struct xfs_da_args	dargs;		/* args for dir/attr code */

	if (ip->i_df.if_bytes <= XFS_IFORK_DSIZE(ip))
	if (ip->i_df.if_bytes <= xfs_inode_data_fork_size(ip))
		return 0;

	if (S_ISDIR(VFS_I(ip)->i_mode)) {
+1 −1
Original line number Diff line number Diff line
@@ -566,7 +566,7 @@ xfs_bmbt_init_cursor(
	if (xfs_sb_version_hascrc(&mp->m_sb))
		cur->bc_flags |= XFS_BTREE_CRC_BLOCKS;

	cur->bc_ino.forksize = XFS_IFORK_SIZE(ip, whichfork);
	cur->bc_ino.forksize = xfs_inode_fork_size(ip, whichfork);
	cur->bc_ino.ip = ip;
	cur->bc_ino.allocated = 0;
	cur->bc_ino.flags = 0;
+2 −1
Original line number Diff line number Diff line
@@ -181,7 +181,8 @@ xfs_dir_isempty(
	ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
	if (dp->i_d.di_size == 0)	/* might happen during shutdown. */
		return 1;
	if (dp->i_d.di_size > XFS_IFORK_DSIZE(dp))
	if (dp->i_d.di_size > xfs_inode_data_fork_size(dp))

		return 0;
	sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data;
	return !sfp->count;
+2 −2
Original line number Diff line number Diff line
@@ -842,7 +842,7 @@ xfs_dir2_block_removename(
	 * See if the size as a shortform is good enough.
	 */
	size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
	if (size > XFS_IFORK_DSIZE(dp))
	if (size > xfs_inode_data_fork_size(dp))
		return 0;

	/*
@@ -1055,7 +1055,7 @@ xfs_dir2_leaf_to_block(
	 * Now see if the resulting block can be shrunken to shortform.
	 */
	size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
	if (size > XFS_IFORK_DSIZE(dp))
	if (size > xfs_inode_data_fork_size(dp))
		return 0;

	return xfs_dir2_block_to_sf(args, dbp, size, &sfh);
Loading