diff options
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 3ac8ca845239..88faf7fb912d 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -252,8 +252,13 @@ xfs_rtallocate_extent_block( end = XFS_BLOCKTOBIT(mp, bbno + 1) - 1; i <= end; i++) { - /* Make sure we don't scan off the end of the rt volume. */ + /* + * Make sure we don't run off the end of the rt volume. Be + * careful that adjusting maxlen downwards doesn't cause us to + * fail the alignment checks. + */ maxlen = min(mp->m_sb.sb_rextents, i + maxlen) - i; + maxlen -= maxlen % prod; /* * See if there's a free extent of maxlen starting at i. @@ -360,7 +365,8 @@ xfs_rtallocate_extent_exact( int isfree; /* extent is free */ xfs_rtblock_t next; /* next block to try (dummy) */ - ASSERT(minlen % prod == 0 && maxlen % prod == 0); + ASSERT(minlen % prod == 0); + ASSERT(maxlen % prod == 0); /* * Check if the range in question (for maxlen) is free. */ @@ -443,7 +449,9 @@ xfs_rtallocate_extent_near( xfs_rtblock_t n; /* next block to try */ xfs_rtblock_t r; /* result block */ - ASSERT(minlen % prod == 0 && maxlen % prod == 0); + ASSERT(minlen % prod == 0); + ASSERT(maxlen % prod == 0); + /* * If the block number given is off the end, silently set it to * the last block. @@ -451,8 +459,13 @@ xfs_rtallocate_extent_near( if (bno >= mp->m_sb.sb_rextents) bno = mp->m_sb.sb_rextents - 1; - /* Make sure we don't run off the end of the rt volume. */ + /* + * Make sure we don't run off the end of the rt volume. Be careful + * that adjusting maxlen downwards doesn't cause us to fail the + * alignment checks. + */ maxlen = min(mp->m_sb.sb_rextents, bno + maxlen) - bno; + maxlen -= maxlen % prod; if (maxlen < minlen) { *rtblock = NULLRTBLOCK; return 0; @@ -643,7 +656,8 @@ xfs_rtallocate_extent_size( xfs_rtblock_t r; /* result block number */ xfs_suminfo_t sum; /* summary information for extents */ - ASSERT(minlen % prod == 0 && maxlen % prod == 0); + ASSERT(minlen % prod == 0); + ASSERT(maxlen % prod == 0); ASSERT(maxlen != 0); /* |