Commit b2941046 authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong
Browse files

xfs: precalculate default inode attribute offset



Default attr fork offset is based on inode size, so is a fixed
geometry parameter of the inode. Move it to the xfs_ino_geometry
structure and stop calculating it on every call to
xfs_default_attroffset().

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Tested-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
parent 683ec9ba
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -94,6 +94,15 @@ xfs_bmap_compute_maxlevels(
	mp->m_bm_maxlevels[whichfork] = level;
}

unsigned int
xfs_bmap_compute_attr_offset(
	struct xfs_mount	*mp)
{
	if (mp->m_sb.sb_inodesize == 256)
		return XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
	return XFS_BMDR_SPACE_CALC(6 * MINABTPTRS);
}

STATIC int				/* error */
xfs_bmbt_lookup_eq(
	struct xfs_btree_cur	*cur,
@@ -192,19 +201,9 @@ uint
xfs_default_attroffset(
	struct xfs_inode	*ip)
{
	struct xfs_mount	*mp = ip->i_mount;
	uint			offset;

	if (ip->i_df.if_format == XFS_DINODE_FMT_DEV)
		return roundup(sizeof(xfs_dev_t), 8);

	if (mp->m_sb.sb_inodesize == 256)
		offset = XFS_LITINO(mp) - XFS_BMDR_SPACE_CALC(MINABTPTRS);
	else
		offset = XFS_BMDR_SPACE_CALC(6 * MINABTPTRS);

	ASSERT(offset < XFS_LITINO(mp));
	return offset;
	return M_IGEO(ip->i_mount)->attr_fork_offset;
}

/*
+1 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ static inline bool xfs_bmap_is_written_extent(struct xfs_bmbt_irec *irec)

void	xfs_trim_extent(struct xfs_bmbt_irec *irec, xfs_fileoff_t bno,
		xfs_filblks_t len);
unsigned int xfs_bmap_compute_attr_offset(struct xfs_mount *mp);
int	xfs_bmap_add_attrfork(struct xfs_inode *ip, int size, int rsvd);
int	xfs_bmap_set_attrforkoff(struct xfs_inode *ip, int size, int *version);
void	xfs_bmap_local_to_extents_empty(struct xfs_trans *tp,
+4 −0
Original line number Diff line number Diff line
@@ -176,8 +176,12 @@ struct xfs_ino_geometry {

	unsigned int	agino_log;	/* #bits for agino in inum */

	/* precomputed default inode attribute fork offset */
	unsigned int	attr_fork_offset;

	/* precomputed value for di_flags2 */
	uint64_t	new_diflags2;

};

#endif /* __XFS_SHARED_H__ */
+13 −1
Original line number Diff line number Diff line
@@ -675,6 +675,18 @@ xfs_unmount_flush_inodes(
	xfs_health_unmount(mp);
}

static void
xfs_mount_setup_inode_geom(
	struct xfs_mount	*mp)
{
	struct xfs_ino_geometry *igeo = M_IGEO(mp);

	igeo->attr_fork_offset = xfs_bmap_compute_attr_offset(mp);
	ASSERT(igeo->attr_fork_offset < XFS_LITINO(mp));

	xfs_ialloc_setup_geometry(mp);
}

/*
 * This function does the following on an initial mount of a file system:
 *	- reads the superblock from disk and init the mount struct
@@ -758,7 +770,7 @@ xfs_mountfs(
	xfs_alloc_compute_maxlevels(mp);
	xfs_bmap_compute_maxlevels(mp, XFS_DATA_FORK);
	xfs_bmap_compute_maxlevels(mp, XFS_ATTR_FORK);
	xfs_ialloc_setup_geometry(mp);
	xfs_mount_setup_inode_geom(mp);
	xfs_rmapbt_compute_maxlevels(mp);
	xfs_refcountbt_compute_maxlevels(mp);