/* Helper routine to reset inode di_forkoff field when switching attribute fork from local to extent format - we reset it where possible to make space available for inline data fork extents.  */
STATIC void xfs_bmap_forkoff_reset(xfs_mount_t *mp, xfs_inode_t *ip, int whichfork)
/* Helper routine to reset inode di_forkoff field when switching attribute fork from local to extent format - we reset it where possible to make space available for inline data fork extents.  */
STATIC void xfs_bmap_forkoff_reset(xfs_mount_t *mp, xfs_inode_t *ip, int whichfork)
{
	if (whichfork == XFS_ATTR_FORK &&
	    ip->i_d.di_format != XFS_DINODE_FMT_DEV &&
	    ip->i_d.di_format != XFS_DINODE_FMT_UUID &&
	    ip->i_d.di_format != XFS_DINODE_FMT_BTREE) {
		uint	dfl_forkoff = xfs_default_attroffset(ip) >> 3;
		if (dfl_forkoff > ip->i_d.di_forkoff) {
			ip->i_d.di_forkoff = dfl_forkoff;
			ip->i_df.if_ext_max =
				XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t);
			ip->i_afp->if_ext_max =
				XFS_IFORK_ASIZE(ip) / sizeof(xfs_bmbt_rec_t);
		}
	}
}