Permalink
Browse files
Show Dev Extents
The DEV TREE shows a mapping from all allocated blocks on the physical
storage back to chunks and their stripes.
>>> import btrfs
>>> from __future__ import print_function
>>> fs=btrfs.FileSystem('/mnt/extents')
>>> map(print, fs.dev_extents())
dev extent devid 1 paddr 1048576 length 134217728 chunk 14348713984
dev extent devid 1 paddr 135266304 length 33554432 chunk 14617149440
dev extent devid 1 paddr 168820736 length 1073741824 chunk 16831741952
dev extent devid 1 paddr 2436890624 length 1073741824 chunk 12201230336
dev extent devid 2 paddr 1048576 length 1073741824 chunk 12201230336
dev extent devid 2 paddr 1074790400 length 134217728 chunk 14348713984
dev extent devid 2 paddr 1209008128 length 33554432 chunk 14617149440
dev extent devid 2 paddr 1242562560 length 1073741824 chunk 16831741952
Or, with some information about the chunk they refer to:
# ./show_dev_extents.py /mnt/extents/
devid 1 type METADATA|RAID0 pstart 1.00MiB length 128.00MiB pend 129.00MiB vaddr 13.36GiB
devid 1 type SYSTEM|RAID0 pstart 129.00MiB length 32.00MiB pend 161.00MiB vaddr 13.61GiB
devid 1 type DATA|RAID0 pstart 161.00MiB length 1.00GiB pend 1.16GiB vaddr 15.68GiB
devid 1 type DATA|RAID0 pstart 2.27GiB length 1.00GiB pend 3.27GiB vaddr 11.36GiB
devid 2 type DATA|RAID0 pstart 1.00MiB length 1.00GiB pend 1.00GiB vaddr 11.36GiB
devid 2 type METADATA|RAID0 pstart 1.00GiB length 128.00MiB pend 1.13GiB vaddr 13.36GiB
devid 2 type SYSTEM|RAID0 pstart 1.13GiB length 32.00MiB pend 1.16GiB vaddr 13.61GiB
devid 2 type DATA|RAID0 pstart 1.16GiB length 1.00GiB pend 2.16GiB vaddr 15.68GiB- Loading branch information
Showing
with
43 additions
and 0 deletions.
- +26 −0 btrfs/ctree.py
- +17 −0 examples/show_dev_extents.py
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/python | ||
|
|
||
| from __future__ import print_function | ||
| import btrfs | ||
| import sys | ||
|
|
||
| fs = btrfs.FileSystem(sys.argv[1]) | ||
| chunks = {chunk.vaddr: chunk for chunk in fs.chunks()} | ||
| for d in fs.dev_extents(): | ||
| print("devid {0} type {1} pstart {2} length {3} pend {4} vaddr {5}".format( | ||
| d.devid, | ||
| btrfs.utils.block_group_flags_str(chunks[d.vaddr].type), | ||
| btrfs.utils.pretty_size(d.paddr), | ||
| btrfs.utils.pretty_size(d.length), | ||
| btrfs.utils.pretty_size(d.paddr + d.length), | ||
| btrfs.utils.pretty_size(d.vaddr) | ||
| )) |