My btrfs backup script don't work any more (4.0 was OK). It seems that btrfs snapshot leaks memory and finally OOM killer goes mad... Test scrip below demonstrates situation. It seems that ssd disk (/mnt/ssd) is not so bad but traditional disk (/mnt/wd) using RAID1 leaks memory. uname -a Linux xxx.xxx.com 4.1.0-rc6 #1 SMP Mon Jun 1 08:55:34 EEST 2015 x86_64 Intel(R) Xeon(R) CPU E5530 @ 2.40GHz GenuineIntel GNU/Linux gcc-versio 5.1.0 (Gentoo 5.1.0 p1.0, pie-0.6.3) btrfs-progs v4.0.1 btrfs filesystem df /mnt/wd/ Data, RAID1: total=2.28TiB, used=2.26TiB Data, single: total=8.00MiB, used=0.00B System, RAID1: total=8.00MiB, used=368.00KiB System, single: total=4.00MiB, used=0.00B Metadata, RAID1: total=112.50GiB, used=5.77GiB Metadata, single: total=8.00MiB, used=0.00B GlobalReserve, single: total=512.00MiB, used=0.00B btrfs filesystem df /mnt/ssd/ Data, single: total=97.49GiB, used=91.54GiB System, single: total=4.00MiB, used=16.00KiB Metadata, single: total=3.01GiB, used=2.02GiB GlobalReserve, single: total=512.00MiB, used=0.00B #!/bin/bash btrfs subvolume delete /mnt/wd/foo* btrfs subvolume snapshot /mnt/wd/root-vol /mnt/wd/foo while [ 1 ]; do btrfs subvolume delete /mnt/wd/foo1 #btrfs subvolume snapshot -r /mnt/wd/foo /mnt/wd/foo1 btrfs subvolume snapshot /mnt/wd/foo /mnt/wd/foo1 cat /proc/meminfo |grep MemFree done
There is no memory leak if I use traditional scsi_mod.use_blk_mq=0 No leak: GRUB_CMDLINE_LINUX="elevator=cfq scsi_mod.use_blk_mq=0" Memory leak: GRUB_CMDLINE_LINUX="elevator=cfq scsi_mod.use_blk_mq=1" I have not tested latest kernels.
Try a newer kernel as after some looking into recent commits seems this may have been fixed in the 4.5.0 or later merge window. If not send me dmesg logs if their our any to trace down the memory leak.