Commit 6e2985c9 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: restore old agirotor behavior



Prior to the removal of xfs_ialloc_next_ag, we would increment the agi
rotor and return the *old* value.  atomic_inc_return returns the new
value, which causes mkfs to allocate the root directory in AG 1.  Put
back the old behavior (at least for mkfs) by subtracting 1 here.

Fixes: 20a5eab4 ("xfs: convert xfs_ialloc_next_ag() to an atomic")
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 60b730a4
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1729,7 +1729,8 @@ xfs_dialloc(
	 * an AG has enough space for file creation.
	 * an AG has enough space for file creation.
	 */
	 */
	if (S_ISDIR(mode))
	if (S_ISDIR(mode))
		start_agno = atomic_inc_return(&mp->m_agirotor) % mp->m_maxagi;
		start_agno = (atomic_inc_return(&mp->m_agirotor) - 1) %
				mp->m_maxagi;
	else {
	else {
		start_agno = XFS_INO_TO_AGNO(mp, parent);
		start_agno = XFS_INO_TO_AGNO(mp, parent);
		if (start_agno >= mp->m_maxagi)
		if (start_agno >= mp->m_maxagi)