Hello to all,
I believe that the blocks used by the free block btrees (BNO + CNT) are
not substracted from the superblock's fdblocks. Except for the roots of
course, which are included in the XFS_PREALLOC_BLOCKS(mp).
Is there a reason for this? Especially since the inode btrees are
substracted... Furthermore, I think this is why a full filesystem
sometime shows a few kb's free - they are actually in the btrees and
can't be used.
How did I got to this result: whenever the level of the trees is > 1,
SUM(agf->agf_freeblks) + SUM(agf->agf_flcount) != sb->sb_fdblocks. How
does this happen? The blocks are allocated using xfs_alloc_get_freelist
which does not modify the superblock counters. The debug checks in
xfs_trans_apply_sb_deltas are ok, because the xfs_alloc_btree.c code
modifies also tp->t_ag_btree_delta and keeps them in sync
(xfs_alloc_get_freelist decrements tp->t_ag_freeblks_delta by 1,
xfs_alloc_split increments tp->t_ag_btree_delta by 1 and thus they
cancel each other).