Skip to content

Commit

Permalink
btrfs: fallback to vmalloc in btrfs_compare_tree
Browse files Browse the repository at this point in the history
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 <jd.girard@sysnux.pf>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
David Sterba committed Apr 4, 2016
1 parent 918c2ee commit 8f282f7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/rbtree.h>
#include <linux/vmalloc.h>
#include "ctree.h"
#include "disk-io.h"
#include "transaction.h"
Expand Down Expand Up @@ -5361,10 +5362,13 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
goto out;
}

tmp_buf = kmalloc(left_root->nodesize, GFP_KERNEL);
tmp_buf = kmalloc(left_root->nodesize, GFP_KERNEL | __GFP_NOWARN);
if (!tmp_buf) {
ret = -ENOMEM;
goto out;
tmp_buf = vmalloc(left_root->nodesize);
if (!tmp_buf) {
ret = -ENOMEM;
goto out;
}
}

left_path->search_commit_root = 1;
Expand Down Expand Up @@ -5565,7 +5569,7 @@ int btrfs_compare_trees(struct btrfs_root *left_root,
out:
btrfs_free_path(left_path);
btrfs_free_path(right_path);
kfree(tmp_buf);
kvfree(tmp_buf);
return ret;
}

Expand Down

0 comments on commit 8f282f7

Please sign in to comment.