diff options
author | Darrick J. Wong <djwong@kernel.org> | 2021-01-05 17:45:39 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2021-03-25 17:08:38 -0700 |
commit | 47ee2ab0e71275a13bab852539bf06df873bbc89 (patch) | |
tree | 991719e95de8528c3af15dc97497ebc9f3496c51 | |
parent | b83122765390a610681a4b07a643d513108e9b40 (diff) |
xfs: move the zero records logic into xfs_bmap_broot_space_calc
The bmap btree cannot ever have zero records in an incore btree block.
If the number of records drops to zero, that means we're converting the
fork to extents format and are trying to remove the tree. This logic
won't hold for the future realtime rmap btree, so move the logic into
the bmbt code.
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap_btree.h | 7 | ||||
-rw-r--r-- | fs/xfs/libxfs/xfs_inode_fork.c | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.h b/fs/xfs/libxfs/xfs_bmap_btree.h index 59b8620bc61b..b189fc2024e9 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.h +++ b/fs/xfs/libxfs/xfs_bmap_btree.h @@ -157,6 +157,13 @@ xfs_bmap_broot_space_calc( struct xfs_mount *mp, unsigned int nrecs) { + /* + * If the bmbt root block is empty, we should be converting the fork + * to extents format. Hence, the size is zero. + */ + if (nrecs == 0) + return 0; + return xfs_bmbt_block_len(mp) + \ (nrecs * (sizeof(struct xfs_bmbt_key) + sizeof(xfs_bmbt_ptr_t))); } diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 9555e5de2fcc..ec1605c92a1d 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -478,10 +478,8 @@ xfs_iroot_realloc( cur_max = xfs_bmbt_maxrecs(mp, old_size, 0); new_max = cur_max + rec_diff; ASSERT(new_max >= 0); - if (new_max > 0) - new_size = xfs_bmap_broot_space_calc(mp, new_max); - else - new_size = 0; + + new_size = xfs_bmap_broot_space_calc(mp, new_max); if (new_size == 0) { xfs_iroot_free(ip, whichfork); return; |