Bug 120941 - [RFE] btrfs-map-logical does not return the physical location for all devices in raid56
Summary: [RFE] btrfs-map-logical does not return the physical location for all devices...
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 enhancement
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-23 18:32 UTC by Chris Murphy
Modified: 2016-06-23 22:13 UTC (History)
0 users

See Also:
Kernel Version: 4.5.7-300.fc24.x86_64
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Chris Murphy 2016-06-23 18:32:17 UTC
[root@f24s ~]# rpm -q btrfs-progs
btrfs-progs-4.6-1.fc25.x86_64


When data is on raid5, btrfs-map-logical returns only two mirrors, sometimes one of those is parity, sometimes both are data. In any case, it's returning incomplete physical location information and should provide physical location for all num_stripes.


Example 3 device raid5 with devices /dev/VG/[abc]


	item 3 key (FIRST_CHUNK_TREE CHUNK_ITEM 4391436288) itemoff 15845 itemsize 144
		chunk length 2147483648 owner 2 stripe_len 65536
		type DATA|RAID5 num_stripes 3
			stripe 0 devid 2 offset 2224029696
			dev uuid: 3c6f37eb-5cae-455a-82bc-a1b0877dea55
			stripe 1 devid 1 offset 3242196992
			dev uuid: 13104709-6f30-4982-979e-4f055c326fad
			stripe 2 devid 3 offset 2224029696
			dev uuid: d45fc482-a0c1-46b1-98c1-41cea5a11c80

A file with 64KiB of the letter "a" followed by 64KiB of the letter "b".

[root@f24s ~]# filefrag -v /mnt/64k_a_then64k_b.txt 
File size of /mnt/64k_a_then64k_b.txt is 131073 (33 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..      32:    1072128..   1072160:     33:             last,eof
/mnt/64k_a_then64k_b.txt: 1 extent found
[root@f24s ~]# btrfs-map-logical -l $[1072128*4096] /dev/VG/a 
mirror 1 logical 4391436288 physical 2224029696 device /dev/mapper/VG-b
mirror 2 logical 4391436288 physical 2224029696 device /dev/mapper/VG-c
[root@f24s ~]# dd if=/dev/VG/b bs=1 skip=2224029696 count=131072 2>/dev/null | hexdump -C
00000000  61 61 61 61 61 61 61 61  61 61 61 61 61 61 61 61  |aaaaaaaaaaaaaaaa|
*
00010000  0a 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00010010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00020000
[root@f24s ~]# dd if=/dev/VG/c bs=1 skip=2224029696 count=131072 2>/dev/null | hexdump -C
00000000  03 03 03 03 03 03 03 03  03 03 03 03 03 03 03 03  |................|
*
00010000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00020000

So VG/b contains the first 64KiB of the file, VG/c contains parity, and unlisted VG/a contains the second 64KiB of the file.
Comment 1 Chris Murphy 2016-06-23 22:13:37 UTC
Just in case it's not clear "a" = 0x61 = 01100001, "b" = 0x62 = 01100010.
01100001
01100010
-->
00000011 = 0x03. So the 0x61 is definitely the 64KiB of "a"'s of the file, missing are the 64KiB of "b"'s of the file, and the 64KiB of 0x03 is parity which is present. But what gets returned as mirrors for a logical address I haven't found a pattern to. Sometimes it's returning data strips, sometimes one data and one parity strip like this example.

I'm guessing this is just an artifact of btrfs-map-logical not being raid56 aware.

Note You need to log in before you can comment on or make changes to this bug.