Commit 5d2361db authored by Forrest Liu's avatar Forrest Liu Committed by 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: default avatarChien-Kuan Yeh <ckya@synology.com>
Signed-off-by: default avatarForrest Liu <forrestl@synology.com>
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Tested-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment