All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug in btrfs-debug-tree for two  or more devices.
@ 2012-06-12  6:53 Santosh Hosamani
  2012-06-12 14:57 ` Randy Barlow
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Santosh Hosamani @ 2012-06-12  6:53 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]


Hi btrfs folks,
                I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
Btrfs-debug-tree also gives the information on the chunk tree

I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.

But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .
Also I notice that for the second device the superblock location 0x10000 is not considered as used .

I would be really grateful if you folks can answer my query.

I hav run these tests on SLES11-sp2-x86
Kernel 3.0.13.0.27-default

If you want any further clarification I would be wiiling to help you guys on this.

Thanks,
Santosh Hosamani



________________________________

http://www.mindtree.com/email/disclaimer.html

[-- Attachment #2: btrfs_debug_tree_two_device.txt --]
[-- Type: text/plain, Size: 7593 bytes --]

root tree
leaf 29364224 items 9 free space 2349 generation 4 owner 1
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239
		root data bytenr 29368320 level 0 dirid 0 refs 1 gen 4
	item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239
		root data bytenr 29372416 level 0 dirid 0 refs 1 gen 4
	item 2 key (FS_TREE INODE_REF 6) itemoff 3500 itemsize 17
		inode ref index 0 namelen 7 name: default
	item 3 key (FS_TREE ROOT_ITEM 0) itemoff 3261 itemsize 239
		root data bytenr 29360128 level 0 dirid 256 refs 1 gen 4
	item 4 key (ROOT_TREE_DIR INODE_ITEM 0) itemoff 3101 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 5 key (ROOT_TREE_DIR INODE_REF 6) itemoff 3089 itemsize 12
		inode ref index 0 namelen 2 name: ..
	item 6 key (ROOT_TREE_DIR DIR_ITEM 2378154706) itemoff 3052 itemsize 37
		location key (FS_TREE ROOT_ITEM 18446744073709551615) type 2
		namelen 7 datalen 0 name: default
	item 7 key (CSUM_TREE ROOT_ITEM 0) itemoff 2813 itemsize 239
		root data bytenr 29376512 level 0 dirid 0 refs 1 gen 4
	item 8 key (DATA_RELOC_TREE ROOT_ITEM 0) itemoff 2574 itemsize 239
		root data bytenr 29380608 level 0 dirid 256 refs 1 gen 4
chunk tree
leaf 20971520 items 8 free space 3023 generation 4 owner 3
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (DEV_ITEMS DEV_ITEM 1) itemoff 3897 itemsize 98
		dev item devid 1 total_bytes 3221225472 bytes used 673579008
	item 1 key (DEV_ITEMS DEV_ITEM 2) itemoff 3799 itemsize 98
		dev item devid 2 total_bytes 3221225472 bytes used 652607488
	item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 0) itemoff 3719 itemsize 80
		chunk length 4194304 owner 2 type 2 num_stripes 1
			stripe 0 devid 1 offset 0
	item 3 key (FIRST_CHUNK_TREE CHUNK_ITEM 4194304) itemoff 3639 itemsize 80
		chunk length 8388608 owner 2 type 4 num_stripes 1
			stripe 0 devid 1 offset 4194304
	item 4 key (FIRST_CHUNK_TREE CHUNK_ITEM 12582912) itemoff 3559 itemsize 80
		chunk length 8388608 owner 2 type 1 num_stripes 1
			stripe 0 devid 1 offset 12582912
	item 5 key (FIRST_CHUNK_TREE CHUNK_ITEM 20971520) itemoff 3447 itemsize 112
		chunk length 8388608 owner 2 type 18 num_stripes 2
			stripe 0 devid 2 offset 1048576
			stripe 1 devid 1 offset 20971520
	item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 29360128) itemoff 3335 itemsize 112
		chunk length 322109440 owner 2 type 20 num_stripes 2
			stripe 0 devid 2 offset 9437184
			stripe 1 devid 1 offset 29360128
	item 7 key (FIRST_CHUNK_TREE CHUNK_ITEM 351469568) itemoff 3223 itemsize 112
		chunk length 644218880 owner 2 type 9 num_stripes 2
			stripe 0 devid 2 offset 331546624
			stripe 1 devid 1 offset 351469568
extent tree key (EXTENT_TREE ROOT_ITEM 0) 
leaf 29368320 items 13 free space 3169 generation 4 owner 2
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (0 BLOCK_GROUP_ITEM 4194304) itemoff 3971 itemsize 24
		block group used 0 chunk_objectid 256 flags 2
	item 1 key (4194304 BLOCK_GROUP_ITEM 8388608) itemoff 3947 itemsize 24
		block group used 0 chunk_objectid 256 flags 4
	item 2 key (12582912 BLOCK_GROUP_ITEM 8388608) itemoff 3923 itemsize 24
		block group used 0 chunk_objectid 256 flags 1
	item 3 key (20971520 EXTENT_ITEM 4096) itemoff 3872 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (1 d8 1) level 0
		tree block backref root 3
	item 4 key (20971520 BLOCK_GROUP_ITEM 8388608) itemoff 3848 itemsize 24
		block group used 4096 chunk_objectid 256 flags 18
	item 5 key (29360128 EXTENT_ITEM 4096) itemoff 3797 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (256 1 0) level 0
		tree block backref root 5
	item 6 key (29360128 BLOCK_GROUP_ITEM 322109440) itemoff 3773 itemsize 24
		block group used 24576 chunk_objectid 256 flags 20
	item 7 key (29364224 EXTENT_ITEM 4096) itemoff 3722 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (2 84 0) level 0
		tree block backref root 1
	item 8 key (29368320 EXTENT_ITEM 4096) itemoff 3671 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (0 c0 4194304) level 0
		tree block backref root 2
	item 9 key (29372416 EXTENT_ITEM 4096) itemoff 3620 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (1 cc 0) level 0
		tree block backref root 4
	item 10 key (29376512 EXTENT_ITEM 4096) itemoff 3569 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (0 0 0) level 0
		tree block backref root 7
	item 11 key (29380608 EXTENT_ITEM 4096) itemoff 3518 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (256 1 0) level 0
		tree block backref root 18446744073709551607
	item 12 key (351469568 BLOCK_GROUP_ITEM 644218880) itemoff 3494 itemsize 24
		block group used 0 chunk_objectid 256 flags 9
device tree key (DEV_TREE ROOT_ITEM 0) 
leaf 29372416 items 9 free space 3338 generation 4 owner 4
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (1 DEV_EXTENT 0) itemoff 3947 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 0 length 4194304
	item 1 key (1 DEV_EXTENT 4194304) itemoff 3899 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 4194304 length 8388608
	item 2 key (1 DEV_EXTENT 12582912) itemoff 3851 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 12582912 length 8388608
	item 3 key (1 DEV_EXTENT 20971520) itemoff 3803 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 20971520 length 8388608
	item 4 key (1 DEV_EXTENT 29360128) itemoff 3755 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 29360128 length 322109440
	item 5 key (1 DEV_EXTENT 351469568) itemoff 3707 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 351469568 length 322109440
	item 6 key (2 DEV_EXTENT 1048576) itemoff 3659 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 20971520 length 8388608
	item 7 key (2 DEV_EXTENT 9437184) itemoff 3611 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 29360128 length 322109440
	item 8 key (2 DEV_EXTENT 331546624) itemoff 3563 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 351469568 length 322109440
fs tree key (FS_TREE ROOT_ITEM 0) 
leaf 29360128 items 2 free space 3773 generation 4 owner 5
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
		inode ref index 0 namelen 2 name: ..
checksum tree key (CSUM_TREE ROOT_ITEM 0) 
leaf 29376512 items 0 free space 3995 generation 4 owner 7
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
data reloc tree key (DATA_RELOC_TREE ROOT_ITEM 0) 
leaf 29380608 items 2 free space 3773 generation 4 owner 18446744073709551607
fs uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
chunk uuid e7e5467e-ef4e-4b47-ac37-198c1cc575b9
	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
		inode ref index 0 namelen 2 name: ..
total bytes 6442450944
bytes used 28672
uuid 22d1b011-b53a-423f-9f61-ca6d5f4192c7
Btrfs v0.19+

[-- Attachment #3: btrfs_debug_tree_single_device.txt --]
[-- Type: text/plain, Size: 6833 bytes --]

root tree
leaf 29364224 items 9 free space 2349 generation 4 owner 1
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239
		root data bytenr 29368320 level 0 dirid 0 refs 1 gen 4
	item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239
		root data bytenr 29372416 level 0 dirid 0 refs 1 gen 4
	item 2 key (FS_TREE INODE_REF 6) itemoff 3500 itemsize 17
		inode ref index 0 namelen 7 name: default
	item 3 key (FS_TREE ROOT_ITEM 0) itemoff 3261 itemsize 239
		root data bytenr 29360128 level 0 dirid 256 refs 1 gen 4
	item 4 key (ROOT_TREE_DIR INODE_ITEM 0) itemoff 3101 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 5 key (ROOT_TREE_DIR INODE_REF 6) itemoff 3089 itemsize 12
		inode ref index 0 namelen 2 name: ..
	item 6 key (ROOT_TREE_DIR DIR_ITEM 2378154706) itemoff 3052 itemsize 37
		location key (FS_TREE ROOT_ITEM 18446744073709551615) type 2
		namelen 7 datalen 0 name: default
	item 7 key (CSUM_TREE ROOT_ITEM 0) itemoff 2813 itemsize 239
		root data bytenr 29376512 level 0 dirid 0 refs 1 gen 4
	item 8 key (DATA_RELOC_TREE ROOT_ITEM 0) itemoff 2574 itemsize 239
		root data bytenr 29380608 level 0 dirid 256 refs 1 gen 4
chunk tree
leaf 20971520 items 6 free space 3283 generation 4 owner 3
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (DEV_ITEMS DEV_ITEM 1) itemoff 3897 itemsize 98
		dev item devid 1 total_bytes 3221225472 bytes used 359792640
	item 1 key (FIRST_CHUNK_TREE CHUNK_ITEM 0) itemoff 3817 itemsize 80
		chunk length 4194304 owner 2 type 2 num_stripes 1
			stripe 0 devid 1 offset 0
	item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 4194304) itemoff 3737 itemsize 80
		chunk length 8388608 owner 2 type 4 num_stripes 1
			stripe 0 devid 1 offset 4194304
	item 3 key (FIRST_CHUNK_TREE CHUNK_ITEM 12582912) itemoff 3657 itemsize 80
		chunk length 8388608 owner 2 type 1 num_stripes 1
			stripe 0 devid 1 offset 12582912
	item 4 key (FIRST_CHUNK_TREE CHUNK_ITEM 20971520) itemoff 3545 itemsize 112
		chunk length 8388608 owner 2 type 34 num_stripes 2
			stripe 0 devid 1 offset 20971520
			stripe 1 devid 1 offset 29360128
	item 5 key (FIRST_CHUNK_TREE CHUNK_ITEM 29360128) itemoff 3433 itemsize 112
		chunk length 161021952 owner 2 type 36 num_stripes 2
			stripe 0 devid 1 offset 37748736
			stripe 1 devid 1 offset 198770688
extent tree key (EXTENT_TREE ROOT_ITEM 0) 
leaf 29368320 items 12 free space 3218 generation 4 owner 2
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (0 BLOCK_GROUP_ITEM 4194304) itemoff 3971 itemsize 24
		block group used 0 chunk_objectid 256 flags 2
	item 1 key (4194304 BLOCK_GROUP_ITEM 8388608) itemoff 3947 itemsize 24
		block group used 0 chunk_objectid 256 flags 4
	item 2 key (12582912 BLOCK_GROUP_ITEM 8388608) itemoff 3923 itemsize 24
		block group used 0 chunk_objectid 256 flags 1
	item 3 key (20971520 EXTENT_ITEM 4096) itemoff 3872 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (1 d8 1) level 0
		tree block backref root 3
	item 4 key (20971520 BLOCK_GROUP_ITEM 8388608) itemoff 3848 itemsize 24
		block group used 4096 chunk_objectid 256 flags 34
	item 5 key (29360128 EXTENT_ITEM 4096) itemoff 3797 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (256 1 0) level 0
		tree block backref root 5
	item 6 key (29360128 BLOCK_GROUP_ITEM 161021952) itemoff 3773 itemsize 24
		block group used 24576 chunk_objectid 256 flags 36
	item 7 key (29364224 EXTENT_ITEM 4096) itemoff 3722 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (2 84 0) level 0
		tree block backref root 1
	item 8 key (29368320 EXTENT_ITEM 4096) itemoff 3671 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (0 c0 4194304) level 0
		tree block backref root 2
	item 9 key (29372416 EXTENT_ITEM 4096) itemoff 3620 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (1 cc 0) level 0
		tree block backref root 4
	item 10 key (29376512 EXTENT_ITEM 4096) itemoff 3569 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (0 0 0) level 0
		tree block backref root 7
	item 11 key (29380608 EXTENT_ITEM 4096) itemoff 3518 itemsize 51
		extent refs 1 gen 4 flags 2
		tree block key (256 1 0) level 0
		tree block backref root 18446744073709551607
device tree key (DEV_TREE ROOT_ITEM 0) 
leaf 29372416 items 7 free space 3484 generation 4 owner 4
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (1 DEV_EXTENT 0) itemoff 3947 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 0 length 4194304
	item 1 key (1 DEV_EXTENT 4194304) itemoff 3899 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 4194304 length 8388608
	item 2 key (1 DEV_EXTENT 12582912) itemoff 3851 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 12582912 length 8388608
	item 3 key (1 DEV_EXTENT 20971520) itemoff 3803 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 20971520 length 8388608
	item 4 key (1 DEV_EXTENT 29360128) itemoff 3755 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 20971520 length 8388608
	item 5 key (1 DEV_EXTENT 37748736) itemoff 3707 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 29360128 length 161021952
	item 6 key (1 DEV_EXTENT 198770688) itemoff 3659 itemsize 48
		dev extent chunk_tree 3
		chunk objectid 256 chunk offset 29360128 length 161021952
fs tree key (FS_TREE ROOT_ITEM 0) 
leaf 29360128 items 2 free space 3773 generation 4 owner 5
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
		inode ref index 0 namelen 2 name: ..
checksum tree key (CSUM_TREE ROOT_ITEM 0) 
leaf 29376512 items 0 free space 3995 generation 4 owner 7
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
data reloc tree key (DATA_RELOC_TREE ROOT_ITEM 0) 
leaf 29380608 items 2 free space 3773 generation 4 owner 18446744073709551607
fs uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
chunk uuid e279f69e-7a5f-401a-b56a-755134965695
	item 0 key (256 INODE_ITEM 0) itemoff 3835 itemsize 160
		inode generation 3 size 0 block group 0 mode 40555 links 1
	item 1 key (256 INODE_REF 256) itemoff 3823 itemsize 12
		inode ref index 0 namelen 2 name: ..
total bytes 3221225472
bytes used 28672
uuid 6dcc7c2b-6b77-4c9d-bafb-201627ef82bf
Btrfs v0.19+

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
@ 2012-06-12 14:57 ` Randy Barlow
  2012-06-13  8:43   ` Santosh Hosamani
  2012-06-12 15:22 ` Duncan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Randy Barlow @ 2012-06-12 14:57 UTC (permalink / raw)
  To: linux-btrfs

On Tuesday, June 12, 2012 06:53:00 AM Santosh Hosamani wrote:
> Kernel 3.0.13.0.27-default

This kernel is very old for btrfs. Can you try with at least Linux 3.4?

-- 
R

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
  2012-06-12 14:57 ` Randy Barlow
@ 2012-06-12 15:22 ` Duncan
  2012-06-12 16:49 ` Arne Jansen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Duncan @ 2012-06-12 15:22 UTC (permalink / raw)
  To: linux-btrfs

Santosh Hosamani posted on Tue, 12 Jun 2012 06:53:00 +0000 as excerpted:

> I am working on btrfs filesystem on how it manages the free space. [...]

> I hav run these tests on SLES11-sp2-x86 Kernel 3.0.13.0.27-default

Quick mostly boilerplate intro reply.  I'm just a list regular following 
development without getting too technical, so won't even a full answer.


1. As you didn't mention the wiki and based on a couple hints in your 
mail including the kernel version, I'm guessing you haven't read up on 
btrfs there yet.

https://btrfs.wiki.kernel.org/


2. Btrfs is of course still experimental and under heavy development, so 
while testing as you're doing is great, even more than with proven 
filesystems, if you value your data, HAVE BACKUPS.

3. It follows from the "under heavy development" part but making it 
explicit: for btrfs testers, a 3.0 kernel is OLD CODE with many bugs, 
some critical, fixed since then, and many newly implemented features in 
newer code.  The standard STRONG recommendation is to run at least 
current Linus stable, thus currently 3.4, if not the 3.5 rcs, and there's 
pre-Linus-integration-branches as well, if you're brave.  Additionally, 
for the first time last kernel cycle (btrfs wasn't considered stable 
enough to bother before that), a btrfs update was submitted to the stable 
tree, so if you're staying with stable, do keep current with the stable 
point releases, 3.3.x in that case but now of course 3.4.x.

4. Also recommended (and following from the "heavy development" bit), 
btrfs testers should keep current with this list in ordered to know what 
bugs are already being worked on and how testers might be affected.


Now a brief reply that may or may not explain the one-device/multi-device 
difference you're seeing, I'm not deep enough into the technical side to 
know for sure.  As you'll be aware if you've read the wiki, btrfs 
defaults to single data, duplicate metadata.  On a single device, the two 
separate metadata copies are of course stored on the same device, but 
where btrfs has at least two devices to work with, it tries to keep the 
two copies on separate devices.  It may be that what you're seeing is the 
lower-level implications of that difference.

Of course it's also possible that you've found a bug, but testing with a 
current kernel would help in terms of knowing whether it's still an issue 
or not.  As I said, 3.0 is OLD for btrfs testers.  (There is however 
someone reporting a huge metadata imbalance with multi-device btrfs 
filesystems and current code, IDR whether it's 3.4 or 3.5-rcs.  Only a 
few gigs, single digits, of data, but something like 85 gigs of metadata, 
after adding a second device!  Definitely looks like a bug there!  That's 
where keeping current with the list comes in, knowing about that sort of 
current issue report with current code.)

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
  2012-06-12 14:57 ` Randy Barlow
  2012-06-12 15:22 ` Duncan
@ 2012-06-12 16:49 ` Arne Jansen
  2012-06-13  4:39   ` Santosh Hosamani
  2012-06-12 20:06 ` Hugo Mills
  2012-06-12 22:58 ` David Sterba
  4 siblings, 1 reply; 9+ messages in thread
From: Arne Jansen @ 2012-06-12 16:49 UTC (permalink / raw)
  To: Santosh Hosamani; +Cc: linux-btrfs

On 06/12/2012 08:53 AM, Santosh Hosamani wrote:
> 
> Hi btrfs folks,
>                 I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
> Btrfs-debug-tree also gives the information on the chunk tree
> 
> I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
> For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.
> 
> But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .
> Also I notice that for the second device the superblock location 0x10000 is not considered as used .
> 
> I would be really grateful if you folks can answer my query.

It's definitely not a bug in debug-tree, but just a problem in
interpreting the result. Could you please paste the output of
btrfs-debug-tree -d? This way it is easier to see what's
bothering you :)

> 
> I hav run these tests on SLES11-sp2-x86
> Kernel 3.0.13.0.27-default
> 
> If you want any further clarification I would be wiiling to help you guys on this.
> 
> Thanks,
> Santosh Hosamani
> 
> 
> 
> ________________________________
> 
> http://www.mindtree.com/email/disclaimer.html


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
                   ` (2 preceding siblings ...)
  2012-06-12 16:49 ` Arne Jansen
@ 2012-06-12 20:06 ` Hugo Mills
  2012-06-13  8:40   ` Santosh Hosamani
  2012-06-12 22:58 ` David Sterba
  4 siblings, 1 reply; 9+ messages in thread
From: Hugo Mills @ 2012-06-12 20:06 UTC (permalink / raw)
  To: Santosh Hosamani; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 2031 bytes --]

On Tue, Jun 12, 2012 at 06:53:00AM +0000, Santosh Hosamani wrote:
> 
> Hi btrfs folks,
>                 I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
> Btrfs-debug-tree also gives the information on the chunk tree
> 
> I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
> For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.
> 
> But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .

   Without actually seeing the details of your technique and
expectations, I shall make a guess that you're not accounting for the
double-counting of RAID-1 metadata. In other words, you will find that
all of the metadata device extents (or chunks) will appear twice --
once on each device.

   Actually, this isn't quite right either -- what you really need to
do is look at the RAID-1, RAID-10 and DUP bits in the chunk flags, add
up all of those chunks, divide by two, and then add in the remaining
(RAID-0 and single) chunks. That total should then add up to the total
value of allocated space that you get from the output of "btrfs fi df".

> Also I notice that for the second device the superblock location 0x10000 is not considered as used .
> 
> I would be really grateful if you folks can answer my query.
> 
> I hav run these tests on SLES11-sp2-x86
> Kernel 3.0.13.0.27-default

   This is pretty old, but shouldn't affect the results. It will cause
reliability problems if you try running it seriously.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
   --- "There's a Martian war machine outside -- they want to talk ---   
                to you about a cure for the common cold."                

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
                   ` (3 preceding siblings ...)
  2012-06-12 20:06 ` Hugo Mills
@ 2012-06-12 22:58 ` David Sterba
  4 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2012-06-12 22:58 UTC (permalink / raw)
  To: Santosh Hosamani; +Cc: linux-btrfs

On Tue, Jun 12, 2012 at 06:53:00AM +0000, Santosh Hosamani wrote:
> 
> Hi btrfs folks,
>                 I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
> Btrfs-debug-tree also gives the information on the chunk tree
> 
> I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
> For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.
> 
> But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .
> Also I notice that for the second device the superblock location 0x10000 is not considered as used .
> 
> I would be really grateful if you folks can answer my query.
> 
> I hav run these tests on SLES11-sp2-x86
> Kernel 3.0.13.0.27-default

Your observation about non-excluded superblock is correct and this is a
known bug fixed in following maintenance update of SLES.

If you're using a distribution kernel, please file a bug at the distro
bug tracker (http://bugzilla.novell.com).

The SLES kernel receives regular backports of btrfs fixes and features
from upstream, but keeps the version at 3.0.x which confuses the
upstream community ready to point you to the latest kernel released.


thanks,
david

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12 16:49 ` Arne Jansen
@ 2012-06-13  4:39   ` Santosh Hosamani
  0 siblings, 0 replies; 9+ messages in thread
From: Santosh Hosamani @ 2012-06-13  4:39 UTC (permalink / raw)
  To: Arne Jansen; +Cc: linux-btrfs



-----Original Message-----
From: Arne Jansen [mailto:sensille@gmx.net]
Sent: Tuesday, June 12, 2012 10:20 PM
To: Santosh Hosamani
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Bug in btrfs-debug-tree for two or more devices.

On 06/12/2012 08:53 AM, Santosh Hosamani wrote:
>
> Hi btrfs folks,
>                 I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
> Btrfs-debug-tree also gives the information on the chunk tree
>
> I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
> For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.
>
> But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .
> Also I notice that for the second device the superblock location 0x10000 is not considered as used .
>
> I would be really grateful if you folks can answer my query.

It's definitely not a bug in debug-tree, but just a problem in interpreting the result. Could you please paste the output of btrfs-debug-tree -d? This way it is easier to see what's bothering you :)


Btrfs fi show

Label: none  uuid: 23f86d1e-038a-4f5b-b87c-2ba78018135c
        Total devices 2 FS bytes used 28.00KB
        devid    2 size 3.00GB used 622.38MB path /dev/sdb2
        devid    1 size 3.00GB used 642.38MB path /dev/sdb1

Btrfs v0.19+


Btrfs-debug-tree -d /dev/sdb2
root tree
leaf 29364224 items 9 free space 2349 generation 4 owner 1
fs uuid 23f86d1e-038a-4f5b-b87c-2ba78018135c
chunk uuid db672366-6801-4f83-99ef-2087a60bb394
        item 0 key (EXTENT_TREE ROOT_ITEM 0) itemoff 3756 itemsize 239
                root data bytenr 29368320 level 0 dirid 0 refs 1 gen 4
        item 1 key (DEV_TREE ROOT_ITEM 0) itemoff 3517 itemsize 239
                root data bytenr 29372416 level 0 dirid 0 refs 1 gen 4
        item 2 key (FS_TREE INODE_REF 6) itemoff 3500 itemsize 17
                inode ref index 0 namelen 7 name: default
        item 3 key (FS_TREE ROOT_ITEM 0) itemoff 3261 itemsize 239
                root data bytenr 29360128 level 0 dirid 256 refs 1 gen 4
        item 4 key (ROOT_TREE_DIR INODE_ITEM 0) itemoff 3101 itemsize 160
                inode generation 3 size 0 block group 0 mode 40555 links 1
        item 5 key (ROOT_TREE_DIR INODE_REF 6) itemoff 3089 itemsize 12
                inode ref index 0 namelen 2 name: ..
        item 6 key (ROOT_TREE_DIR DIR_ITEM 2378154706) itemoff 3052 itemsize 37
                location key (FS_TREE ROOT_ITEM 18446744073709551615) type 2
                namelen 7 datalen 0 name: default
        item 7 key (CSUM_TREE ROOT_ITEM 0) itemoff 2813 itemsize 239
                root data bytenr 29376512 level 0 dirid 0 refs 1 gen 4
        item 8 key (DATA_RELOC_TREE ROOT_ITEM 0) itemoff 2574 itemsize 239
                root data bytenr 29380608 level 0 dirid 256 refs 1 gen 4
chunk tree
leaf 20971520 items 8 free space 3023 generation 4 owner 3
fs uuid 23f86d1e-038a-4f5b-b87c-2ba78018135c
chunk uuid db672366-6801-4f83-99ef-2087a60bb394
        item 0 key (DEV_ITEMS DEV_ITEM 1) itemoff 3897 itemsize 98
                dev item devid 1 total_bytes 3221225472 bytes used 673579008
        item 1 key (DEV_ITEMS DEV_ITEM 2) itemoff 3799 itemsize 98
                dev item devid 2 total_bytes 3221225472 bytes used 652607488
        item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 0) itemoff 3719 itemsize 80
                chunk length 4194304 owner 2 type 2 num_stripes 1
                        stripe 0 devid 1 offset 0
        item 3 key (FIRST_CHUNK_TREE CHUNK_ITEM 4194304) itemoff 3639 itemsize 80
                chunk length 8388608 owner 2 type 4 num_stripes 1
                        stripe 0 devid 1 offset 4194304
        item 4 key (FIRST_CHUNK_TREE CHUNK_ITEM 12582912) itemoff 3559 itemsize 80
                chunk length 8388608 owner 2 type 1 num_stripes 1
                        stripe 0 devid 1 offset 12582912
        item 5 key (FIRST_CHUNK_TREE CHUNK_ITEM 20971520) itemoff 3447 itemsize 112
                chunk length 8388608 owner 2 type 18 num_stripes 2
                        stripe 0 devid 2 offset 1048576
                        stripe 1 devid 1 offset 20971520
        item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 29360128) itemoff 3335 itemsize 112
                chunk length 322109440 owner 2 type 20 num_stripes 2
                        stripe 0 devid 2 offset 9437184
                        stripe 1 devid 1 offset 29360128
        item 7 key (FIRST_CHUNK_TREE CHUNK_ITEM 351469568) itemoff 3223 itemsize 112
                chunk length 644218880 owner 2 type 9 num_stripes 2
                        stripe 0 devid 2 offset 331546624
                        stripe 1 devid 1 offset 351469568
device tree key (DEV_TREE ROOT_ITEM 0)
leaf 29372416 items 9 free space 3338 generation 4 owner 4
fs uuid 23f86d1e-038a-4f5b-b87c-2ba78018135c
chunk uuid db672366-6801-4f83-99ef-2087a60bb394
        item 0 key (1 DEV_EXTENT 0) itemoff 3947 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 0 length 4194304
        item 1 key (1 DEV_EXTENT 4194304) itemoff 3899 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 4194304 length 8388608
        item 2 key (1 DEV_EXTENT 12582912) itemoff 3851 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 12582912 length 8388608
        item 3 key (1 DEV_EXTENT 20971520) itemoff 3803 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 20971520 length 8388608
        item 4 key (1 DEV_EXTENT 29360128) itemoff 3755 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 29360128 length 322109440
        item 5 key (1 DEV_EXTENT 351469568) itemoff 3707 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 351469568 length 322109440
        item 6 key (2 DEV_EXTENT 1048576) itemoff 3659 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 20971520 length 8388608
        item 7 key (2 DEV_EXTENT 9437184) itemoff 3611 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 29360128 length 322109440
        item 8 key (2 DEV_EXTENT 331546624) itemoff 3563 itemsize 48
                dev extent chunk_tree 3
                chunk objectid 256 chunk offset 351469568 length 322109440

>when you add all the lengths in the chunk tree
>devid 1  407502840
>devid 2  394919928
>may be the way I am counting the length is wrong.
>how to find which all blocks are used (data or metadata)  and which all  blocks are free in the multiple devices.
>Traversing the chunk tree is correct or is there any other alternative ?

>Also I had one more doubt Is chunk tree present only in the first device or will there  be a copy in all the devices?





________________________________

http://www.mindtree.com/email/disclaimer.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12 20:06 ` Hugo Mills
@ 2012-06-13  8:40   ` Santosh Hosamani
  0 siblings, 0 replies; 9+ messages in thread
From: Santosh Hosamani @ 2012-06-13  8:40 UTC (permalink / raw)
  To: Hugo Mills; +Cc: linux-btrfs



-----Original Message-----
From: linux-btrfs-owner@vger.kernel.org [mailto:linux-btrfs-owner@vger.kernel.org] On Behalf Of Hugo Mills
Sent: Wednesday, June 13, 2012 1:37 AM
To: Santosh Hosamani
Cc: linux-btrfs@vger.kernel.org
Subject: Re: Bug in btrfs-debug-tree for two or more devices.

On Tue, Jun 12, 2012 at 06:53:00AM +0000, Santosh Hosamani wrote:
>
> Hi btrfs folks,
>                 I am working on btrfs filesystem on how it manages the free space. And found out btrfs maintain a ctree which manages the physical location of the chunks and stripes of the filesystem.
> Btrfs-debug-tree also gives the information on the chunk tree
>
> I created btrfs on single device and two device.I have attached the output of both on running btrfs-debug-tree.
> For single device sum of all the length in the chunks will add upto the total used bytes which is expected behavior.
>
> But for two devices sum of all lengths in the chunks does not add to the total bytes .Am I missing something .

   Without actually seeing the details of your technique and expectations, I shall make a guess that you're not accounting for the double-counting of RAID-1 metadata. In other words, you will find that all of the metadata device extents (or chunks) will appear twice -- once on each device.

   Actually, this isn't quite right either -- what you really need to do is look at the RAID-1, RAID-10 and DUP bits in the chunk flags, add up all of those chunks, divide by two, and then add in the remaining
(RAID-0 and single) chunks. That total should then add up to the total value of allocated space that you get from the output of "btrfs fi df".

>>
 chunk tree leaf 20971520 items 8 free space 3023 generation 4 owner 3 fs uuid 23f86d1e-038a-4f5b-b87c-2ba78018135c
chunk uuid db672366-6801-4f83-99ef-2087a60bb394
        item 0 key (DEV_ITEMS DEV_ITEM 1) itemoff 3897 itemsize 98
                dev item devid 1 total_bytes 3221225472 bytes used 673579008
        item 1 key (DEV_ITEMS DEV_ITEM 2) itemoff 3799 itemsize 98
                dev item devid 2 total_bytes 3221225472 bytes used 652607488
        item 2 key (FIRST_CHUNK_TREE CHUNK_ITEM 0) itemoff 3719 itemsize 80
                chunk length 4194304 owner 2 type 2 num_stripes 1
                        stripe 0 devid 1 offset 0
        item 3 key (FIRST_CHUNK_TREE CHUNK_ITEM 4194304) itemoff 3639 itemsize 80
                chunk length 8388608 owner 2 type 4 num_stripes 1
                        stripe 0 devid 1 offset 4194304
        item 4 key (FIRST_CHUNK_TREE CHUNK_ITEM 12582912) itemoff 3559 itemsize 80
                chunk length 8388608 owner 2 type 1 num_stripes 1
                        stripe 0 devid 1 offset 12582912
        item 5 key (FIRST_CHUNK_TREE CHUNK_ITEM 20971520) itemoff 3447 itemsize 112
                chunk length 8388608 owner 2 type 18 num_stripes 2
                        stripe 0 devid 2 offset 1048576
                        stripe 1 devid 1 offset 20971520
        item 6 key (FIRST_CHUNK_TREE CHUNK_ITEM 29360128) itemoff 3335 itemsize 112
                chunk length 322109440 owner 2 type 20 num_stripes 2
                        stripe 0 devid 2 offset 9437184
                        stripe 1 devid 1 offset 29360128
        item 7 key (FIRST_CHUNK_TREE CHUNK_ITEM 351469568) itemoff 3223 itemsize 112
                chunk length 644218880 owner 2 type 9 num_stripes 2
                        stripe 0 devid 2 offset 331546624
                        stripe 1 devid 1 offset 351469568
chunk tree will tell me where the physical stripes are there right .?Irrespective of the raid type ... correct me if I am wrong.
If not how will you know which all blocks are occupied and which all block are free.

Basically  what I want to do is .
 get the used blocks of all the devices and create a bitmap of that and zero out all the free block. Then I should not overwrite the used blocks.
I should be able to mount the filesystem without any error.
How do I achieve that?

> Also I notice that for the second device the superblock location 0x10000 is not considered as used .
>
> I would be really grateful if you folks can answer my query.
>
> I hav run these tests on SLES11-sp2-x86 Kernel 3.0.13.0.27-default

   This is pretty old, but shouldn't affect the results. It will cause reliability problems if you try running it seriously.

   Hugo.

--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
   --- "There's a Martian war machine outside -- they want to talk ---
                to you about a cure for the common cold."

________________________________

http://www.mindtree.com/email/disclaimer.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Bug in btrfs-debug-tree for two  or more devices.
  2012-06-12 14:57 ` Randy Barlow
@ 2012-06-13  8:43   ` Santosh Hosamani
  0 siblings, 0 replies; 9+ messages in thread
From: Santosh Hosamani @ 2012-06-13  8:43 UTC (permalink / raw)
  To: Randy Barlow, linux-btrfs



-----Original Message-----
From: linux-btrfs-owner@vger.kernel.org [mailto:linux-btrfs-owner@vger.kernel.org] On Behalf Of Randy Barlow
Sent: Tuesday, June 12, 2012 8:28 PM
To: linux-btrfs@vger.kernel.org
Subject: Re: Bug in btrfs-debug-tree for two or more devices.

On Tuesday, June 12, 2012 06:53:00 AM Santosh Hosamani wrote:
> Kernel 3.0.13.0.27-default

This kernel is very old for btrfs. Can you try with at least Linux 3.4?

I have installed 3.4.2 kernel but still I am facing the same issue.May be my understanding of calculating the used block may be wrong.
If someone could help me in understanding .It would be great.

--
R
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html

________________________________

http://www.mindtree.com/email/disclaimer.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-06-13  8:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12  6:53 Bug in btrfs-debug-tree for two or more devices Santosh Hosamani
2012-06-12 14:57 ` Randy Barlow
2012-06-13  8:43   ` Santosh Hosamani
2012-06-12 15:22 ` Duncan
2012-06-12 16:49 ` Arne Jansen
2012-06-13  4:39   ` Santosh Hosamani
2012-06-12 20:06 ` Hugo Mills
2012-06-13  8:40   ` Santosh Hosamani
2012-06-12 22:58 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.