btrfs gets very slow, metadata almost full
One of our storage servers that has had problems in the past. Originally it seemed like XFS was having a problem with the large filesystem, so, we gambled and decided to use btrfs. After eight days running, the machine has gotten extremely slow for disk I/O to the point where backups that should take minutes, were taking hours.
Switching the disk scheduler from cfq to noop to deadline appeared to have only short-term benefits at which point the machine bogged down again.
We’re running an Adaptec 31205 with 11 Western Digital 2.0 terabyte drives in hardware Raid 5 with roughly 19 terabytes accessible on our filesystem. During the first few days of backups, we would easily hit 800mb/sec inbound, but, after a few machines had been backed up to the server, 100mb/sec was optimistic with 20-40mb/sec being more normal. We originally attributed this to rsync of thousands of smaller files rather than the large files moved on some of the earlier machines. Once we started overlapping machines to get their second generational backup, the problem was much more evident.
# df -h /colobk1 Filesystem Size Used Avail Use% Mounted on /dev/sda8 19T 8.6T 9.6T 48% /colobk1 # btrfs fi show Label: none uuid: 3cd405c7-5d7d-42bd-a630-86ec3ca452d7 Total devices 1 FS bytes used 8.44TB devid 1 size 18.14TB used 8.55TB path /dev/sda8 Btrfs Btrfs v0.19 # btrfs filesystem df /colobk1 Data: total=8.34TB, used=8.34TB System, DUP: total=8.00MB, used=940.00KB System: total=4.00MB, used=0.00 Metadata, DUP: total=106.25GB, used=104.91GB Metadata: total=8.00MB, used=0.00
# uname -a Linux st1 3.8.0 #1 SMP Tue Feb 19 16:09:18 EST 2013 x86_64 GNU/Linux # btrfs --version Btrfs Btrfs v0.19
As it stands, we appear to be running out of Metadata space. Since our used metadata space is more than 75% of our total metadata space, updates are taking forever. The initial filesystem was not created with any special inode or leaf parameters, so, it is using the defaults.
The btrfs wiki points to this particular tuning option which seems like it might do the trick. Since you can run the balance while the filesystem is in use and check its status, we should be able to see whether it is making a difference.
I don’t believe it is going to make a difference as we have only a single device exposed to btrfs, but, here’s the command we’re told to use:
btrfs fi balance start -dusage=5 /colobk1
After a while, the box returned with:
# btrfs fi balance start -dusage=5 /colobk1 Done, had to relocate 0 out of 8712 chunks # btrfs fi df /colobk1 Data: total=8.34TB, used=8.34TB System, DUP: total=8.00MB, used=940.00KB System: total=4.00MB, used=0.00 Metadata, DUP: total=107.25GB, used=104.95GB Metadata: total=8.00MB, used=0.00
So it added 1GB to the metadata size. At first glance, it is still taking considerable time to do the backup of a single machine of 9.7gb – over 2 hours and 8 minutes when the first backup took under 50 minutes. I would say that the balance didn’t do anything positive as we have a single device. I suspect that the leafsize and nodesize might be the difference here – requiring a format and backup of 8.6 terabytes of data again. It took two and a half minutes to unmount the partition after it had bogged down and after running the balance.
mkfs -t btrfs -l 32768 -n 32768 /dev/sda8 # btrfs fi df /colobk1 Data: total=8.00MB, used=0.00 System, DUP: total=8.00MB, used=32.00KB System: total=4.00MB, used=0.00 Metadata, DUP: total=1.00GB, used=192.00KB Metadata: total=8.00MB, used=0.00 # df -h /colobk1 Filesystem Size Used Avail Use% Mounted on /dev/sda8 19T 72M 19T 1% /colobk1
XFS took 52 minutes to back up the machine. XFS properly tuned took 51 minutes. Btrfs tested with the leafnode set took 51 minutes. I suspect I need to run things for a week to get the extent’s close to filled again and check it again. In any case, it is a lot faster than it was with the default settings.