提交 5d2361db 编写于 作者: F Forrest Liu 提交者: Chris Mason

Btrfs: btrfs_release_extent_buffer_page didn't free pages of dummy extent

btrfs_release_extent_buffer_page() can't handle dummy extent that
allocated by btrfs_clone_extent_buffer() properly. That is because
reference count of pages that allocated by btrfs_clone_extent_buffer()
was 2, 1 by alloc_page(), and another by attach_extent_buffer_page().

Running following command repeatly can check this memory leak problem

    btrfs inspect-internal inode-resolve 256 /mnt/btrfs
Signed-off-by: NChien-Kuan Yeh <ckya@synology.com>
Signed-off-by: NForrest Liu <forrestl@synology.com>
Reviewed-by: NFilipe Manana <fdmanana@suse.com>
Tested-by: NFilipe Manana <fdmanana@suse.com>
Signed-off-by: NChris Mason <clm@fb.com>
上级 6e17d30b
......@@ -4560,7 +4560,9 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
do {
index--;
page = eb->pages[index];
if (page && mapped) {
if (!page)
continue;
if (mapped)
spin_lock(&page->mapping->private_lock);
/*
* We do this since we'll remove the pages after we've
......@@ -4583,13 +4585,12 @@ static void btrfs_release_extent_buffer_page(struct extent_buffer *eb)
/* One for the page private */
page_cache_release(page);
}
if (mapped)
spin_unlock(&page->mapping->private_lock);
}
if (page) {
/* One for when we alloced the page */
page_cache_release(page);
}
} while (index != 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册