Skip to content

Commit 17de39a

Browse files
Josef Bacikchrismason-xx
authored andcommitted
Btrfs: fix page leak when allocing extent buffers
If we happen to alloc a extent buffer and then alloc a page and notice that page is already attached to an extent buffer, we will only unlock it and free our existing eb. Any pages currently attached to that eb will be properly freed, but we don't do the page_cache_release() on the page where we noticed the other extent buffer which can cause us to leak pages and I hope cause the weird issues we've been seeing in this area. Thanks, Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent e5846fc commit 17de39a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/extent_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,6 +4120,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
41204120
if (atomic_inc_not_zero(&exists->refs)) {
41214121
spin_unlock(&mapping->private_lock);
41224122
unlock_page(p);
4123+
page_cache_release(p);
41234124
mark_extent_buffer_accessed(exists);
41244125
goto free_eb;
41254126
}
@@ -4199,8 +4200,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
41994200
unlock_page(eb->pages[i]);
42004201
}
42014202

4202-
if (!atomic_dec_and_test(&eb->refs))
4203-
return exists;
4203+
WARN_ON(!atomic_dec_and_test(&eb->refs));
42044204
btrfs_release_extent_buffer(eb);
42054205
return exists;
42064206
}

0 commit comments

Comments
 (0)