For curiosity I'm trying to write a tool which will show me the size of
data extents belonging to which files in a snapshot are exclusive to
that snapshot as a way to show how much space would be freed if the
snapshot were to be deleted, and which files in the snapshot are taking
up the most space.
I'm working with Hans van Kranenburg's python-btrfs python library but
my knowledge of the filesystem structures isn't good enough to allow me
to figure out which bits of data I need to be able to achieve this. I'd
be grateful if anyone could help me along with this.
So far my idea is:
for each OS file in a subvolume:
find its data extents
for each extent:
find what files reference it #1
for each referencing file:
determine which subvolumes it lives in #2
if all references are within this subvolume:
record the OS file path and extents it references
for each recorded file path
find its data extents
output its path and the total number of bytes in all recorded extents
(those which are not shared)
#1 and #2 are where my understanding breaks down. How do I find which
files reference an extent and which subvolume those files are in?
Alternatively, if such a script already exists I would be happy to use
it.
Thanks for any pointers.
--
Steven Davies