Bug 99511 - btrfs snapshot leaks memory
Summary: btrfs snapshot leaks memory
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-06 16:53 UTC by Markus Suvanto
Modified: 2016-04-10 03:26 UTC (History)
3 users (show)

See Also:
Kernel Version: 4.1.0-rc6
Tree: Mainline
Regression: Yes


Attachments

Description Markus Suvanto 2015-06-06 16:53:42 UTC
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
Comment 1 Markus Suvanto 2016-03-29 13:37:50 UTC
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.
Comment 2 [account disabled by administrator] 2016-04-10 03:26:36 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.