Commit 8aea3ff4 authored by Carlos Maiolino's avatar Carlos Maiolino Committed by Ben Myers

xfs: Fix m_agirotor reset during AG selection

xfs_ialloc_next_ag() currently resets m_agirotor when it is equal to
m_maxagi:

         if (++mp->m_agirotor == mp->m_maxagi)
	         mp->m_agirotor = 0;

But, if for some reason mp->m_maxagi changes to a lower value than
current m_agirotor, this condition will never be true, causing
m_agirotor to exceed the maximum allowed value (m_maxagi).

This implies mainly during lookups for xfs_perag structs in its radix
tree, since the agno value used for the lookup is based on m_agirotor.
An out-of-range m_agirotor may cause a lookup failure which in case will
return NULL.

As an example, the value of m_maxagi is decreased during
inode64->inode32 remount process, case where I've found this problem.
Signed-off-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent c3a58fec
...@@ -431,7 +431,7 @@ xfs_ialloc_next_ag( ...@@ -431,7 +431,7 @@ xfs_ialloc_next_ag(
spin_lock(&mp->m_agirotor_lock); spin_lock(&mp->m_agirotor_lock);
agno = mp->m_agirotor; agno = mp->m_agirotor;
if (++mp->m_agirotor == mp->m_maxagi) if (++mp->m_agirotor >= mp->m_maxagi)
mp->m_agirotor = 0; mp->m_agirotor = 0;
spin_unlock(&mp->m_agirotor_lock); spin_unlock(&mp->m_agirotor_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment