From: "David F." <df7729@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Understanding BTRFS Extent Tree?
Date: Wed, 3 Apr 2024 22:41:46 -0700 [thread overview]
Message-ID: <CAGRSmLv2TB5YT5_11zqVd6qfBgJ6wgzPCpmd6s4-gvSCnnnXWg@mail.gmail.com> (raw)
Hi,
I have a need to find all the used areas on the btrfs (in this case
just a single disk, no RAID, etc..). I read that the extent tree
should have all the information necessary but the values don't add up.
Looking at items in the Extent Tree for BTRFS_EXTENT_ITEM_KEY and
BTRFS_METADATA_ITEM_KEY I find a total of 196,608 bytes.
Using "btrfs inspect-internal dump-tree --extents" and add that up you
get exactly 1/2 of that 98,304 (presume because DUP).
Yet the file system says 3.6M is used. How do I get all the used
areas for a simple single drive or partition on a PC using btrfs? I
will probably need to manually handle the superblock area?
Anyway, here is the output for the extent tree:
linux-jn17:/home/suse # df -h /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 8.0G 3.6M 7.2G 1% /mnt
linux-jn17:/home/suse # btrfs inspect-internal dump-tree --extents /dev/sdb
btrfs-progs v4.19.1
extent tree key (EXTENT_TREE ROOT_ITEM 0)
leaf 30523392 items 12 free space 15594 generation 14 owner EXTENT_TREE
leaf 30523392 flags 0x1(WRITTEN) backref revision 1
fs uuid 7fe21481-9083-4f7b-a00c-e651fd16bfac
chunk uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 0 key (13631488 EXTENT_ITEM 65536) itemoff 16230 itemsize 53
refs 1 gen 14 flags DATA
extent data backref root ROOT_TREE objectid 256 offset 0 count 1
item 1 key (13631488 BLOCK_GROUP_ITEM 8388608) itemoff 16206 itemsize 24
block group used 65536 chunk_objectid 256 flags DATA
item 2 key (22020096 BLOCK_GROUP_ITEM 8388608) itemoff 16182 itemsize 24
block group used 16384 chunk_objectid 256 flags SYSTEM|DUP
item 3 key (22036480 METADATA_ITEM 0) itemoff 16149 itemsize 33
refs 1 gen 5 flags TREE_BLOCK
tree block skinny level 0
tree block backref root CHUNK_TREE
item 4 key (30408704 BLOCK_GROUP_ITEM 429457408) itemoff 16125 itemsize 24
block group used 114688 chunk_objectid 256 flags METADATA|DUP
item 5 key (30425088 METADATA_ITEM 0) itemoff 16092 itemsize 33
refs 1 gen 6 flags TREE_BLOCK
tree block skinny level 0
tree block backref root UUID_TREE
item 6 key (30490624 METADATA_ITEM 0) itemoff 16059 itemsize 33
refs 1 gen 4 flags TREE_BLOCK
tree block skinny level 0
tree block backref root DATA_RELOC_TREE
item 7 key (30507008 METADATA_ITEM 0) itemoff 16026 itemsize 33
refs 1 gen 14 flags TREE_BLOCK
tree block skinny level 0
tree block backref root ROOT_TREE
item 8 key (30523392 METADATA_ITEM 0) itemoff 15993 itemsize 33
refs 1 gen 14 flags TREE_BLOCK
tree block skinny level 0
tree block backref root EXTENT_TREE
item 9 key (30539776 METADATA_ITEM 0) itemoff 15960 itemsize 33
refs 1 gen 14 flags TREE_BLOCK
tree block skinny level 0
tree block backref root DEV_TREE
item 10 key (30556160 METADATA_ITEM 0) itemoff 15927 itemsize 33
refs 1 gen 14 flags TREE_BLOCK
tree block skinny level 0
tree block backref root CSUM_TREE
item 11 key (30670848 METADATA_ITEM 0) itemoff 15894 itemsize 33
refs 1 gen 7 flags TREE_BLOCK
tree block skinny level 0
tree block backref root FS_TREE
device tree key (DEV_TREE ROOT_ITEM 0)
leaf 30539776 items 6 free space 15853 generation 14 owner DEV_TREE
leaf 30539776 flags 0x1(WRITTEN) backref revision 1
fs uuid 7fe21481-9083-4f7b-a00c-e651fd16bfac
chunk uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 0 key (0 PERSISTENT_ITEM 1) itemoff 16243 itemsize 40
persistent item objectid 0 offset 1
device stats
write_errs 0 read_errs 0 flush_errs 0 corruption_errs 0 generation 0
item 1 key (1 DEV_EXTENT 13631488) itemoff 16195 itemsize 48
dev extent chunk_tree 3
chunk_objectid 256 chunk_offset 13631488 length 8388608
chunk_tree_uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 2 key (1 DEV_EXTENT 22020096) itemoff 16147 itemsize 48
dev extent chunk_tree 3
chunk_objectid 256 chunk_offset 22020096 length 8388608
chunk_tree_uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 3 key (1 DEV_EXTENT 30408704) itemoff 16099 itemsize 48
dev extent chunk_tree 3
chunk_objectid 256 chunk_offset 22020096 length 8388608
chunk_tree_uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 4 key (1 DEV_EXTENT 38797312) itemoff 16051 itemsize 48
dev extent chunk_tree 3
chunk_objectid 256 chunk_offset 30408704 length 429457408
chunk_tree_uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
item 5 key (1 DEV_EXTENT 468254720) itemoff 16003 itemsize 48
dev extent chunk_tree 3
chunk_objectid 256 chunk_offset 30408704 length 429457408
chunk_tree_uuid 44ceacdd-bc48-409f-8af7-6bd2eb7cb44a
Thanks!!
next reply other threads:[~2024-04-04 5:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 5:41 David F. [this message]
2024-04-04 7:15 ` Understanding BTRFS Extent Tree? Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGRSmLv2TB5YT5_11zqVd6qfBgJ6wgzPCpmd6s4-gvSCnnnXWg@mail.gmail.com \
--to=df7729@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).