diff options
| -rw-r--r-- | fs/xfs/libxfs/xfs_alloc.c | 15 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_btree.c | 19 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_btree.h | 2 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_ialloc.c | 19 |
4 files changed, 28 insertions, 27 deletions
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 638657a91335..e56991d1a970 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c | |||
| @@ -1839,19 +1839,8 @@ void | |||
| 1839 | xfs_alloc_compute_maxlevels( | 1839 | xfs_alloc_compute_maxlevels( |
| 1840 | xfs_mount_t *mp) /* file system mount structure */ | 1840 | xfs_mount_t *mp) /* file system mount structure */ |
| 1841 | { | 1841 | { |
| 1842 | int level; | 1842 | mp->m_ag_maxlevels = xfs_btree_compute_maxlevels(mp, mp->m_alloc_mnr, |
| 1843 | uint maxblocks; | 1843 | (mp->m_sb.sb_agblocks + 1) / 2); |
| 1844 | uint maxleafents; | ||
| 1845 | int minleafrecs; | ||
| 1846 | int minnoderecs; | ||
| 1847 | |||
| 1848 | maxleafents = (mp->m_sb.sb_agblocks + 1) / 2; | ||
| 1849 | minleafrecs = mp->m_alloc_mnr[0]; | ||
| 1850 | minnoderecs = mp->m_alloc_mnr[1]; | ||
| 1851 | maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; | ||
| 1852 | for (level = 1; maxblocks > 1; level++) | ||
| 1853 | maxblocks = (maxblocks + minnoderecs - 1) / minnoderecs; | ||
| 1854 | mp->m_ag_maxlevels = level; | ||
| 1855 | } | 1844 | } |
| 1856 | 1845 | ||
| 1857 | /* | 1846 | /* |
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 1f88e1ce770f..a6779b3e873c 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
| @@ -4152,3 +4152,22 @@ xfs_btree_sblock_verify( | |||
| 4152 | 4152 | ||
| 4153 | return true; | 4153 | return true; |
| 4154 | } | 4154 | } |
| 4155 | |||
| 4156 | /* | ||
| 4157 | * Calculate the number of btree levels needed to store a given number of | ||
| 4158 | * records in a short-format btree. | ||
| 4159 | */ | ||
| 4160 | uint | ||
| 4161 | xfs_btree_compute_maxlevels( | ||
| 4162 | struct xfs_mount *mp, | ||
| 4163 | uint *limits, | ||
| 4164 | unsigned long len) | ||
| 4165 | { | ||
| 4166 | uint level; | ||
| 4167 | unsigned long maxblocks; | ||
| 4168 | |||
| 4169 | maxblocks = (len + limits[0] - 1) / limits[0]; | ||
| 4170 | for (level = 1; maxblocks > 1; level++) | ||
| 4171 | maxblocks = (maxblocks + limits[1] - 1) / limits[1]; | ||
| 4172 | return level; | ||
| 4173 | } | ||
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index 2e874be70209..785a99682159 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h | |||
| @@ -474,5 +474,7 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block) | |||
| 474 | 474 | ||
| 475 | bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp); | 475 | bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp); |
| 476 | bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs); | 476 | bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs); |
| 477 | uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits, | ||
| 478 | unsigned long len); | ||
| 477 | 479 | ||
| 478 | #endif /* __XFS_BTREE_H__ */ | 480 | #endif /* __XFS_BTREE_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index e3c0af73cf94..4b1e408169a8 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c | |||
| @@ -2394,20 +2394,11 @@ void | |||
| 2394 | xfs_ialloc_compute_maxlevels( | 2394 | xfs_ialloc_compute_maxlevels( |
| 2395 | xfs_mount_t *mp) /* file system mount structure */ | 2395 | xfs_mount_t *mp) /* file system mount structure */ |
| 2396 | { | 2396 | { |
| 2397 | int level; | 2397 | uint inodes; |
| 2398 | uint maxblocks; | 2398 | |
| 2399 | uint maxleafents; | 2399 | inodes = (1LL << XFS_INO_AGINO_BITS(mp)) >> XFS_INODES_PER_CHUNK_LOG; |
| 2400 | int minleafrecs; | 2400 | mp->m_in_maxlevels = xfs_btree_compute_maxlevels(mp, mp->m_inobt_mnr, |
| 2401 | int minnoderecs; | 2401 | inodes); |
| 2402 | |||
| 2403 | maxleafents = (1LL << XFS_INO_AGINO_BITS(mp)) >> | ||
| 2404 | XFS_INODES_PER_CHUNK_LOG; | ||
| 2405 | minleafrecs = mp->m_inobt_mnr[0]; | ||
| 2406 | minnoderecs = mp->m_inobt_mnr[1]; | ||
| 2407 | maxblocks = (maxleafents + minleafrecs - 1) / minleafrecs; | ||
| 2408 | for (level = 1; maxblocks > 1; level++) | ||
| 2409 | maxblocks = (maxblocks + minnoderecs - 1) / minnoderecs; | ||
| 2410 | mp->m_in_maxlevels = level; | ||
| 2411 | } | 2402 | } |
| 2412 | 2403 | ||
| 2413 | /* | 2404 | /* |
