diff options
author | Carlos Maiolino <cmaiolino@redhat.com> | 2012-09-20 09:32:36 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-09-26 16:42:42 -0400 |
commit | 8aea3ff411b2ce8fe7b46644298ed243a920eb24 (patch) | |
tree | 19a8f40bf1f8b8f48d1d77d29fb87020d8c17f81 /fs | |
parent | c3a58fecdd1934a8538ada9073107625f5151687 (diff) |
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: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 5aceb3f8ecd6..445bf1aef31c 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -431,7 +431,7 @@ xfs_ialloc_next_ag( | |||
431 | 431 | ||
432 | spin_lock(&mp->m_agirotor_lock); | 432 | spin_lock(&mp->m_agirotor_lock); |
433 | agno = mp->m_agirotor; | 433 | agno = mp->m_agirotor; |
434 | if (++mp->m_agirotor == mp->m_maxagi) | 434 | if (++mp->m_agirotor >= mp->m_maxagi) |
435 | mp->m_agirotor = 0; | 435 | mp->m_agirotor = 0; |
436 | spin_unlock(&mp->m_agirotor_lock); | 436 | spin_unlock(&mp->m_agirotor_lock); |
437 | 437 | ||