diff options
author | David Sterba <dsterba@suse.cz> | 2013-02-28 09:54:18 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-02-28 13:33:56 -0500 |
commit | b8dae3138876080d4dd98cc438ff759338d632ef (patch) | |
tree | 0b99ae05e9e656e158261a05f11c2a140124ac49 | |
parent | c58aaad2ac46f8dbce9ab7f7a7a3726e332a56ee (diff) |
btrfs: use only inline_pages from extent buffer
The nodesize is capped at 64k and there are enough pages preallocated in
extent_buffer::inline_pages. The fallback to kmalloc never happened
because even on the smallest page size considered (4k) inline_pages
covered the needs.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-rw-r--r-- | fs/btrfs/extent_io.c | 21 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 3 |
2 files changed, 7 insertions, 17 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 597ab8966c80..0306665cb1d7 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3981,8 +3981,6 @@ static void __free_extent_buffer(struct extent_buffer *eb) | |||
3981 | list_del(&eb->leak_list); | 3981 | list_del(&eb->leak_list); |
3982 | spin_unlock_irqrestore(&leak_lock, flags); | 3982 | spin_unlock_irqrestore(&leak_lock, flags); |
3983 | #endif | 3983 | #endif |
3984 | if (eb->pages && eb->pages != eb->inline_pages) | ||
3985 | kfree(eb->pages); | ||
3986 | kmem_cache_free(extent_buffer_cache, eb); | 3984 | kmem_cache_free(extent_buffer_cache, eb); |
3987 | } | 3985 | } |
3988 | 3986 | ||
@@ -4023,19 +4021,12 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree, | |||
4023 | atomic_set(&eb->refs, 1); | 4021 | atomic_set(&eb->refs, 1); |
4024 | atomic_set(&eb->io_pages, 0); | 4022 | atomic_set(&eb->io_pages, 0); |
4025 | 4023 | ||
4026 | if (len > MAX_INLINE_EXTENT_BUFFER_SIZE) { | 4024 | /* |
4027 | struct page **pages; | 4025 | * Sanity checks, currently the maximum is 64k covered by 16x 4k pages |
4028 | int num_pages = (len + PAGE_CACHE_SIZE - 1) >> | 4026 | */ |
4029 | PAGE_CACHE_SHIFT; | 4027 | BUILD_BUG_ON(BTRFS_MAX_METADATA_BLOCKSIZE |
4030 | pages = kzalloc(num_pages, mask); | 4028 | > MAX_INLINE_EXTENT_BUFFER_SIZE); |
4031 | if (!pages) { | 4029 | BUG_ON(len > MAX_INLINE_EXTENT_BUFFER_SIZE); |
4032 | __free_extent_buffer(eb); | ||
4033 | return NULL; | ||
4034 | } | ||
4035 | eb->pages = pages; | ||
4036 | } else { | ||
4037 | eb->pages = eb->inline_pages; | ||
4038 | } | ||
4039 | 4030 | ||
4040 | return eb; | 4031 | return eb; |
4041 | } | 4032 | } |
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index dc81868d975a..6068a1985560 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -158,8 +158,7 @@ struct extent_buffer { | |||
158 | */ | 158 | */ |
159 | wait_queue_head_t read_lock_wq; | 159 | wait_queue_head_t read_lock_wq; |
160 | wait_queue_head_t lock_wq; | 160 | wait_queue_head_t lock_wq; |
161 | struct page *inline_pages[INLINE_EXTENT_BUFFER_PAGES]; | 161 | struct page *pages[INLINE_EXTENT_BUFFER_PAGES]; |
162 | struct page **pages; | ||
163 | }; | 162 | }; |
164 | 163 | ||
165 | static inline void extent_set_compress_type(unsigned long *bio_flags, | 164 | static inline void extent_set_compress_type(unsigned long *bio_flags, |