]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: always account pinned bytes when dropping a tree block ref
authorOmar Sandoval <osandov@fb.com>
Tue, 6 Jun 2017 23:45:29 +0000 (16:45 -0700)
committerDavid Sterba <dsterba@suse.com>
Thu, 29 Jun 2017 18:17:01 +0000 (20:17 +0200)
commitdee8ba0d47139a4ea9ab4d24f4159d6e601584f4
tree45e7f32dd3253b5604db57d0fe198e6cef81d750
parenteaa4e9f2a314015608a77ea5e3348e763050e83b
Btrfs: always account pinned bytes when dropping a tree block ref

Currently, we only increment total_bytes_pinned in
btrfs_free_tree_block() when dropping the last reference on the block.
However, when the delayed ref is run later, we will decrement
total_bytes_pinned regardless of whether it was the last reference or
not. This causes the counter to underflow when the reference we dropped
was not the last reference. Fix it by incrementing the counter
unconditionally, which is what btrfs_free_extent() does. This makes
total_bytes_pinned an overestimate when references to shared extents are
dropped, but in the worst case this will just make us try to commit the
transaction to try to free up space and find we didn't free enough.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c