Peter Becker posted on Sat, 10 Oct 2015 21:48:31 +0200 as excerpted:

> btrfs balance start -m /media/RAID
> 
> complete with out any error but the resulte of device usage is confusing
> me.
> Metadata on sdb and sdc are 2 GiB, but on sdd (the new added device)
> is 4 GiB. And the 2. one that's confusing me, is that sdd has a "System"
> entry but sdb and sdc dosn't
> 
> floyd@nas ~ $ sudo btrfs dev us /media/RAID/
> /dev/sdb, ID: 1
>    Device size:             2.73TiB
>    Data,RAID1:              2.11TiB
>    Metadata,RAID1:          2.00GiB
>    System,RAID1:           32.00MiB
>    Unallocated:           628.49GiB
> 
> /dev/sdc, ID: 2
>    Device size:             2.73TiB
>    Data,RAID1:              2.11TiB
>    Metadata,RAID1:          2.00GiB
>    Unallocated:           628.52GiB
> 
> /dev/sdd, ID: 3
>    Device size:             2.73TiB
>    Data,RAID1:            792.00GiB
>    Metadata,RAID1:          4.00GiB
>    System,RAID1:           32.00MiB
>    Unallocated:             1.95TiB

FWIW, there's also btrfs fi usage, which prints a somewhat different 
layout of pretty much the same statistics.  It may be useful to compare 
output styles and choose the one you prefer.  I prefer fi usage to dev 
usage in most cases, but YMMV.

The key thing to remember about btrfs raid1 on more than two devices is 
that it's exactly two copies, not N copies, where N is the number of 
devices.  In a three-device raid1, by definition, for each chunk that 
will mean one copy each on two devices, with the third device not getting 
a copy of that particular chunk, since btrfs raid1 is exactly two copies, 
no more, no less.

So system is raid1, and sdb and sdd each have a copy of the (apparently 
just one) system chunk, one copy each for two copies total, leaving no 
system chunk to be placed on sdc, which is why it has none.

And, given the stats, there are 4 GiB of raid1 metadata chunks comprising 
two copies of 2 GiB worth of metadata.  Half that metadata has a copy 
each on sdb and sdd, while the other half has a copy each on sdc and sdd.  
IOW, sdd has a copy of all metadata, but sdb and sdc only have a copy of 
half the metadata each.

Since the chunk allocator creates new chunks on the device with the most 
available space, subject to the restriction that for raid1, there's two 
copies and both copies cannot be on the same device, because sdd was 
recently added and thus the one most empty, when you ran the metadata 
balance, it created one copy of the raid1 two copies on the new device as 
it had the most free space, and then had to select one of the other two 
devices for the other copy.  Since the other two devices were basically 
evenly filled, it alternated, selecting one and then the other, so each 
one got the second copy of half of the metadata, while the new device 
with the most free space got the first copy of all metadata as it was 
rewritten by the balance.

-- 
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

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

Reply via email to