You are not logged in.

#1 2020-12-13 18:00:20

cdwijs
Member
Registered: 2010-04-24
Posts: 310

[solved]Btrfs raid1 with very slow HD and SSD, howto maximize performa

I have put a laptop 5400 rpm hard drive and a SSD into a btrfs raid1 array. I'm hoping to get the speed of the SSD, and the redundancy of raid1, so I'm basically trying to have my cake and eat it too.

I've run these commands to setup the array. My PC boots OK:

mkfs.btrfs /dev/sda1 #the HD
mount /dev/sda1 /mnt/newarch
clone my arch linux system onto the new btrfs partition, and set the correct UUID in /etc/fstab, as described here:
https://www.rdeeson.com/weblog/157/moving-arch-linux-to-a-new-ssd-with-rsync
Boot from the btrfs drive, and then add the second drive:
btrfs device add /dev/sdb1 -f / #the SSD
btrfs balance start -dconvert=raid1 -mconvert=raid1 /

The current state of the array after the balancing is done:

# df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/sdb1                      187G   40G  110G  27% /
# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 2 FS bytes used 39.35GiB
	devid    1 size 149.05GiB used 40.03GiB path /dev/sdb1
	devid    2 size 223.57GiB used 40.03GiB path /dev/sda1
# btrfs filesystem df /
Data, RAID1: total=39.00GiB, used=38.83GiB
System, RAID1: total=32.00MiB, used=16.00KiB
Metadata, RAID1: total=1.00GiB, used=532.48MiB
GlobalReserve, single: total=84.23MiB, used=0.00B
# btrfs filesystem usage /
Overall:
    Device size:		 372.62GiB
    Device allocated:		  80.06GiB
    Device unallocated:		 292.56GiB
    Device missing:		     0.00B
    Used:			  78.70GiB
    Free (estimated):		 146.45GiB	(min: 146.45GiB)
    Data ratio:			      2.00
    Metadata ratio:		      2.00
    Global reserve:		  84.22MiB	(used: 0.00B)
    Multiple profiles:		        no

Data,RAID1: Size:39.00GiB, Used:38.83GiB (99.56%)
   /dev/sdb1	  39.00GiB
   /dev/sda1	  39.00GiB

Metadata,RAID1: Size:1.00GiB, Used:532.48MiB (52.00%)
   /dev/sdb1	   1.00GiB
   /dev/sda1	   1.00GiB

System,RAID1: Size:32.00MiB, Used:16.00KiB (0.05%)
   /dev/sdb1	  32.00MiB
   /dev/sda1	  32.00MiB

Unallocated:
   /dev/sdb1	 109.02GiB
   /dev/sda1	 183.54GiB

How can I measure the latency and throughput of this array?
How can I optimize the performance?
how can i make btrfs to only use the hard drive when a checksum is incorrect, so that a rebuild of the data is needed?
Why does df report a size of 187G when the smallest drive in the raid1 array is 150GB?

Last edited by cdwijs (2020-12-15 06:25:28)

Offline

#2 2020-12-13 18:11:28

frostschutz
Member
Registered: 2013-11-15
Posts: 1,652

Re: [solved]Btrfs raid1 with very slow HD and SSD, howto maximize performa

mdadm raid1 has a write-mostly flag for such a use case, which means writes will go to both ssd + hdd, but all reads will be served by ssd only (unless ssd fails).

no idea if btrfs offers anything like it

Offline

#3 2020-12-13 19:33:57

cdwijs
Member
Registered: 2010-04-24
Posts: 310

Re: [solved]Btrfs raid1 with very slow HD and SSD, howto maximize performa

It seems the read actions are almost almost exclusively done at /dev/sdb. Sadly, sdb the slow hdd. below is the output from dstat, during the scan of QDirstat

I've created the btrfs filesystem on the slow hdd, and then added the SSD to the array. Could it be btrfs uses the original drive the filesystem was made on as the primary device? how can the primary device be changed?

dstat -tdD total,sda,sdb --nocolor
----system---- -dsk/total- --dsk/sda-- --dsk/sdb--
     time     | read  writ: read  writ: read  writ
13-12 21:23:48|6912k    0 :  16k    0 :6896k    0 
13-12 21:23:49|  13M    0 :   0     0 :  13M    0 
13-12 21:23:50|  11M    0 :   0     0 :  11M    0 
13-12 21:23:51|7888k    0 :   0     0 :7888k    0 
13-12 21:23:52|6080k    0 :   0     0 :6080k    0 
13-12 21:23:53|9104k    0 :  16k    0 :9088k    0 
13-12 21:23:54|8016k    0 :   0     0 :8016k    0 
13-12 21:23:55|8848k    0 :   0     0 :8848k    0 
13-12 21:23:56|  10M    0 :   0     0 :  10M    0 
13-12 21:23:57|  13M    0 :   0     0 :  13M    0 
13-12 21:23:58|7728k    0 :   0     0 :7728k    0 
13-12 21:23:59|  10M    0 :   0     0 :  10M    0 
13-12 21:24:00|  10M  336k:   0   168k:  10M  168k
13-12 21:24:01|7824k    0 :   0     0 :7824k    0 
13-12 21:24:02|6800k    0 :  32k    0 :6768k    0 
13-12 21:24:03|3568k    0 :   0     0 :3568k    0 
13-12 21:24:04|7248k    0 :   0     0 :7248k    0 
13-12 21:24:05|8928k   16k:  32k 8192B:8896k 8192B
13-12 21:24:06|7168k    0 :   0     0 :7168k    0 
13-12 21:24:07|  13M    0 :   0     0 :  13M    0 
13-12 21:24:08|  11M    0 :   0     0 :  11M    0 
13-12 21:24:09|9072k    0 :   0     0 :9072k    0 
13-12 21:24:10|8128k    0 :   0     0 :8128k    0 
13-12 21:24:11|9120k    0 :   0     0 :9120k    0 
13-12 21:24:12|7504k    0 :  16k    0 :7488k    0 
13-12 21:24:13|5824k    0 :   0     0 :5824k    0 
13-12 21:24:14|7760k    0 :   0     0 :7760k    0 
13-12 21:24:15|8784k 5040k:   0  2736k:8784k 2304k
13-12 21:24:16| 896k   47M:   0    24M: 896k   24M
13-12 21:24:17|1136k   56M:   0    28M:1136k   28M
13-12 21:24:18|1216k   62M:   0    31M:1216k   31M
13-12 21:24:19|7008k 1696k:   0   824k:7008k  872k
13-12 21:24:20|5504k  440k:  16k  220k:5488k  220k
13-12 21:24:21|9008k    0 :   0     0 :9008k    0 
13-12 21:24:22|6960k 9072k:2352k 4536k:4608k 4536k
13-12 21:24:23| 720k   44M:   0    22M: 720k   22M
13-12 21:24:24|6480k    0 :   0     0 :6480k    0 
13-12 21:24:25|6096k   72k:   0    36k:6096k   36k
13-12 21:24:26|5808k    0 :   0     0 :5808k    0 
13-12 21:24:27|3696k    0 :   0     0 :3696k    0 
13-12 21:24:28|1312k    0 :   0     0 :1312k    0 
13-12 21:24:29|4096B    0 :   0     0 :4096B    0 
13-12 21:24:30|   0     0 :   0     0 :   0     0 
13-12 21:24:31|   0     0 :   0     0 :   0     0 

Offline

#4 2020-12-15 06:23:01

cdwijs
Member
Registered: 2010-04-24
Posts: 310

Re: [solved]Btrfs raid1 with very slow HD and SSD, howto maximize performa

It's possible to remove the hard drive from the array, and then re-add it. This causes the ID of the hard drive to change from 1 to 3, so the ssd with ID 2 becomes the primary device.

My procedure does involve a two reshufflings of all the data. Is there somebody who know a more efficient method?

# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 2 FS bytes used 39.76GiB
	devid    1 size 149.05GiB used 41.03GiB path /dev/sdb1
	devid    2 size 223.57GiB used 41.03GiB path /dev/sda1
# btrfs balance start -dconvert=single,devid=2 -mconvert=single,devid=2 --force  /
# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 2 FS bytes used 39.76GiB
	devid    1 size 149.05GiB used 0.00B path /dev/sdb1
	devid    2 size 223.57GiB used 42.06GiB path /dev/sda1
# btrfs device delete /dev/sdb1 /
# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 1 FS bytes used 39.76GiB
	devid    2 size 223.57GiB used 42.06GiB path /dev/sda1
# btrfs device add /dev/sdb1 /
# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 2 FS bytes used 39.76GiB
	devid    2 size 223.57GiB used 42.06GiB path /dev/sda1
	devid    3 size 149.05GiB used 0.00B path /dev/sdb1
# btrfs balance start -dconvert=raid1 -mconvert=raid1 /
# btrfs fi show
Label: none  uuid: 485952f9-0cfc-499a-b5c2-5131d34b0372
	Total devices 2 FS bytes used 39.77GiB
	devid    2 size 223.57GiB used 42.06GiB path /dev/sda1
	devid    3 size 149.05GiB used 42.06GiB path /dev/sdb1

Offline

Board footer

Powered by FluxBB