diff options
author | Chris Mason <clm@fb.com> | 2016-01-27 05:48:23 -0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-01-27 05:48:23 -0800 |
commit | d32a4e34348869a273a01139112a13fc6870f003 (patch) | |
tree | 507adf3bf14d2cafb38502c27ea8cc82b28cf11a /fs/btrfs/free-space-tree.c | |
parent | bf6092066f80840410e3401cd962b23d54a95713 (diff) | |
parent | 3e4c5efbb3ac7c9c4fb5f33b659fa98afe568ab1 (diff) |
Merge branch 'dev/fst-followup' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.5
Diffstat (limited to 'fs/btrfs/free-space-tree.c')
-rw-r--r-- | fs/btrfs/free-space-tree.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 94e887f5ec4e..dfa8124effb8 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -154,6 +154,20 @@ static inline u32 free_space_bitmap_size(u64 size, u32 sectorsize) static unsigned long *alloc_bitmap(u32 bitmap_size) { + void *mem; + + /* + * The allocation size varies, observed numbers were < 4K up to 16K. + * Using vmalloc unconditionally would be too heavy, we'll try + * contiguous allocations first. + */ + if (bitmap_size <= PAGE_SIZE) + return kzalloc(bitmap_size, GFP_NOFS); + + mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_HIGHMEM | __GFP_NOWARN); + if (mem) + return mem; + return __vmalloc(bitmap_size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL); } @@ -290,7 +304,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, ret = 0; out: - vfree(bitmap); + kvfree(bitmap); if (ret) btrfs_abort_transaction(trans, root, ret); return ret; @@ -439,7 +453,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, ret = 0; out: - vfree(bitmap); + kvfree(bitmap); if (ret) btrfs_abort_transaction(trans, root, ret); return ret; |