btrfs: Fix leaking bytes_may_use after hitting EDQUOTA
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Tue, 28 Jun 2016 01:57:29 +0000 (09:57 +0800)
committerDavid Sterba <dsterba@suse.com>
Fri, 9 Sep 2016 08:56:00 +0000 (10:56 +0200)
commit3c8bf9268f09e1bf55e016ed9ed5c3eab7d1deef
tree7ba20c3a78846f1793ea133140103fb53ecdc219
parent465a5081cb11748887e3505e86e2513e182b10de
btrfs: Fix leaking bytes_may_use after hitting EDQUOTA

If one mount btrfs with enospc_debug mount option and hit qgroup limits
in btrfs_check_data_free_space(), then at unmount time, kernel warning
will be triggered alone with a data space info dump.
------
------------[ cut here ]------------
WARNING: CPU: 0 PID: 3875 at fs/btrfs/extent-tree.c:9785
btrfs_free_block_groups+0x2b8/0x460 [btrfs]
Modules linked in: btrfs ext4 jbd2 mbcache xor zlib_deflate raid6_pq xfs
[last unloaded: btrfs]
CPU: 0 PID: 3875 Comm: umount Tainted: G        W       4.7.0-rc4+ #13
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox
12/01/2006
 0000000000000000 ffff8800230a7d00 ffffffff813b89e5 0000000000000000
 0000000000000000 ffff8800230a7d40 ffffffff810c9b8b 00002639230a7d50
 ffff88003d523a78 ffff88003d523b80 ffff88000d1c0000 ffff88000d1c00c8
Call Trace:
 [<ffffffff813b89e5>] dump_stack+0x67/0x92
 [<ffffffff810c9b8b>] __warn+0xcb/0xf0
 [<ffffffff810c9c7d>] warn_slowpath_null+0x1d/0x20
 [<ffffffffa0367508>] btrfs_free_block_groups+0x2b8/0x460 [btrfs]
 [<ffffffffa03792e3>] close_ctree+0x173/0x350 [btrfs]
 [<ffffffffa0348f39>] btrfs_put_super+0x19/0x20 [btrfs]
 [<ffffffff812449aa>] generic_shutdown_super+0x6a/0xf0
 [<ffffffff81244ca2>] kill_anon_super+0x12/0x20
 [<ffffffffa0349728>] btrfs_kill_super+0x18/0x110 [btrfs]
 [<ffffffff81244f1e>] deactivate_locked_super+0x3e/0x70
 [<ffffffff8124536c>] deactivate_super+0x5c/0x60
 [<ffffffff812667ef>] cleanup_mnt+0x3f/0x90
 [<ffffffff81266882>] __cleanup_mnt+0x12/0x20
 [<ffffffff810ecbd1>] task_work_run+0x81/0xc0
 [<ffffffff810022f3>] exit_to_usermode_loop+0xb3/0xc0
 [<ffffffff81002dc0>] syscall_return_slowpath+0xb0/0xc0
 [<ffffffff81885f73>] entry_SYSCALL_64_fastpath+0xa6/0xa8
---[ end trace 99b9af8484495c66 ]---
BTRFS: space_info 1 has 8044544 free, is not full
BTRFS: space_info total=8388608, used=344064, pinned=0, reserved=0,
may_use=409600, readonly=0
------

The problem is in btrfs_check_data_free_space(), we reserve data space
first and then reserve qgroup space.
However if qgroup reserve failed, we didn't cleanup reserved data space,
which leads to the kernel warning.

Fix it by freeing reserved data space when qgroup_reserve_data() fails.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c
This page took 0.030419 seconds and 5 git commands to generate.