2023 Edit: This script seemed to work with a freshly made pool, but doesn’t seem to work with my pool which is now more “mature” and has more data on the special vdevs than this script reports. As such this script should be considered ultimately inaccurate until I have time far in the future to figure out what it’s missing.
2022 Original Post: Ok so I think I’ve got something “close enough” that should tell you how much pure metadata a pool has. A special thanks to @rcxb and @oO.o for their help here: The small linux problem thread - #4956 by rcxb
//Generate zdb output file so we only have to run a slow command once:
zdb -PLbbbs kpool | tee ~/kpool_metadata_output.txt
//Sum only the relevent numbers from the ASIZE column, removing rows with redundant numbers or things that aren’t metadata. Hopefully I got everything.
(
cat ~/kpool_metadata_output.txt \
| grep -B 9999 'L1 Total' \
| grep -A 9999 'ASIZE' \
| grep -v \
-e 'L1 object array' -e 'L0 object array' \
-e 'L1 bpobj' -e 'L0 bpobj' \
-e 'L2 SPA space map' -e 'L1 SPA space map' -e 'L0 SPA space map' \
-e 'L5 DMU dnode' -e 'L4 DMU dnode' -e 'L3 DMU dnode' -e 'L2 DMU dnode' -e 'L1 DMU dnode' -e 'L0 DMU dnode' \
-e 'L0 ZFS plain file' -e 'ZFS plain file' \
-e 'L2 ZFS directory' -e 'L1 ZFS directory' -e 'L0 ZFS directory' \
-e 'L3 zvol object' -e 'L2 zvol object' -e 'L1 zvol object' -e 'L0 zvol object' \
-e 'L1 SPA history' -e 'L0 SPA history' \
-e 'L1 deferred free' -e 'L0 deferred free' \
| awk \
'{sum+=$4} \
END {printf "\nTotal Metadata\n %.0f Bytes\n" " %.2f GiB\n",sum,sum/1073741824}' \
)
Output
Total Metadata
57844416512 Bytes
53.87 GiB
Which is close enough to the 53.2G Allocated that zpool list kpool -v gives me. It is possible that all of my metadata might not actually be in the special vdev. If anyone finds any errors let me know. Your metadata being over a TiB is a good indication the script is counting something it shouldn’t.
So that combined with my findings here about the “new” histogram that shows up with zdb -bb (as detailed here: ZFS Metadata Special Device: Z - #94 by Log) should help people quickly figure out how large their drives need to be to hold metadata and small blocks.
@wendell
Curiously, I think I’ve somehow obtained the ability to edit your post. Is this on purpose or did I hack you?
