6

I have a BTRFS filesystem with a HDDs of various sizes. I thought adding an SSD might allow BTRFS to use it as a caching layer or just another much-faster drive (the docs are a little sparse on this: https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_optimized_for_SSD.3F ). However when I run btrfs fi show /data it shows the SSD as unused:

Total devices 8 FS bytes used 4.29TiB

// SSD moved to the top of the list for easier reading
devid    9 size 223.57GiB used 0.00B path /dev/sda
devid    1 size 2.73TiB used 1.28TiB path /dev/sdb1
devid    5 size 0.00B used 356.00GiB path /dev/sdi1
devid    6 size 1.82TiB used 379.00GiB path /dev/sde1
devid    7 size 4.55TiB used 3.09TiB path /dev/sdh
devid    8 size 3.64TiB used 2.19TiB path /dev/sdc
devid   10 size 2.73TiB used 1.28TiB path /dev/sdf
devid   11 size 1.82TiB used 24.00GiB path /dev/sdg

Also if I run btrfs device usage /data it also reports the SSD as unused:

/dev/sda, ID: 9
Device size:           223.57GiB
Unallocated:           223.57GiB

So I thought I'd check my fstab mount options:

# Mount BTRFS array
UUID=587d228b-5dc3-44e6-b9d9-83df5682d50d       /data   btrfs   defaults,noatime,space_cache,discard    0       0

As far as I can tell these are all pretty standard.

Is this normal, how can I tell if BTRFS is actually using the drive at all? (I may be totally mistaken and BTRFS might not even support this use case at all)

3
  • 1
    I don't see any operations in the btrfs tool that would allow you to specify how to use a device. What you can do is control the RAID level to specify how the data is spread out across the device pool. As for the device usage, did you already re-balance the filesystem? Mar 29, 2017 at 18:24
  • The filesystem has been rebalanced, seemingly to no effect. I'm tempted to add another identical SSD to see if it needs two SSDs before trying to utilise them in a RAID 1 array. This is total guesswork though. I should probably just read the code.
    – Foritus
    Mar 29, 2017 at 19:12
  • 1
    There's a similar discussion here: unix.stackexchange.com/questions/623460/… Dec 13, 2020 at 1:00

1 Answer 1

2

Just adding a device to a BTRFS pool doesn't automatically move any data to it, you have to write new data to the pool and the balancer will decide which device it puts the data on.
The next chunk is very likely to be created on a newly added device though since it's 0% allocated (the balancer tries to fill up all devices equally).

If you want to make already written data go through the balancer again, you need to use the btrfs balance command.

All data that is put on the SSD will be faster than the data on the HDDs but there is no speed aware balancing in place, so which data is fast and which isn't is pretty much random and cannot be manually controlled either.

2
  • FYI, the old mdraid code does allow you to specify fast and slow devices: you mark the spindles as "write-mostly". Then all reads will come from the SSD, thus fast. Writes are fast too, because a "write-behind" bitmap is used: the writes are immediate to the SSD and eventually get to the spindle, without delaying the writing process. It'd be nice if btrfs could do this?
    – Linas
    Feb 3 at 18:27
  • Neat, didn't know that. Would be great if btrfs could do that but I guess nobody bothers to implement it since bcachefs will do that sort of thing much better anyways.
    – Atemu
    Feb 4 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .