From: Darrick J. Wong Date: Fri, 17 Feb 2023 23:45:51 +0000 (-0800) Subject: xfs: restore old agirotor behavior X-Git-Tag: libxfs-sync-6.3_2023-04-05~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cd1faa10b9c99de893e9738323810fc978941648;p=xfsprogs-dev.git xfs: restore old agirotor behavior Source kernel commit: 127c6534882090d848652a723b436eaef90fce53 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: 20a5eab49d35 ("xfs: convert xfs_ialloc_next_ag() to an atomic") Signed-off-by: Darrick J. Wong --- diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c index 791880a3..50ffa820 100644 --- a/libxfs/xfs_ialloc.c +++ b/libxfs/xfs_ialloc.c @@ -1724,7 +1724,8 @@ xfs_dialloc( * an AG has enough space for file creation. */ 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 { start_agno = XFS_INO_TO_AGNO(mp, parent); if (start_agno >= mp->m_maxagi)