@@ -162,6 +162,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)));
}
@@ -488,10 +488,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;