Skip to contentSkip to conversation

xfs: restore old agirotor behavior

PATCH In review Darrick J. Wong 2 participants 3 messages Feb 22, 2023 – Feb 27, 2023 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: restore old agirotor behavior

From: Darrick J. Wong <[email protected]>

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")
---
 fs/xfs/libxfs/xfs_ialloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_ialloc.c +1 -1
index 65832c74e86c..550c6351e9b6 100644
@@ -1729,7 +1729,7 @@ 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)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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")
---
 fs/xfs/libxfs/xfs_ialloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_ialloc.c +0 -0
index 65832c74e86c..550c6351e9b6 100644

fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc( · line 1735

Quoted 8 lines
fs/xfs/libxfs/xfs_ialloc.c +1 -1
@@ -1729,7 +1729,7 @@ 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)

Change is fine, but it pushes the code to 85 columns. If you clean it up to:

	if (S_ISDIR(mode)) {
		start_agno = (atomic_inc_return(&mp->m_agirotor) - 1) %
				mp->m_maxagi;
	} else {
		....

Then you can add:

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 37 lines · Dave Chinner
Quoted 18 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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")
---
 fs/xfs/libxfs/xfs_ialloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_ialloc.c +0 -0
index 65832c74e86c..550c6351e9b6 100644

fs/xfs/libxfs/xfs_ialloc.c xfs_dialloc( · line 1735

Quoted 8 lines
fs/xfs/libxfs/xfs_ialloc.c +1 -1
@@ -1729,7 +1729,7 @@ 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)

Change is fine, but it pushes the code to 85 columns. If you clean it up to:

	if (S_ISDIR(mode)) {
		start_agno = (atomic_inc_return(&mp->m_agirotor) - 1) %
				mp->m_maxagi;
	} else {
		....
Quoted 3 lines

Then you can add:

Thanks, merged with tweaks!

--D

Quoted 4 lines
Signature · 3 lines
-- 
Dave Chinner
[email protected]