Skip to content

Commit 8f282f7

Browse files
committed
btrfs: fallback to vmalloc in btrfs_compare_tree
The allocation of node could fail if the memory is too fragmented for a given node size, practically observed with 64k. http://article.gmane.org/gmane.comp.file-systems.btrfs/54689 Reported-and-tested-by: Jean-Denis Girard <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 918c2ee commit 8f282f7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fs/btrfs/ctree.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/sched.h>
2020
#include <linux/slab.h>
2121
#include <linux/rbtree.h>
22+
#include <linux/vmalloc.h>
2223
#include "ctree.h"
2324
#include "disk-io.h"
2425
#include "transaction.h"
@@ -5361,10 +5362,13 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
53615362
goto out;
53625363
}
53635364

5364-
tmp_buf = kmalloc(left_root->nodesize, GFP_KERNEL);
5365+
tmp_buf = kmalloc(left_root->nodesize, GFP_KERNEL | __GFP_NOWARN);
53655366
if (!tmp_buf) {
5366-
ret = -ENOMEM;
5367-
goto out;
5367+
tmp_buf = vmalloc(left_root->nodesize);
5368+
if (!tmp_buf) {
5369+
ret = -ENOMEM;
5370+
goto out;
5371+
}
53685372
}
53695373

53705374
left_path->search_commit_root = 1;
@@ -5565,7 +5569,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
55655569
out:
55665570
btrfs_free_path(left_path);
55675571
btrfs_free_path(right_path);
5568-
kfree(tmp_buf);
5572+
kvfree(tmp_buf);
55695573
return ret;
55705574
}
55715575

0 commit comments

Comments
 (0)