linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org, nborisov@suse.com
Subject: Re: xfstests generic/476 failed on btrfs(errno=-12 Out of memory, kernel 5.11.10)
Date: Tue, 30 Mar 2021 14:24:46 +0800	[thread overview]
Message-ID: <20210330142446.AB2E.409509F4@e16-tech.com> (raw)
In-Reply-To: <20210328185609.D969.409509F4@e16-tech.com>

[-- Attachment #1: Type: text/plain, Size: 2729 bytes --]

Hi, Nikolay Borisov

With a lot of dump_stack()/printk inserted around ENOMEM in btrfs code,
we find out the call stack for ENOMEM.
see the file 0000-btrfs-dump_stack-when-ENOMEM.patch


#cat /usr/hpc-bio/xfstests/results//generic/476.dmesg
...
[ 5759.102929] ENOMEM btrfs_drew_lock_init
[ 5759.102943] ENOMEM btrfs_init_fs_root
[ 5759.102947] ------------[ cut here ]------------
[ 5759.102950] BTRFS: Transaction aborted (error -12)
[ 5759.103052] WARNING: CPU: 14 PID: 2741468 at /ssd/hpc-bio/linux-5.10.27/fs/btrfs/transaction.c:1705 create_pending_snapshot+0xb8c/0xd50 [btrfs]
...


btrfs_drew_lock_init() return -ENOMEM, 
this is the source:

    /*
     * We might be called under a transaction (e.g. indirect backref
     * resolution) which could deadlock if it triggers memory reclaim
     */
    nofs_flag = memalloc_nofs_save();
    ret = btrfs_drew_lock_init(&root->snapshot_lock);
    memalloc_nofs_restore(nofs_flag);
    if (ret == -ENOMEM) printk("ENOMEM btrfs_drew_lock_init\n");
    if (ret)
        goto fail;

And the souce come from:

commit dcc3eb9638c3c927f1597075e851d0a16300a876
Author: Nikolay Borisov <nborisov@suse.com>
Date:   Thu Jan 30 14:59:45 2020 +0200

    btrfs: convert snapshot/nocow exlcusion to drew lock


Any advice to fix this ENOMEM problem?

top command show that this server have engough memory.

The hardware of this server:
CPU:  Xeon(R) CPU E5-2660 v2(10 core)  *2
memory:  192G, no swap


> > kmem_cache_zalloc() without __GFP_NOFAIL may fail.
> > 
> > btrfs use kmem_cache_zalloc() with GFP_NOFS mostly, 
> > and only few place with __GFP_NOFAIL.
> > 
> > xfs use kmem_cache_zalloc() with __GFP_NOFAIL mostly.
> > 
> > It is very difficult to test all case of failure in kmem_cache_zalloc() .
> > 
> > Should btrfs use kmem_cache_zalloc() with __GFP_NOFAIL just like xfs  
> > or use mempool with pre-alloc to prevent fail?
> 
> I tried both way.
> 
> 1) add __GFP_NOFAIL to kmem_cache_zalloc()
> see 0001-btrfs-add-__GFP_NOFAIL-to-kmem_cache.patch
> 
> but this problem still happened in test.
> 
> 
> 2) switch to  use mempool_t for btrfs_path
> see 0001-btrfs-switch-to-mempool_t-for-btrfs_path.patch
> 
> this problem yet not happen in test.
> 
> But the memory alloc failure is difficult to test, we need more review.

more test result show that this problem still happen with the mempool_t
patch.


with more source check, we found out this info is wrong
> these callstack have a same root failure.
> struct btrfs_path *btrfs_alloc_path(void)
> {
>     return kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS);
> }



Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2021/03/29



[-- Attachment #2: 0000-btrfs-dump_stack-when-ENOMEM.patch --]
[-- Type: application/octet-stream, Size: 141746 bytes --]

From adfdc423f80ab379f14751ac9e9cdf11b2e201fd Mon Sep 17 00:00:00 2001
From: wangyugui <wangyugui@e16-tech.com>
Date: Tue, 30 Mar 2021 14:02:52 +0800
Subject: [PATCH] btrfs: dump_stack when ENOMEM

---
 fs/btrfs/acl.c              |   4 +-
 fs/btrfs/backref.c          |  34 ++++-----
 fs/btrfs/block-group.c      |  22 +++---
 fs/btrfs/check-integrity.c  |   8 +-
 fs/btrfs/compression.c      |   4 +-
 fs/btrfs/ctree.c            |  32 ++++----
 fs/btrfs/delayed-inode.c    |  20 ++---
 fs/btrfs/delayed-ref.c      |  16 ++--
 fs/btrfs/dev-replace.c      |   8 +-
 fs/btrfs/dir-item.c         |   4 +-
 fs/btrfs/disk-io.c          |  35 +++++----
 fs/btrfs/export.c           |   4 +-
 fs/btrfs/extent-tree.c      |  30 ++++----
 fs/btrfs/extent_io.c        |  28 +++----
 fs/btrfs/extent_map.c       |   2 +-
 fs/btrfs/file-item.c        |  10 +--
 fs/btrfs/file.c             |  18 ++---
 fs/btrfs/free-space-cache.c |  22 +++---
 fs/btrfs/free-space-tree.c  |  20 ++---
 fs/btrfs/inode-item.c       |   8 +-
 fs/btrfs/inode.c            |  70 ++++++++---------
 fs/btrfs/ioctl.c            |  44 +++++------
 fs/btrfs/lzo.c              |   8 +-
 fs/btrfs/ordered-data.c     |   4 +-
 fs/btrfs/orphan.c           |   4 +-
 fs/btrfs/props.c            |   4 +-
 fs/btrfs/qgroup.c           |  54 ++++++-------
 fs/btrfs/raid56.c           |  10 +--
 fs/btrfs/reada.c            |   4 +-
 fs/btrfs/ref-verify.c       |  14 ++--
 fs/btrfs/reflink.c          |   7 +-
 fs/btrfs/relocation.c       |  42 +++++------
 fs/btrfs/root-tree.c        |  10 +--
 fs/btrfs/scrub.c            |  36 ++++-----
 fs/btrfs/send.c             | 146 ++++++++++++++++++------------------
 fs/btrfs/space-info.c       |   2 +-
 fs/btrfs/subpage.c          |   2 +-
 fs/btrfs/super.c            |  26 +++----
 fs/btrfs/sysfs.c            |  14 ++--
 fs/btrfs/transaction.c      |   6 +-
 fs/btrfs/tree-defrag.c      |   2 +-
 fs/btrfs/tree-log.c         |  66 ++++++++--------
 fs/btrfs/ulist.c            |   2 +-
 fs/btrfs/uuid-tree.c        |   8 +-
 fs/btrfs/volumes.c          |  72 +++++++++---------
 fs/btrfs/xattr.c            |   8 +-
 fs/btrfs/zlib.c             |  10 +--
 fs/btrfs/zoned.c            |  14 ++--
 fs/btrfs/zstd.c             |  10 +--
 49 files changed, 518 insertions(+), 510 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index a0af1b9..5c381f7 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -38,7 +38,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
 	if (size > 0) {
 		value = kzalloc(size, GFP_KERNEL);
 		if (!value)
-			return ERR_PTR(-ENOMEM);
+			{dump_stack();return ERR_PTR(-ENOMEM);}
 		size = btrfs_getxattr(inode, name, value, size);
 	}
 	if (size > 0)
@@ -84,7 +84,7 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans,
 		value = kmalloc(size, GFP_KERNEL);
 		memalloc_nofs_restore(nofs_flag);
 		if (!value) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index f47c152..244e32e 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -52,7 +52,7 @@ static int check_extent_in_eb(const struct btrfs_key *key,
 
 	e = kmalloc(sizeof(*e), GFP_NOFS);
 	if (!e)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	e->next = *eie;
 	e->inum = key->objectid;
@@ -154,7 +154,7 @@ int __init btrfs_prelim_ref_init(void)
 					SLAB_MEM_SPREAD,
 					NULL);
 	if (!btrfs_prelim_ref_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	return 0;
 }
 
@@ -345,7 +345,7 @@ static int add_prelim_ref(const struct btrfs_fs_info *fs_info,
 
 	ref = kmem_cache_alloc(btrfs_prelim_ref_cache, gfp_mask);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ref->root_id = root_id;
 	if (key)
@@ -677,7 +677,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
 
 	parents = ulist_alloc(GFP_NOFS);
 	if (!parents)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * We could trade memory usage for performance here by iterating
@@ -740,7 +740,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info,
 						   GFP_NOFS);
 			if (!new_ref) {
 				free_pref(ref);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			memcpy(new_ref, ref, sizeof(*ref));
@@ -1193,7 +1193,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	if (!trans) {
 		path->search_commit_root = 1;
 		path->skip_locking = 1;
@@ -1419,7 +1419,7 @@ int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
 
 	*leafs = ulist_alloc(GFP_NOFS);
 	if (!*leafs)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = find_parent_nodes(trans, fs_info, bytenr, time_seq,
 				*leafs, NULL, extent_item_pos, NULL, ignore_offset);
@@ -1456,11 +1456,11 @@ static int btrfs_find_all_roots_safe(struct btrfs_trans_handle *trans,
 
 	tmp = ulist_alloc(GFP_NOFS);
 	if (!tmp)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	*roots = ulist_alloc(GFP_NOFS);
 	if (!*roots) {
 		ulist_free(tmp);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	ULIST_ITER_INIT(&uiter);
@@ -2078,7 +2078,7 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root,
 		slot = path->slots[0];
 		eb = btrfs_clone_extent_buffer(path->nodes[0]);
 		if (!eb) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			break;
 		}
 		btrfs_release_path(path);
@@ -2137,7 +2137,7 @@ static int iterate_inode_extrefs(u64 inum, struct btrfs_root *fs_root,
 		slot = path->slots[0];
 		eb = btrfs_clone_extent_buffer(path->nodes[0]);
 		if (!eb) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			break;
 		}
 		btrfs_release_path(path);
@@ -2250,7 +2250,7 @@ struct btrfs_data_container *init_data_container(u32 total_bytes)
 	alloc_bytes = max_t(size_t, total_bytes, sizeof(*data));
 	data = kvmalloc(alloc_bytes, GFP_KERNEL);
 	if (!data)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	if (total_bytes >= sizeof(*data)) {
 		data->bytes_left = total_bytes - sizeof(*data);
@@ -2285,7 +2285,7 @@ struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
 	ifp = kmalloc(sizeof(*ifp), GFP_KERNEL);
 	if (!ifp) {
 		kvfree(fspath);
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	}
 
 	ifp->btrfs_path = path;
@@ -2638,7 +2638,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
 
 	edge = btrfs_backref_alloc_edge(cache);
 	if (!edge)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	rb_node = rb_simple_search(&cache->rb_root, ref_key->offset);
 	if (!rb_node) {
@@ -2647,7 +2647,7 @@ static int handle_direct_tree_backref(struct btrfs_backref_cache *cache,
 					   cur->level + 1);
 		if (!upper) {
 			btrfs_backref_free_edge(cache, edge);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 
 		/*
@@ -2768,7 +2768,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
 		edge = btrfs_backref_alloc_edge(cache);
 		if (!edge) {
 			btrfs_put_root(root);
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 
@@ -2780,7 +2780,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
 			if (!upper) {
 				btrfs_put_root(root);
 				btrfs_backref_free_edge(cache, edge);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			upper->owner = btrfs_header_owner(eb);
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index f3e7ab0..023ea00 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -524,7 +524,7 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	last = max_t(u64, block_group->start, BTRFS_SUPER_INFO_OFFSET);
 
@@ -731,7 +731,7 @@ int btrfs_cache_block_group(struct btrfs_block_group *cache, int load_cache_only
 
 	caching_ctl = kzalloc(sizeof(*caching_ctl), GFP_NOFS);
 	if (!caching_ctl)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	INIT_LIST_HEAD(&caching_ctl->list);
 	mutex_init(&caching_ctl->mutex);
@@ -905,7 +905,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1633,7 +1633,7 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
 
 	buf = kcalloc(map->num_stripes, sizeof(u64), GFP_NOFS);
 	if (!buf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1857,7 +1857,7 @@ static int read_one_block_group(struct btrfs_fs_info *info,
 
 	cache = btrfs_create_block_group_cache(info, key->objectid);
 	if (!cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	cache->length = key->offset;
 	cache->used = btrfs_stack_block_group_used(bgi);
@@ -1979,7 +1979,7 @@ static int fill_dummy_bgs(struct btrfs_fs_info *fs_info)
 		map = em->map_lookup;
 		bg = btrfs_create_block_group_cache(fs_info, em->start);
 		if (!bg) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			break;
 		}
 
@@ -2026,7 +2026,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 	key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	cache_gen = btrfs_super_cache_generation(info->super_copy);
 	if (btrfs_test_opt(info, SPACE_CACHE) &&
@@ -2200,7 +2200,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
 
 	cache = btrfs_create_block_group_cache(fs_info, chunk_offset);
 	if (!cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	cache->length = size;
 	set_free_space_tree_thresholds(cache);
@@ -2598,7 +2598,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* Could add new block groups, use _safe just in case */
 	list_for_each_entry_safe(cache, tmp, &cur_trans->dirty_bgs,
@@ -2651,7 +2651,7 @@ again:
 	if (!path) {
 		path = btrfs_alloc_path();
 		if (!path) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 	}
@@ -2804,7 +2804,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * Even though we are in the critical section of the transaction commit,
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 6ff44e5..98b757f 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -631,7 +631,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state,
 
 	selected_super = kzalloc(sizeof(*selected_super), GFP_NOFS);
 	if (!selected_super)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	list_for_each_entry(device, dev_head, dev_list) {
 		int i;
@@ -1597,7 +1597,7 @@ static int btrfsic_read_block(struct btrfsic_state *state,
 	size = sizeof(*block_ctx->datav) + sizeof(*block_ctx->pagev);
 	block_ctx->mem_to_free = kcalloc(num_pages, size, GFP_NOFS);
 	if (!block_ctx->mem_to_free)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	block_ctx->datav = block_ctx->mem_to_free;
 	block_ctx->pagev = (struct page **)(block_ctx->datav + num_pages);
 	for (i = 0; i < num_pages; i++) {
@@ -2782,7 +2782,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
 	}
 	state = kvzalloc(sizeof(*state), GFP_KERNEL);
 	if (!state)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (!btrfsic_is_initialized) {
 		mutex_init(&btrfsic_mutex);
@@ -2811,7 +2811,7 @@ int btrfsic_mount(struct btrfs_fs_info *fs_info,
 		ds = btrfsic_dev_state_alloc();
 		if (NULL == ds) {
 			mutex_unlock(&btrfsic_mutex);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 		ds->bdev = device->bdev;
 		ds->state = state;
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 3f4c832..e55f7d3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -867,7 +867,7 @@ static struct list_head *alloc_heuristic_ws(unsigned int level)
 
 	ws = kzalloc(sizeof(*ws), GFP_KERNEL);
 	if (!ws)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	ws->sample = kvmalloc(MAX_SAMPLE_SIZE, GFP_KERNEL);
 	if (!ws->sample)
@@ -885,7 +885,7 @@ static struct list_head *alloc_heuristic_ws(unsigned int level)
 	return &ws->list;
 fail:
 	free_heuristic_ws(&ws->list);
-	return ERR_PTR(-ENOMEM);
+	{dump_stack();return ERR_PTR(-ENOMEM);}
 }
 
 const struct btrfs_compress_op btrfs_heuristic_compress = {
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 34b929b..1bc1766 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -464,7 +464,7 @@ static noinline int tree_mod_log_insert_key(struct extent_buffer *eb, int slot,
 
 	tm = alloc_tree_mod_elem(eb, slot, op, flags);
 	if (!tm)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (tree_mod_dont_log(eb->fs_info, eb)) {
 		kfree(tm);
@@ -493,11 +493,11 @@ static noinline int tree_mod_log_insert_move(struct extent_buffer *eb,
 
 	tm_list = kcalloc(nr_items, sizeof(struct tree_mod_elem *), GFP_NOFS);
 	if (!tm_list)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	tm = kzalloc(sizeof(*tm), GFP_NOFS);
 	if (!tm) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto free_tms;
 	}
 
@@ -511,7 +511,7 @@ static noinline int tree_mod_log_insert_move(struct extent_buffer *eb,
 		tm_list[i] = alloc_tree_mod_elem(eb, i + dst_slot,
 		    MOD_LOG_KEY_REMOVE_WHILE_MOVING, GFP_NOFS);
 		if (!tm_list[i]) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_tms;
 		}
 	}
@@ -591,14 +591,14 @@ static noinline int tree_mod_log_insert_root(struct extent_buffer *old_root,
 		tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *),
 				  GFP_NOFS);
 		if (!tm_list) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_tms;
 		}
 		for (i = 0; i < nritems; i++) {
 			tm_list[i] = alloc_tree_mod_elem(old_root, i,
 			    MOD_LOG_KEY_REMOVE_WHILE_FREEING, GFP_NOFS);
 			if (!tm_list[i]) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto free_tms;
 			}
 		}
@@ -606,7 +606,7 @@ static noinline int tree_mod_log_insert_root(struct extent_buffer *old_root,
 
 	tm = kzalloc(sizeof(*tm), GFP_NOFS);
 	if (!tm) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto free_tms;
 	}
 
@@ -727,7 +727,7 @@ static noinline int tree_mod_log_eb_copy(struct extent_buffer *dst,
 	tm_list = kcalloc(nr_items * 2, sizeof(struct tree_mod_elem *),
 			  GFP_NOFS);
 	if (!tm_list)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	tm_list_add = tm_list;
 	tm_list_rem = tm_list + nr_items;
@@ -735,14 +735,14 @@ static noinline int tree_mod_log_eb_copy(struct extent_buffer *dst,
 		tm_list_rem[i] = alloc_tree_mod_elem(src, i + src_offset,
 		    MOD_LOG_KEY_REMOVE, GFP_NOFS);
 		if (!tm_list_rem[i]) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_tms;
 		}
 
 		tm_list_add[i] = alloc_tree_mod_elem(dst, i + dst_offset,
 		    MOD_LOG_KEY_ADD, GFP_NOFS);
 		if (!tm_list_add[i]) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_tms;
 		}
 	}
@@ -794,13 +794,13 @@ static noinline int tree_mod_log_free_eb(struct extent_buffer *eb)
 	nritems = btrfs_header_nritems(eb);
 	tm_list = kcalloc(nritems, sizeof(struct tree_mod_elem *), GFP_NOFS);
 	if (!tm_list)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	for (i = 0; i < nritems; i++) {
 		tm_list[i] = alloc_tree_mod_elem(eb, i,
 		    MOD_LOG_KEY_REMOVE_WHILE_FREEING, GFP_NOFS);
 		if (!tm_list[i]) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_tms;
 		}
 	}
@@ -2495,7 +2495,7 @@ static struct extent_buffer *btrfs_search_slot_get_root(struct btrfs_root *root,
 			b = btrfs_clone_extent_buffer(root->commit_root);
 			up_read(&fs_info->commit_root_sem);
 			if (!b)
-				return ERR_PTR(-ENOMEM);
+				{dump_stack();return ERR_PTR(-ENOMEM);}
 
 		} else {
 			b = root->commit_root;
@@ -2918,7 +2918,7 @@ again:
 		btrfs_tree_read_lock(b);
 		b = tree_mod_log_rewind(fs_info, p, b, time_seq);
 		if (!b) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto done;
 		}
 		p->locks[level] = BTRFS_READ_LOCK;
@@ -4391,7 +4391,7 @@ static noinline int split_item(struct btrfs_path *path,
 
 	buf = kmalloc(item_size, GFP_NOFS);
 	if (!buf)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf,
 			    path->slots[0]), item_size);
@@ -4816,7 +4816,7 @@ int btrfs_insert_item(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
 	if (!ret) {
 		leaf = path->nodes[0];
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index c1d2b67..0315d46 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -29,7 +29,7 @@ int __init btrfs_delayed_inode_init(void)
 					SLAB_MEM_SPREAD,
 					NULL);
 	if (!delayed_node_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	return 0;
 }
 
@@ -135,7 +135,7 @@ again:
 
 	node = kmem_cache_zalloc(delayed_node_cache, GFP_NOFS);
 	if (!node)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	btrfs_init_delayed_node(node, root, ino);
 
 	/* cached in the btrfs inode and can be accessed */
@@ -743,13 +743,13 @@ static int btrfs_batch_insert_items(struct btrfs_root *root,
 
 	keys = kmalloc_array(nitems, sizeof(struct btrfs_key), GFP_NOFS);
 	if (!keys) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
 	data_size = kmalloc_array(nitems, sizeof(u32), GFP_NOFS);
 	if (!data_size) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto error;
 	}
 
@@ -1147,7 +1147,7 @@ static int __btrfs_run_delayed_items(struct btrfs_trans_handle *trans, int nr)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	block_rsv = trans->block_rsv;
 	trans->block_rsv = &fs_info->delayed_block_rsv;
@@ -1210,7 +1210,7 @@ int btrfs_commit_inode_delayed_items(struct btrfs_trans_handle *trans,
 	path = btrfs_alloc_path();
 	if (!path) {
 		btrfs_release_delayed_node(delayed_node);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	block_rsv = trans->block_rsv;
@@ -1253,7 +1253,7 @@ int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto trans_out;
 	}
 
@@ -1364,7 +1364,7 @@ static int btrfs_wq_run_delayed_node(struct btrfs_delayed_root *delayed_root,
 
 	async_work = kmalloc(sizeof(*async_work), GFP_NOFS);
 	if (!async_work)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	async_work->delayed_root = delayed_root;
 	btrfs_init_work(&async_work->work, btrfs_async_run_delayed_root, NULL,
@@ -1437,7 +1437,7 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
 
 	delayed_item = btrfs_alloc_delayed_item(sizeof(*dir_item) + name_len);
 	if (!delayed_item) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto release_node;
 	}
 
@@ -1518,7 +1518,7 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
 
 	item = btrfs_alloc_delayed_item(0);
 	if (!item) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto end;
 	}
 
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index 63be7d0..19009f0 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -953,12 +953,12 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
 	BUG_ON(extent_op && extent_op->is_data);
 	ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS);
 	if (!head_ref) {
 		kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
@@ -969,7 +969,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
 		if (!record) {
 			kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref);
 			kmem_cache_free(btrfs_delayed_ref_head_cachep, head_ref);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 	}
 
@@ -1046,7 +1046,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
 	ASSERT(generic_ref->type == BTRFS_REF_DATA && action);
 	ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (parent)
 	        ref_type = BTRFS_SHARED_DATA_REF_KEY;
@@ -1063,7 +1063,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
 	head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS);
 	if (!head_ref) {
 		kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
@@ -1075,7 +1075,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
 			kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
 			kmem_cache_free(btrfs_delayed_ref_head_cachep,
 					head_ref);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 	}
 
@@ -1123,7 +1123,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_trans_handle *trans,
 
 	head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS);
 	if (!head_ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	init_delayed_ref_head(head_ref, NULL, bytenr, num_bytes, 0, 0,
 			      BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data,
@@ -1199,5 +1199,5 @@ int __init btrfs_delayed_ref_init(void)
 	return 0;
 fail:
 	btrfs_delayed_ref_exit();
-	return -ENOMEM;
+	{dump_stack();return -ENOMEM;}
 }
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index b23cb61..8ba3cb1 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -86,7 +86,7 @@ int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -301,7 +301,7 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
 	name = rcu_string_strdup(device_path, GFP_KERNEL);
 	if (!name) {
 		btrfs_free_device(device);
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto error;
 	}
 	rcu_assign_pointer(device->name, name);
@@ -372,7 +372,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);
@@ -511,7 +511,7 @@ static int mark_block_group_to_copy(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto unlock;
 	}
 
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 98b63eb..22c0c2c 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -126,7 +126,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, const char *name,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	btrfs_cpu_key_to_disk(&disk_key, location);
 
@@ -214,7 +214,7 @@ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = dir;
 	key.type = BTRFS_DIR_ITEM_KEY;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e4d8979..c36ca2b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -88,7 +88,7 @@ int __init btrfs_end_io_wq_init(void)
 					SLAB_MEM_SPREAD,
 					NULL);
 	if (!btrfs_end_io_wq_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	return 0;
 }
 
@@ -1167,7 +1167,7 @@ struct btrfs_root *btrfs_alloc_dummy_root(struct btrfs_fs_info *fs_info)
 
 	root = btrfs_alloc_root(fs_info, BTRFS_ROOT_TREE_OBJECTID, GFP_KERNEL);
 	if (!root)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	/* We don't use the stripesize in selftest, set it as sectorsize */
 	root->alloc_bytenr = 0;
@@ -1195,7 +1195,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	root = btrfs_alloc_root(fs_info, objectid, GFP_KERNEL);
 	memalloc_nofs_restore(nofs_flag);
 	if (!root)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	root->root_key.objectid = objectid;
 	root->root_key.type = BTRFS_ROOT_ITEM_KEY;
@@ -1257,7 +1257,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
 
 	root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS);
 	if (!root)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID;
 	root->root_key.type = BTRFS_ROOT_ITEM_KEY;
@@ -1368,7 +1368,7 @@ static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root,
 
 	root = btrfs_alloc_root(fs_info, key->objectid, GFP_NOFS);
 	if (!root)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	ret = btrfs_find_root(tree_root, key, path,
 			      &root->root_item, &root->root_key);
@@ -1406,7 +1406,7 @@ struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	root = read_tree_root_path(tree_root, path, key);
 	btrfs_free_path(path);
 
@@ -1430,6 +1430,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
 	nofs_flag = memalloc_nofs_save();
 	ret = btrfs_drew_lock_init(&root->snapshot_lock);
 	memalloc_nofs_restore(nofs_flag);
+	if (ret == -ENOMEM) printk("ENOMEM btrfs_drew_lock_init\n");
 	if (ret)
 		goto fail;
 
@@ -1447,6 +1448,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
 	    btrfs_root_refs(&root->root_item) > 0) {
 		if (!anon_dev) {
 			ret = get_anon_bdev(&root->anon_dev);
+			if (ret == -ENOMEM) printk("ENOMEM get_anon_bdev\n");
 			if (ret)
 				goto fail;
 		} else {
@@ -1456,6 +1458,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
 
 	mutex_lock(&root->objectid_mutex);
 	ret = btrfs_init_root_free_objectid(root);
+	if (ret == -ENOMEM) printk("ENOMEM btrfs_init_root_free_objectid\n");
 	if (ret) {
 		mutex_unlock(&root->objectid_mutex);
 		goto fail;
@@ -1610,6 +1613,7 @@ static struct btrfs_root *btrfs_get_root_ref(struct btrfs_fs_info *fs_info,
 	int ret;
 
 	root = btrfs_get_global_root(fs_info, objectid);
+	if (root == ERR_PTR(-ENOMEM)) printk("ENOMEM btrfs_get_global_root\n");
 	if (root)
 		return root;
 again:
@@ -1621,6 +1625,7 @@ again:
 			btrfs_put_root(root);
 			return ERR_PTR(-ENOENT);
 		}
+		if (root == ERR_PTR(-ENOMEM)) printk("ENOMEM btrfs_lookup_fs_root\n");
 		return root;
 	}
 
@@ -1628,6 +1633,7 @@ again:
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	key.offset = (u64)-1;
 	root = btrfs_read_tree_root(fs_info->tree_root, &key);
+	if (root == ERR_PTR(-ENOMEM)) printk("ENOMEM btrfs_read_tree_root\n");
 	if (IS_ERR(root))
 		return root;
 
@@ -1637,12 +1643,13 @@ again:
 	}
 
 	ret = btrfs_init_fs_root(root, anon_dev);
+	if (ret == -ENOMEM) printk("ENOMEM btrfs_init_fs_root\n");
 	if (ret)
 		goto fail;
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto fail;
 	}
 	key.objectid = BTRFS_ORPHAN_OBJECTID;
@@ -1650,6 +1657,7 @@ again:
 	key.offset = objectid;
 
 	ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
+	if (ret == -ENOMEM) printk("ENOMEM btrfs_search_slot\n");
 	btrfs_free_path(path);
 	if (ret < 0)
 		goto fail;
@@ -1657,6 +1665,7 @@ again:
 		set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state);
 
 	ret = btrfs_insert_fs_root(fs_info, root);
+	if (ret == -ENOMEM) printk("ENOMEM btrfs_insert_fs_root\n");
 	if (ret) {
 		btrfs_put_root(root);
 		if (ret == -EEXIST)
@@ -2277,7 +2286,7 @@ int btrfs_init_workqueues(struct btrfs_fs_info *fs_info,
 	      fs_info->fixup_workers && fs_info->delayed_workers &&
 	      fs_info->qgroup_rescan_workers &&
 	      fs_info->discard_ctl.discard_workers)) {
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	return 0;
@@ -2318,7 +2327,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
 	log_tree_root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID,
 					 GFP_KERNEL);
 	if (!log_tree_root)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	log_tree_root->node = read_tree_block(fs_info, bytenr,
 					      BTRFS_TREE_LOG_OBJECTID,
@@ -2924,7 +2933,7 @@ static int init_mount_fs_info(struct btrfs_fs_info *fs_info, struct super_block
 	fs_info->delayed_root = kmalloc(sizeof(struct btrfs_delayed_root),
 					GFP_KERNEL);
 	if (!fs_info->delayed_root)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	btrfs_init_delayed_root(fs_info->delayed_root);
 
 	if (sb_rdonly(sb))
@@ -3119,13 +3128,13 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 				      GFP_KERNEL);
 	fs_info->chunk_root = chunk_root;
 	if (!tree_root || !chunk_root) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto fail;
 	}
 
 	fs_info->btree_inode = new_inode(sb);
 	if (!fs_info->btree_inode) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto fail;
 	}
 	mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
@@ -4909,7 +4918,7 @@ int btrfs_init_root_free_objectid(struct btrfs_root *root)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	search_key.objectid = BTRFS_LAST_FREE_OBJECTID;
 	search_key.type = -1;
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 1d4c239..3742cf2 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -145,7 +145,7 @@ struct dentry *btrfs_get_parent(struct dentry *child)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	if (btrfs_ino(BTRFS_I(dir)) == BTRFS_FIRST_FREE_OBJECTID) {
 		key.objectid = root->root_key.objectid;
@@ -221,7 +221,7 @@ static int btrfs_get_name(struct dentry *parent, char *name,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (ino == BTRFS_FIRST_FREE_OBJECTID) {
 		key.objectid = BTRFS_I(inode)->root->root_key.objectid;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 36a3c97..22a6d25 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -93,7 +93,7 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = start;
 	key.offset = len;
@@ -138,7 +138,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (!trans) {
 		path->skip_locking = 1;
@@ -1459,7 +1459,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* this will setup the path even if it fails to insert the back ref */
 	ret = insert_inline_extent_backref(trans, path, bytenr, num_bytes,
@@ -1586,7 +1586,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = head->bytenr;
 
@@ -2195,7 +2195,7 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans,
 
 	extent_op = btrfs_alloc_delayed_extent_op();
 	if (!extent_op)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	extent_op->flags_to_set = flags;
 	extent_op->update_flags = true;
@@ -2372,7 +2372,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	do {
 		ret = check_committed_ref(root, path, objectid,
@@ -2965,7 +2965,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
 
@@ -4529,7 +4529,7 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
 				      ins, size);
@@ -4613,7 +4613,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
 				      &extent_key, size);
@@ -4859,7 +4859,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
 	if (root_objectid != BTRFS_TREE_LOG_OBJECTID) {
 		extent_op = btrfs_alloc_delayed_extent_op();
 		if (!extent_op) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out_free_buf;
 		}
 		if (key)
@@ -5083,7 +5083,7 @@ static int check_ref_exists(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = lookup_extent_backref(trans, path, &iref, bytenr,
 				    root->fs_info->nodesize, parent,
@@ -5522,14 +5522,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
 	wc = kzalloc(sizeof(*wc), GFP_NOFS);
 	if (!wc) {
 		btrfs_free_path(path);
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
@@ -5768,12 +5768,12 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	wc = kzalloc(sizeof(*wc), GFP_NOFS);
 	if (!wc) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	btrfs_assert_tree_locked(parent);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fbb3ffd..deeb2d2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -221,7 +221,7 @@ int __init extent_state_cache_init(void)
 			sizeof(struct extent_state), 0,
 			SLAB_MEM_SPREAD, NULL);
 	if (!extent_state_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	return 0;
 }
 
@@ -231,7 +231,7 @@ int __init extent_io_init(void)
 			sizeof(struct extent_buffer), 0,
 			SLAB_MEM_SPREAD, NULL);
 	if (!extent_buffer_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (bioset_init(&btrfs_bioset, BIO_POOL_SIZE,
 			offsetof(struct btrfs_io_bio, bio),
@@ -249,7 +249,7 @@ free_bioset:
 free_buffer_cache:
 	kmem_cache_destroy(extent_buffer_cache);
 	extent_buffer_cache = NULL;
-	return -ENOMEM;
+	{dump_stack();return -ENOMEM;}
 }
 
 void __cold extent_state_cache_exit(void)
@@ -1229,7 +1229,7 @@ again:
 		 */
 		prealloc = alloc_extent_state(GFP_NOFS);
 		if (!prealloc && !first_iteration)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 	}
 
 	spin_lock(&tree->lock);
@@ -1250,7 +1250,7 @@ again:
 	if (!node) {
 		prealloc = alloc_extent_state_atomic(prealloc);
 		if (!prealloc) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto out;
 		}
 		err = insert_state(tree, prealloc, start, end,
@@ -1304,7 +1304,7 @@ hit_next:
 	if (state->start < start) {
 		prealloc = alloc_extent_state_atomic(prealloc);
 		if (!prealloc) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto out;
 		}
 		err = split_state(tree, state, prealloc, start);
@@ -1343,7 +1343,7 @@ hit_next:
 
 		prealloc = alloc_extent_state_atomic(prealloc);
 		if (!prealloc) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto out;
 		}
 
@@ -1369,7 +1369,7 @@ hit_next:
 	if (state->start <= end && state->end > end) {
 		prealloc = alloc_extent_state_atomic(prealloc);
 		if (!prealloc) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto out;
 		}
 
@@ -2476,7 +2476,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
 
 	failrec = kzalloc(sizeof(*failrec), GFP_NOFS);
 	if (!failrec)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	failrec->start = start;
 	failrec->len = end - start + 1;
@@ -5001,12 +5001,12 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	roots = ulist_alloc(GFP_KERNEL);
 	tmp_ulist = ulist_alloc(GFP_KERNEL);
 	if (!roots || !tmp_ulist) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_free_ulist;
 	}
 
@@ -5513,7 +5513,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
 		return eb;
 	eb = alloc_dummy_extent_buffer(fs_info, start);
 	if (!eb)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	eb->fs_info = fs_info;
 again:
 	ret = radix_tree_preload(GFP_NOFS);
@@ -5608,7 +5608,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
 
 	eb = __alloc_extent_buffer(fs_info, start, len);
 	if (!eb)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	btrfs_set_buffer_lockdep_class(owner_root, eb, level);
 
 	num_pages = num_extent_pages(eb);
@@ -5617,7 +5617,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
 
 		p = find_or_create_page(mapping, index, GFP_NOFS|__GFP_NOFAIL);
 		if (!p) {
-			exists = ERR_PTR(-ENOMEM);
+			exists = ERR_PTR(-ENOMEM); dump_stack();
 			goto free_eb;
 		}
 
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 4a8e02f..0f16850 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -17,7 +17,7 @@ int __init extent_map_init(void)
 			sizeof(struct extent_map), 0,
 			SLAB_MEM_SPREAD, NULL);
 	if (!extent_map_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	return 0;
 }
 
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 47cd3a6..eb0ef80 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -143,7 +143,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	file_key.objectid = objectid;
 	file_key.offset = pos;
 	file_key.type = BTRFS_EXTENT_DATA_KEY;
@@ -513,7 +513,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (search_commit) {
 		path->skip_locking = 1;
@@ -576,7 +576,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
 			sums = kzalloc(btrfs_ordered_sum_size(fs_info, size),
 				       GFP_NOFS);
 			if (!sums) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto fail;
 			}
 
@@ -796,7 +796,7 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	while (1) {
 		key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
@@ -946,7 +946,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 again:
 	next_offset = (u64)-1;
 	found_next = 0;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 17d9623..e43bffb 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -153,7 +153,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
 
 	defrag = kmem_cache_zalloc(btrfs_inode_defrag_cachep, GFP_NOFS);
 	if (!defrag)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	defrag->ino = btrfs_ino(inode);
 	defrag->transid = transid;
@@ -720,7 +720,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
 	if (!path) {
 		path = btrfs_alloc_path();
 		if (!path) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 	}
@@ -1099,7 +1099,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 again:
 	recow = 0;
 	split = start;
@@ -1365,7 +1365,7 @@ again:
 					       mask | __GFP_WRITE);
 		if (!pages[i]) {
 			faili = i - 1;
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto fail;
 		}
 
@@ -1673,7 +1673,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb,
 	nrptrs = max(nrptrs, 8);
 	pages = kmalloc_array(nrptrs, sizeof(struct page *), GFP_KERNEL);
 	if (!pages) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2626,7 +2626,7 @@ int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
 
 	rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
 	if (!rsv) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	rsv->size = btrfs_calc_insert_metadata_size(fs_info, 1);
@@ -2962,7 +2962,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -3045,7 +3045,7 @@ static int add_falloc_range(struct list_head *head, u64 start, u64 len)
 insert:
 	range = kmalloc(sizeof(*range), GFP_KERNEL);
 	if (!range)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	range->start = start;
 	range->len = len;
 	list_add_tail(&range->list, head);
@@ -3670,7 +3670,7 @@ int __init btrfs_auto_defrag_init(void)
 					SLAB_MEM_SPREAD,
 					NULL);
 	if (!btrfs_inode_defrag_cachep)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	return 0;
 }
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 8120ffa..301c207 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -221,7 +221,7 @@ int btrfs_remove_free_space_inode(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (!inode)
 		inode = lookup_free_space_inode(block_group, path);
@@ -296,7 +296,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
 		struct btrfs_path *path = btrfs_alloc_path();
 
 		if (!path) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto fail;
 		}
 		locked = true;
@@ -373,7 +373,7 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
 
 	io_ctl->pages = kcalloc(num_pages, sizeof(struct page *), GFP_NOFS);
 	if (!io_ctl->pages)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	io_ctl->num_pages = num_pages;
 	io_ctl->fs_info = btrfs_sb(inode->i_sb);
@@ -436,7 +436,7 @@ static int io_ctl_prepare_pages(struct btrfs_io_ctl *io_ctl, bool uptodate)
 		page = find_or_create_page(inode->i_mapping, i, mask);
 		if (!page) {
 			io_ctl_drop_pages(io_ctl);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 
 		ret = set_page_extent_mapped(page);
@@ -785,7 +785,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
 		e = kmem_cache_zalloc(btrfs_free_space_cachep,
 				      GFP_NOFS);
 		if (!e) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto free_cache;
 		}
 
@@ -817,7 +817,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
 			e->bitmap = kmem_cache_zalloc(
 					btrfs_free_space_bitmap_cachep, GFP_NOFS);
 			if (!e->bitmap) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				kmem_cache_free(
 					btrfs_free_space_cachep, e);
 				goto free_cache;
@@ -2242,7 +2242,7 @@ new_bitmap:
 						 GFP_NOFS);
 			if (!info) {
 				spin_lock(&ctl->tree_lock);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 		}
@@ -2253,7 +2253,7 @@ new_bitmap:
 		info->trim_state = BTRFS_TRIM_STATE_TRIMMED;
 		spin_lock(&ctl->tree_lock);
 		if (!info->bitmap) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 		goto again;
@@ -2481,7 +2481,7 @@ int __btrfs_add_free_space(struct btrfs_fs_info *fs_info,
 
 	info = kmem_cache_zalloc(btrfs_free_space_cachep, GFP_NOFS);
 	if (!info)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	info->offset = offset;
 	info->bytes = bytes;
@@ -4014,7 +4014,7 @@ again:
 	if (!info) {
 		info = kmem_cache_zalloc(btrfs_free_space_cachep, GFP_NOFS);
 		if (!info)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 	}
 
 	if (!bitmap) {
@@ -4033,7 +4033,7 @@ again:
 		map = kmem_cache_zalloc(btrfs_free_space_bitmap_cachep, GFP_NOFS);
 		if (!map) {
 			kmem_cache_free(btrfs_free_space_cachep, info);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 	}
 
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c
index a33bca9..19a455c 100644
--- a/fs/btrfs/free-space-tree.c
+++ b/fs/btrfs/free-space-tree.c
@@ -204,7 +204,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans,
 	bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
 	bitmap = alloc_bitmap(bitmap_size);
 	if (!bitmap) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -341,7 +341,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans,
 	bitmap_size = free_space_bitmap_size(fs_info, block_group->length);
 	bitmap = alloc_bitmap(bitmap_size);
 	if (!bitmap) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -822,7 +822,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1015,7 +1015,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1054,13 +1054,13 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_FORWARD;
 
 	path2 = btrfs_alloc_path();
 	if (!path2) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	ret = add_new_free_space_info(trans, block_group, path2);
@@ -1199,7 +1199,7 @@ static int clear_free_space_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = 0;
 	key.type = 0;
@@ -1302,7 +1302,7 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1337,7 +1337,7 @@ int remove_block_group_free_space(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1547,7 +1547,7 @@ int load_free_space_tree(struct btrfs_caching_control *caching_ctl)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * Just like caching_thread() doesn't want to deadlock on the extent
diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
index 37f36ff..1a323d9 100644
--- a/fs/btrfs/inode-item.c
+++ b/fs/btrfs/inode-item.c
@@ -117,7 +117,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
 	if (ret > 0)
@@ -189,7 +189,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
 	if (ret > 0) {
@@ -264,7 +264,7 @@ static int btrfs_insert_inode_extref(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_insert_empty_item(trans, root, path, &key,
 				      ins_len);
@@ -320,7 +320,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	path->skip_release_on_error = 1;
 	ret = btrfs_insert_empty_item(trans, root, path, &key,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2689954..f0c3a92 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -344,7 +344,7 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 start,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	trans = btrfs_join_transaction(root);
 	if (IS_ERR(trans)) {
@@ -1326,7 +1326,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
 
 		extent_clear_unlock_delalloc(inode, start, end, locked_page,
 					     clear_bits, page_ops);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	async_chunk = ctx->chunks;
@@ -1544,7 +1544,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 					     EXTENT_DEFRAG, PAGE_UNLOCK |
 					     PAGE_START_WRITEBACK |
 					     PAGE_END_WRITEBACK);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	while (1) {
@@ -2747,7 +2747,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * we may be replacing one extent in the tree with another.
@@ -3331,7 +3331,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	path->reada = READA_BACK;
@@ -3582,7 +3582,7 @@ static int btrfs_read_locked_inode(struct inode *inode,
 	if (!path) {
 		path = btrfs_alloc_path();
 		if (!path)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 	}
 
 	memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
@@ -3818,7 +3818,7 @@ static noinline int btrfs_update_inode_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_lookup_inode(trans, root, path, &inode->location, 1);
 	if (ret) {
@@ -3903,7 +3903,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4086,7 +4086,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
 				   name, name_len, -1);
@@ -4172,7 +4172,7 @@ static noinline int may_destroy_subvol(struct btrfs_root *root)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* Make sure this root isn't set as the default subvol */
 	dir_id = btrfs_super_root_dir(fs_info->super_copy);
@@ -4513,7 +4513,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_BACK;
 
 	if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
@@ -4879,7 +4879,7 @@ again:
 		btrfs_delalloc_release_space(inode, data_reserved, block_start,
 					     blocksize, true);
 		btrfs_delalloc_release_extents(inode, blocksize);
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	ret = set_page_extent_mapped(page);
@@ -5510,7 +5510,7 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)),
 			name, namelen, 0);
@@ -5556,7 +5556,7 @@ static int fixup_tree_root_location(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
@@ -5711,7 +5711,7 @@ struct inode *btrfs_iget_path(struct super_block *s, u64 ino,
 
 	inode = btrfs_iget_locked(s, ino, root);
 	if (!inode)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	if (inode->i_state & I_NEW) {
 		int ret;
@@ -5748,7 +5748,7 @@ static struct inode *new_simple_dir(struct super_block *s,
 	struct inode *inode = new_inode(s);
 
 	if (!inode)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	BTRFS_I(inode)->root = btrfs_grab_root(root);
 	memcpy(&BTRFS_I(inode)->location, key, sizeof(*key));
@@ -5894,11 +5894,11 @@ static int btrfs_opendir(struct inode *inode, struct file *file)
 
 	private = kzalloc(sizeof(struct btrfs_file_private), GFP_KERNEL);
 	if (!private)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	private->filldir_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!private->filldir_buf) {
 		kfree(private);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 	file->private_data = private;
 	return 0;
@@ -5956,7 +5956,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	addr = private->filldir_buf;
 	path->reada = READA_FORWARD;
@@ -6148,7 +6148,7 @@ static int btrfs_set_inode_index_count(struct btrfs_inode *inode)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
 	if (ret < 0)
@@ -6274,14 +6274,14 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	nofs_flag = memalloc_nofs_save();
 	inode = new_inode(fs_info->sb);
 	memalloc_nofs_restore(nofs_flag);
 	if (!inode) {
 		btrfs_free_path(path);
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	}
 
 	/*
@@ -6816,7 +6816,7 @@ static noinline int uncompress_inline(struct btrfs_path *path,
 					btrfs_item_nr(path->slots[0]));
 	tmp = kmalloc(inline_size, GFP_NOFS);
 	if (!tmp)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ptr = btrfs_file_extent_inline_start(item);
 
 	read_extent_buffer(leaf, tmp, ptr, inline_size);
@@ -6893,7 +6893,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
 	}
 	em = alloc_extent_map();
 	if (!em) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	em->start = EXTENT_MAP_HOLE;
@@ -6903,7 +6903,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -7141,7 +7141,7 @@ struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
 
 		em = alloc_extent_map();
 		if (!em) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			goto out;
 		}
 
@@ -7306,7 +7306,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_lookup_file_extent(NULL, root, path,
 			btrfs_ino(BTRFS_I(inode)), offset, 0);
@@ -7529,7 +7529,7 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
 	em_tree = &inode->extent_tree;
 	em = alloc_extent_map();
 	if (!em)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	em->start = start;
 	em->orig_start = orig_start;
@@ -7688,7 +7688,7 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 
 	dio_data = kzalloc(sizeof(*dio_data), GFP_NOFS);
 	if (!dio_data)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	dio_data->length = length;
 	if (write) {
@@ -8693,7 +8693,7 @@ static int btrfs_truncate(struct inode *inode, bool skip_writeback)
 	 */
 	rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
 	if (!rsv)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	rsv->size = min_size;
 	rsv->failfast = 1;
 
@@ -9020,7 +9020,7 @@ int __init btrfs_init_cachep(void)
 	return 0;
 fail:
 	btrfs_destroy_cachep();
-	return -ENOMEM;
+	{dump_stack();return -ENOMEM;}
 }
 
 static int btrfs_getattr(const struct path *path, struct kstat *stat,
@@ -9641,7 +9641,7 @@ static int start_delalloc_inodes(struct btrfs_root *root,
 			work = btrfs_alloc_delalloc_work(inode);
 			if (!work) {
 				iput(inode);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			list_add_tail(&work->list, &works);
@@ -9812,7 +9812,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out_unlock;
 	}
 	key.objectid = btrfs_ino(BTRFS_I(inode));
@@ -9919,7 +9919,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto free_qgroup;
 	}
 
@@ -10211,7 +10211,7 @@ static int btrfs_add_swapfile_pin(struct inode *inode, void *ptr,
 
 	sp = kmalloc(sizeof(*sp), GFP_NOFS);
 	if (!sp)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	sp->ptr = ptr;
 	sp->inode = inode;
 	sp->is_block_group = is_block_group;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ede09df..0292757 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -618,7 +618,7 @@ static noinline int create_subvol(struct inode *dir,
 
 	root_item = kzalloc(sizeof(*root_item), GFP_KERNEL);
 	if (!root_item)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_get_free_objectid(fs_info->tree_root, &objectid);
 	if (ret)
@@ -812,7 +812,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
 
 	pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_KERNEL);
 	if (!pending_snapshot)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_anon_bdev(&pending_snapshot->anon_dev);
 	if (ret < 0)
@@ -821,7 +821,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
 			GFP_KERNEL);
 	pending_snapshot->path = btrfs_alloc_path();
 	if (!pending_snapshot->root_item || !pending_snapshot->path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto free_pending;
 	}
 
@@ -1110,7 +1110,7 @@ static int find_new_extents(struct btrfs_root *root,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	min_key.objectid = ino;
 	min_key.type = BTRFS_EXTENT_DATA_KEY;
@@ -1530,7 +1530,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 
 	pages = kmalloc_array(max_cluster, sizeof(struct page *), GFP_KERNEL);
 	if (!pages) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_ra;
 	}
 
@@ -2263,7 +2263,7 @@ static noinline int search_ioctl(struct inode *inode,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (sk->tree_id == 0) {
 		/* search the root of the inode that was passed */
@@ -2403,7 +2403,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ptr = &name[BTRFS_INO_LOOKUP_PATH_MAX - 1];
 
@@ -2491,7 +2491,7 @@ static int btrfs_search_path_in_tree_user(struct inode *inode,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * If the bottom subvolume does not exist directly under upper_limit,
@@ -2733,12 +2733,12 @@ static int btrfs_ioctl_get_subvol_info(struct file *file, void __user *argp)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	subvol_info = kzalloc(sizeof(*subvol_info), GFP_KERNEL);
 	if (!subvol_info) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	inode = file_inode(file);
@@ -2851,7 +2851,7 @@ static int btrfs_ioctl_get_subvol_rootref(struct file *file, void __user *argp)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	rootrefs = memdup_user(argp, sizeof(*rootrefs));
 	if (IS_ERR(rootrefs)) {
@@ -3172,7 +3172,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
 
 		range = kzalloc(sizeof(*range), GFP_KERNEL);
 		if (!range) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 
@@ -3467,7 +3467,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_free;
 	}
 
@@ -3586,12 +3586,12 @@ static long btrfs_ioctl_space_info(struct btrfs_fs_info *fs_info,
 	 * level.  So, a whole page should be more than enough for everyone
 	 */
 	if (alloc_size > PAGE_SIZE)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	space_args.total_spaces = 0;
 	dest = kmalloc(alloc_size, GFP_KERNEL);
 	if (!dest)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	dest_orig = dest;
 
 	/* now we have a buffer to copy into */
@@ -3863,7 +3863,7 @@ static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -3964,7 +3964,7 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4114,7 +4114,7 @@ locked:
 
 	bctl = kzalloc(sizeof(*bctl), GFP_KERNEL);
 	if (!bctl) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_bargs;
 	}
 
@@ -4196,7 +4196,7 @@ static long btrfs_ioctl_balance_progress(struct btrfs_fs_info *fs_info,
 
 	bargs = kzalloc(sizeof(*bargs), GFP_KERNEL);
 	if (!bargs) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4446,7 +4446,7 @@ static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info,
 
 	qsa = kzalloc(sizeof(*qsa), GFP_KERNEL);
 	if (!qsa)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) {
 		qsa->flags = 1;
@@ -4573,7 +4573,7 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file,
 
 	args64 = kmalloc(sizeof(*args64), GFP_KERNEL);
 	if (!args64) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4886,7 +4886,7 @@ static int _btrfs_ioctl_send(struct file *file, void __user *argp, bool compat)
 			return -EFAULT;
 		arg = kzalloc(sizeof(*arg), GFP_KERNEL);
 		if (!arg)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		arg->send_fd = args32.send_fd;
 		arg->clone_sources_count = args32.clone_sources_count;
 		arg->clone_sources = compat_ptr(args32.clone_sources);
diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index aa9cd11..e5dcd37 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -79,7 +79,7 @@ struct list_head *lzo_alloc_workspace(unsigned int level)
 
 	workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
 	if (!workspace)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	workspace->mem = kvmalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
 	workspace->buf = kvmalloc(lzo1x_worst_compress(PAGE_SIZE), GFP_KERNEL);
@@ -92,7 +92,7 @@ struct list_head *lzo_alloc_workspace(unsigned int level)
 	return &workspace->list;
 fail:
 	lzo_free_workspace(&workspace->list);
-	return ERR_PTR(-ENOMEM);
+	{dump_stack();return ERR_PTR(-ENOMEM);}
 }
 
 static inline void write_compress_length(char *buf, size_t len)
@@ -148,7 +148,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 	 */
 	out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 	if (out_page == NULL) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	cpage_out = kmap(out_page);
@@ -218,7 +218,7 @@ int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
 
 				out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 				if (out_page == NULL) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					goto out;
 				}
 				cpage_out = kmap(out_page);
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 985a215..ca3d9d0 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -188,7 +188,7 @@ static int __btrfs_add_ordered_extent(struct btrfs_inode *inode, u64 file_offset
 	}
 	entry = kmem_cache_zalloc(btrfs_ordered_extent_cache, GFP_NOFS);
 	if (!entry)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	entry->file_offset = file_offset;
 	entry->disk_bytenr = disk_bytenr;
@@ -1009,7 +1009,7 @@ int __init ordered_data_init(void)
 				     SLAB_MEM_SPREAD,
 				     NULL);
 	if (!btrfs_ordered_extent_cache)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	return 0;
 }
diff --git a/fs/btrfs/orphan.c b/fs/btrfs/orphan.c
index aa53410..bae03dc 100644
--- a/fs/btrfs/orphan.c
+++ b/fs/btrfs/orphan.c
@@ -19,7 +19,7 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
 
@@ -40,7 +40,7 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
 	if (ret < 0)
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index 2dcb1cb..763f8aa 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -181,7 +181,7 @@ static int iterate_object_props(struct btrfs_root *root,
 				name_buf_len = name_len + 1;
 				name_buf = kmalloc(name_buf_len, GFP_NOFS);
 				if (!name_buf) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					goto out;
 				}
 			}
@@ -197,7 +197,7 @@ static int iterate_object_props(struct btrfs_root *root,
 				value_buf_len = data_len;
 				value_buf = kmalloc(data_len, GFP_NOFS);
 				if (!value_buf) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					goto out;
 				}
 			}
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index f0b9ef1..5a1806d 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -208,7 +208,7 @@ static struct btrfs_qgroup *add_qgroup_rb(struct btrfs_fs_info *fs_info,
 
 	qgroup = kzalloc(sizeof(*qgroup), GFP_ATOMIC);
 	if (!qgroup)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	qgroup->qgroupid = qgroupid;
 	INIT_LIST_HEAD(&qgroup->groups);
@@ -272,7 +272,7 @@ static int add_relation_rb(struct btrfs_fs_info *fs_info,
 
 	list = kzalloc(sizeof(*list), GFP_ATOMIC);
 	if (!list)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	list->group = parent;
 	list->member = member;
@@ -342,13 +342,13 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
 
 	fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
 	if (!fs_info->qgroup_ulist) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -590,7 +590,7 @@ static int add_qgroup_relation_item(struct btrfs_trans_handle *trans, u64 src,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = src;
 	key.type = BTRFS_QGROUP_RELATION_KEY;
@@ -614,7 +614,7 @@ static int del_qgroup_relation_item(struct btrfs_trans_handle *trans, u64 src,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = src;
 	key.type = BTRFS_QGROUP_RELATION_KEY;
@@ -650,7 +650,7 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = 0;
 	key.type = BTRFS_QGROUP_INFO_KEY;
@@ -712,7 +712,7 @@ static int del_qgroup_item(struct btrfs_trans_handle *trans, u64 qgroupid)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = 0;
 	key.type = BTRFS_QGROUP_INFO_KEY;
@@ -766,7 +766,7 @@ static int update_qgroup_limit_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, quota_root, &key, path, 0, 1);
 	if (ret > 0)
@@ -812,7 +812,7 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, quota_root, &key, path, 0, 1);
 	if (ret > 0)
@@ -854,7 +854,7 @@ static int update_qgroup_status_item(struct btrfs_trans_handle *trans)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, quota_root, &key, path, 0, 1);
 	if (ret > 0)
@@ -892,7 +892,7 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = 0;
 	key.offset = 0;
@@ -945,7 +945,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
 
 	ulist = ulist_alloc(GFP_KERNEL);
 	if (!ulist) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1003,7 +1003,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		btrfs_abort_transaction(trans, ret);
 		goto out_free_root;
 	}
@@ -1376,7 +1376,7 @@ int btrfs_add_qgroup_relation(struct btrfs_trans_handle *trans, u64 src,
 	tmp = ulist_alloc(GFP_KERNEL);
 	memalloc_nofs_restore(nofs_flag);
 	if (!tmp)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	mutex_lock(&fs_info->qgroup_ioctl_lock);
 	if (!fs_info->quota_root) {
@@ -1440,7 +1440,7 @@ static int __del_qgroup_relation(struct btrfs_trans_handle *trans, u64 src,
 	tmp = ulist_alloc(GFP_KERNEL);
 	memalloc_nofs_restore(nofs_flag);
 	if (!tmp)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (!fs_info->quota_root) {
 		ret = -ENOTCONN;
@@ -1743,7 +1743,7 @@ int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans, u64 bytenr,
 		return 0;
 	record = kzalloc(sizeof(*record), gfp_flag);
 	if (!record)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	delayed_refs = &trans->transaction->delayed_refs;
 	record->bytenr = bytenr;
@@ -1929,7 +1929,7 @@ static int qgroup_trace_extent_swap(struct btrfs_trans_handle* trans,
 
 	src_path = btrfs_alloc_path();
 	if (!src_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2169,7 +2169,7 @@ static int qgroup_trace_subtree_swap(struct btrfs_trans_handle *trans,
 	level = btrfs_header_level(dst_eb);
 	dst_path = btrfs_alloc_path();
 	if (!dst_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	/* For dst_path */
@@ -2221,7 +2221,7 @@ int btrfs_qgroup_trace_subtree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * Walk down the tree.  Missing extent blocks are filled in as
@@ -2548,12 +2548,12 @@ int btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, u64 bytenr,
 
 	qgroups = ulist_alloc(GFP_NOFS);
 	if (!qgroups) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_free;
 	}
 	tmp = ulist_alloc(GFP_NOFS);
 	if (!tmp) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_free;
 	}
 
@@ -3159,7 +3159,7 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans,
 
 	scratch_leaf = btrfs_clone_extent_buffer(path->nodes[0]);
 	if (!scratch_leaf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		mutex_unlock(&fs_info->qgroup_rescan_lock);
 		goto out;
 	}
@@ -3210,13 +3210,13 @@ static void btrfs_qgroup_rescan_worker(struct btrfs_work *work)
 						     qgroup_rescan_work);
 	struct btrfs_path *path;
 	struct btrfs_trans_handle *trans = NULL;
-	int err = -ENOMEM;
+	int err;
 	int ret = 0;
 	bool stopped = false;
 
 	path = btrfs_alloc_path();
 	if (!path)
-		goto out;
+		{ dump_stack(); err = -ENOMEM; goto out;}
 	/*
 	 * Rescan should only search for commit root, and any later difference
 	 * should be recorded by qgroup
@@ -3622,7 +3622,7 @@ static int qgroup_reserve_data(struct btrfs_inode *inode,
 		new_reserved = true;
 		*reserved_ret = extent_changeset_alloc();
 		if (!*reserved_ret)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 	}
 	reserved = *reserved_ret;
 	/* Record already reserved space */
@@ -4099,7 +4099,7 @@ int btrfs_qgroup_add_swapped_blocks(struct btrfs_trans_handle *trans,
 
 	block = kmalloc(sizeof(*block), GFP_NOFS);
 	if (!block) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 5ab4566..e822f08 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -219,7 +219,7 @@ int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info)
 	 */
 	table = kvzalloc(struct_size(table, table, num_entries), GFP_KERNEL);
 	if (!table)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	spin_lock_init(&table->cache_lock);
 	INIT_LIST_HEAD(&table->stripe_cache);
@@ -979,7 +979,7 @@ static struct btrfs_raid_bio *alloc_rbio(struct btrfs_fs_info *fs_info,
 				BITS_TO_LONGS(stripe_npages),
 		       GFP_NOFS);
 	if (!rbio)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	bio_list_init(&rbio->bio_list);
 	INIT_LIST_HEAD(&rbio->plug_list);
@@ -1036,7 +1036,7 @@ static int alloc_rbio_pages(struct btrfs_raid_bio *rbio)
 			continue;
 		page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 		if (!page)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		rbio->stripe_pages[i] = page;
 	}
 	return 0;
@@ -1055,7 +1055,7 @@ static int alloc_rbio_parity_pages(struct btrfs_raid_bio *rbio)
 			continue;
 		page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 		if (!page)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		rbio->stripe_pages[i] = page;
 	}
 	return 0;
@@ -2300,7 +2300,7 @@ static int alloc_rbio_essential_pages(struct btrfs_raid_bio *rbio)
 
 			page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 			if (!page)
-				return -ENOMEM;
+				{dump_stack();return -ENOMEM;}
 			rbio->stripe_pages[index] = page;
 		}
 	}
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 06713a8..7d5fe50 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -572,7 +572,7 @@ static int reada_add_block(struct reada_control *rc, u64 logical,
 	rec = kzalloc(sizeof(*rec), GFP_KERNEL);
 	if (!rec) {
 		reada_extent_put(fs_info, re);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	rec->rc = rc;
@@ -969,7 +969,7 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
 
 	rc = kzalloc(sizeof(*rc), GFP_KERNEL);
 	if (!rc)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	rc->fs_info = root->fs_info;
 	rc->key_start = *key_start;
diff --git a/fs/btrfs/ref-verify.c b/fs/btrfs/ref-verify.c
index 8e026de..84bd7bf 100644
--- a/fs/btrfs/ref-verify.c
+++ b/fs/btrfs/ref-verify.c
@@ -269,7 +269,7 @@ static struct block_entry *add_block_entry(struct btrfs_fs_info *fs_info,
 	if (!be || !re) {
 		kfree(re);
 		kfree(be);
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	}
 	be->bytenr = bytenr;
 	be->len = len;
@@ -315,7 +315,7 @@ static int add_tree_block(struct btrfs_fs_info *fs_info, u64 ref_root,
 
 	ref = kmalloc(sizeof(struct ref_entry), GFP_KERNEL);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (parent)
 		ref->root_objectid = 0;
@@ -360,7 +360,7 @@ static int add_shared_data_ref(struct btrfs_fs_info *fs_info,
 
 	ref = kzalloc(sizeof(struct ref_entry), GFP_KERNEL);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	be = add_block_entry(fs_info, bytenr, num_bytes, 0);
 	if (IS_ERR(be)) {
 		kfree(ref);
@@ -395,7 +395,7 @@ static int add_extent_data_ref(struct btrfs_fs_info *fs_info,
 
 	ref = kzalloc(sizeof(struct ref_entry), GFP_KERNEL);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	be = add_block_entry(fs_info, bytenr, num_bytes, ref_root);
 	if (IS_ERR(be)) {
 		kfree(ref);
@@ -692,7 +692,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
 	if (!ra || !ref) {
 		kfree(ref);
 		kfree(ra);
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -766,7 +766,7 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
 			if (!re) {
 				kfree(ref);
 				kfree(ra);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			/*
@@ -983,7 +983,7 @@ int btrfs_build_ref_tree(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	eb = btrfs_read_lock_root_node(fs_info->extent_root);
 	level = btrfs_header_level(eb);
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index c90b696..839fd0b 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -77,7 +77,7 @@ static int copy_inline_to_page(struct btrfs_inode *inode,
 	page = find_or_create_page(mapping, file_offset >> PAGE_SHIFT,
 				   btrfs_alloc_write_mask(mapping));
 	if (!page) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out_unlock;
 	}
 
@@ -334,15 +334,14 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 	const u64 len = olen_aligned;
 	u64 last_dest_end = destoff;
 
-	ret = -ENOMEM;
 	buf = kvmalloc(fs_info->nodesize, GFP_KERNEL);
 	if (!buf)
-		return ret;
+		{ dump_stack(); return -ENOMEM; }
 
 	path = btrfs_alloc_path();
 	if (!path) {
 		kvfree(buf);
-		return ret;
+		{ dump_stack(); return -ENOMEM; }
 	}
 
 	path->reada = READA_FORWARD;
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index bf269ee..6462f97 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -469,16 +469,16 @@ static noinline_for_stack struct btrfs_backref_node *build_backref_tree(
 
 	iter = btrfs_backref_iter_alloc(rc->extent_root->fs_info, GFP_NOFS);
 	if (!iter)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
 	node = btrfs_backref_alloc_node(cache, bytenr, level);
 	if (!node) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
@@ -573,7 +573,7 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
 	new_node = btrfs_backref_alloc_node(cache, dest->node->start,
 					    node->level);
 	if (!new_node)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	new_node->lowest = node->lowest;
 	new_node->checked = 1;
@@ -613,7 +613,7 @@ fail:
 		btrfs_backref_free_edge(cache, new_edge);
 	}
 	btrfs_backref_free_node(cache, new_node);
-	return -ENOMEM;
+	{dump_stack();return -ENOMEM;}
 }
 
 /*
@@ -628,7 +628,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
 
 	node = kmalloc(sizeof(*node), GFP_NOFS);
 	if (!node)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	node->bytenr = root->commit_root->start;
 	node->data = root;
@@ -982,7 +982,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	bytenr -= BTRFS_I(reloc_inode)->index_cnt;
 	ret = btrfs_lookup_file_extent(NULL, root, path,
@@ -1633,7 +1633,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_FORWARD;
 
 	reloc_root = root->reloc_root;
@@ -2485,7 +2485,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out_free_blocks;
 	}
 
@@ -2614,7 +2614,7 @@ int setup_extent_mapping(struct inode *inode, u64 start, u64 end,
 
 	em = alloc_extent_map();
 	if (!em)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	em->start = start;
 	em->len = end + 1 - start;
@@ -2667,7 +2667,7 @@ static int relocate_file_extent_cluster(struct inode *inode,
 
 	ra = kzalloc(sizeof(*ra), GFP_NOFS);
 	if (!ra)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = prealloc_file_extent_cluster(BTRFS_I(inode), cluster);
 	if (ret)
@@ -2700,7 +2700,7 @@ static int relocate_file_extent_cluster(struct inode *inode,
 							PAGE_SIZE, true);
 				btrfs_delalloc_release_extents(BTRFS_I(inode),
 							PAGE_SIZE);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 		}
@@ -2901,7 +2901,7 @@ static int add_tree_block(struct reloc_control *rc,
 
 	block = kmalloc(sizeof(*block), GFP_NOFS);
 	if (!block)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	block->bytenr = extent_key->objectid;
 	block->key.objectid = rc->extent_root->fs_info->nodesize;
@@ -2939,7 +2939,7 @@ static int __add_tree_block(struct reloc_control *rc,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 again:
 	key.objectid = bytenr;
 	if (skinny) {
@@ -3243,7 +3243,7 @@ int prepare_to_relocate(struct reloc_control *rc)
 	rc->block_rsv = btrfs_alloc_block_rsv(rc->extent_root->fs_info,
 					      BTRFS_BLOCK_RSV_TEMP);
 	if (!rc->block_rsv)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	memset(&rc->cluster, 0, sizeof(rc->cluster));
 	rc->search_start = rc->block_group->start;
@@ -3292,7 +3292,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_FORWARD;
 
 	ret = prepare_to_relocate(rc);
@@ -3469,7 +3469,7 @@ static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_insert_empty_inode(trans, root, path, objectid);
 	if (ret)
@@ -3612,7 +3612,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
 	rc = alloc_reloc_control(fs_info);
 	if (!rc) {
 		btrfs_put_block_group(bg);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	rc->extent_root = extent_root;
@@ -3627,7 +3627,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
@@ -3755,7 +3755,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_BACK;
 
 	key.objectid = BTRFS_TREE_RELOC_OBJECTID;
@@ -3822,7 +3822,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
 
 	rc = alloc_reloc_control(fs_info);
 	if (!rc) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out;
 	}
 
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c
index 702dc54..90a6362 100644
--- a/fs/btrfs/root-tree.c
+++ b/fs/btrfs/root-tree.c
@@ -129,7 +129,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(trans, root, key, path, 0, 1);
 	if (ret < 0)
@@ -216,7 +216,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_ORPHAN_OBJECTID;
 	key.type = BTRFS_ORPHAN_ITEM_KEY;
@@ -300,7 +300,7 @@ int btrfs_del_root(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ret = btrfs_search_slot(trans, root, key, path, -1, 1);
 	if (ret < 0)
 		goto out;
@@ -329,7 +329,7 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = root_id;
 	key.type = BTRFS_ROOT_BACKREF_KEY;
@@ -400,7 +400,7 @@ int btrfs_add_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = root_id;
 	key.type = BTRFS_ROOT_BACKREF_KEY;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 70a90ca..5b82947 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -346,7 +346,7 @@ static struct full_stripe_lock *insert_full_stripe_lock(
 	 */
 	ret = kmalloc(sizeof(*ret), GFP_KERNEL);
 	if (!ret)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	ret->logical = fstripe_logical;
 	ret->refs = 1;
 	mutex_init(&ret->mutex);
@@ -628,7 +628,7 @@ static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
 
 nomem:
 	scrub_free_ctx(sctx);
-	return ERR_PTR(-ENOMEM);
+	{dump_stack();return ERR_PTR(-ENOMEM);}
 }
 
 static int scrub_print_warning_inode(u64 inum, u64 offset, u64 root,
@@ -1312,7 +1312,7 @@ static int scrub_setup_recheck_block(struct scrub_block *original_sblock,
 		if (!recover) {
 			btrfs_put_bbio(bbio);
 			btrfs_bio_counter_dec(fs_info);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 
 		refcount_set(&recover->refs, 1);
@@ -1338,7 +1338,7 @@ leave_nomem:
 				sctx->stat.malloc_errors++;
 				spin_unlock(&sctx->stat_lock);
 				scrub_put_recover(fs_info, recover);
-				return -ENOMEM;
+				{dump_stack();return -ENOMEM;}
 			}
 			scrub_page_get(spage);
 			sblock->pagev[page_index] = spage;
@@ -1658,7 +1658,7 @@ again:
 					      GFP_KERNEL);
 		if (!sctx->wr_curr_bio) {
 			mutex_unlock(&sctx->wr_lock);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 		sctx->wr_curr_bio->sctx = sctx;
 		sctx->wr_curr_bio->page_count = 0;
@@ -2211,7 +2211,7 @@ static int scrub_pages(struct scrub_ctx *sctx, u64 logical, u32 len,
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.malloc_errors++;
 		spin_unlock(&sctx->stat_lock);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	/* one ref inside this function, plus one for each page added to
@@ -2236,7 +2236,7 @@ leave_nomem:
 			sctx->stat.malloc_errors++;
 			spin_unlock(&sctx->stat_lock);
 			scrub_block_put(sblock);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 		BUG_ON(index >= SCRUB_MAX_PAGES_PER_BLOCK);
 		scrub_page_get(spage);
@@ -2549,7 +2549,7 @@ static int scrub_pages_for_parity(struct scrub_parity *sparity,
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.malloc_errors++;
 		spin_unlock(&sctx->stat_lock);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	/* one ref inside this function, plus one for each page added to
@@ -2570,7 +2570,7 @@ leave_nomem:
 			sctx->stat.malloc_errors++;
 			spin_unlock(&sctx->stat_lock);
 			scrub_block_put(sblock);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 		BUG_ON(index >= SCRUB_MAX_PAGES_PER_BLOCK);
 		/* For scrub block */
@@ -2869,7 +2869,7 @@ static noinline_for_stack int scrub_raid56_parity(struct scrub_ctx *sctx,
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.malloc_errors++;
 		spin_unlock(&sctx->stat_lock);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	ASSERT(map->stripe_len <= U32_MAX);
@@ -3172,12 +3172,12 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ppath = btrfs_alloc_path();
 	if (!ppath) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	/*
@@ -3613,7 +3613,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	path->reada = READA_FORWARD;
 	path->search_commit_root = 1;
@@ -3880,7 +3880,7 @@ skip_unfreeze:
 			break;
 		}
 		if (sctx->stat.malloc_errors > 0) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			break;
 		}
 skip:
@@ -3964,7 +3964,7 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
 	struct btrfs_workqueue *scrub_parity = NULL;
 	unsigned int flags = WQ_FREEZABLE | WQ_UNBOUND;
 	int max_active = fs_info->thread_pool_size;
-	int ret = -ENOMEM;
+	int ret;
 
 	if (refcount_inc_not_zero(&fs_info->scrub_workers_refcnt))
 		return 0;
@@ -3972,17 +3972,17 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
 	scrub_workers = btrfs_alloc_workqueue(fs_info, "scrub", flags,
 					      is_dev_replace ? 1 : max_active, 4);
 	if (!scrub_workers)
-		goto fail_scrub_workers;
+		{ dump_stack(); ret = -ENOMEM; goto fail_scrub_workers; }
 
 	scrub_wr_comp = btrfs_alloc_workqueue(fs_info, "scrubwrc", flags,
 					      max_active, 2);
 	if (!scrub_wr_comp)
-		goto fail_scrub_wr_completion_workers;
+		{ dump_stack(); ret = -ENOMEM; goto fail_scrub_wr_completion_workers;}
 
 	scrub_parity = btrfs_alloc_workqueue(fs_info, "scrubparity", flags,
 					     max_active, 2);
 	if (!scrub_parity)
-		goto fail_scrub_parity_workers;
+		{ dump_stack(); ret = -ENOMEM; goto fail_scrub_parity_workers;}
 
 	mutex_lock(&fs_info->scrub_lock);
 	if (refcount_read(&fs_info->scrub_workers_refcnt) == 0) {
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6b10652..bde1fc2 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -392,7 +392,7 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
 
 	if (len > PATH_MAX) {
 		WARN_ON(1);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	path_len = p->end - p->start;
@@ -409,7 +409,7 @@ static int fs_path_ensure_buf(struct fs_path *p, int len)
 		tmp_buf = krealloc(p->buf, len, GFP_KERNEL);
 	}
 	if (!tmp_buf)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	p->buf = tmp_buf;
 	/*
 	 * The real size of the buffer is bigger, this will let the fast path
@@ -862,7 +862,7 @@ static int get_inode_info(struct btrfs_root *root,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ret = __get_inode_info(root, path, ino, size, gen, mode, uid, gid,
 			       rdev);
 	btrfs_free_path(path);
@@ -906,12 +906,12 @@ static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
 
 	p = fs_path_alloc_reversed();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	tmp_path = alloc_path_for_send();
 	if (!tmp_path) {
 		fs_path_free(p);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 
@@ -1029,7 +1029,7 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
 	buf_len = PATH_MAX;
 	buf = kmalloc(buf_len, GFP_KERNEL);
 	if (!buf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1084,7 +1084,7 @@ static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
 			if (!buf) {
 				buf = kvmalloc(buf_len, GFP_KERNEL);
 				if (!buf) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					goto out;
 				}
 			}
@@ -1141,7 +1141,7 @@ static int get_inode_path(struct btrfs_root *root,
 
 	p = alloc_path_for_send();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	fs_path_reset(path);
 
@@ -1317,14 +1317,14 @@ static int find_extent_clone(struct send_ctx *sctx,
 
 	tmp_path = alloc_path_for_send();
 	if (!tmp_path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* We only use this path under the commit sem */
 	tmp_path->need_commit_sem = 0;
 
 	backref_ctx = kmalloc(sizeof(*backref_ctx), GFP_KERNEL);
 	if (!backref_ctx) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -1477,7 +1477,7 @@ static int read_symlink(struct btrfs_root *root,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = ino;
 	key.type = BTRFS_EXTENT_DATA_KEY;
@@ -1535,7 +1535,7 @@ static int gen_unique_name(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	while (1) {
 		len = snprintf(tmp, sizeof(tmp), "o%llu-%llu-%llu",
@@ -1697,7 +1697,7 @@ static int lookup_dir_item_inode(struct btrfs_root *root,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	di = btrfs_lookup_dir_item(NULL, root, path,
 			dir, name, name_len, 0);
@@ -1734,7 +1734,7 @@ static int get_first_ref(struct btrfs_root *root, u64 ino,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = ino;
 	key.type = BTRFS_INODE_REF_KEY;
@@ -1799,7 +1799,7 @@ static int is_first_ref(struct btrfs_root *root,
 
 	tmp_name = fs_path_alloc();
 	if (!tmp_name)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_first_ref(root, ino, &tmp_dir, NULL, tmp_name);
 	if (ret < 0)
@@ -1984,7 +1984,7 @@ static int did_overwrite_first_ref(struct send_ctx *sctx, u64 ino, u64 gen)
 
 	name = fs_path_alloc();
 	if (!name)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_first_ref(sctx->parent_root, ino, &dir, &dir_gen, name);
 	if (ret < 0)
@@ -2016,7 +2016,7 @@ static int name_cache_insert(struct send_ctx *sctx,
 		nce_head = kmalloc(sizeof(*nce_head), GFP_KERNEL);
 		if (!nce_head) {
 			kfree(nce);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 		INIT_LIST_HEAD(nce_head);
 
@@ -2210,7 +2210,7 @@ out_cache:
 	 */
 	nce = kmalloc(sizeof(*nce) + fs_path_len(dest) + 1, GFP_KERNEL);
 	if (!nce) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2272,7 +2272,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
 
 	name = fs_path_alloc();
 	if (!name) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2342,12 +2342,12 @@ static int send_subvol_begin(struct send_ctx *sctx)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	name = kmalloc(BTRFS_PATH_NAME_MAX, GFP_KERNEL);
 	if (!name) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	key.objectid = send_root->root_key.objectid;
@@ -2426,7 +2426,7 @@ static int send_truncate(struct send_ctx *sctx, u64 ino, u64 gen, u64 size)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_TRUNCATE);
 	if (ret < 0)
@@ -2456,7 +2456,7 @@ static int send_chmod(struct send_ctx *sctx, u64 ino, u64 gen, u64 mode)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_CHMOD);
 	if (ret < 0)
@@ -2487,7 +2487,7 @@ static int send_chown(struct send_ctx *sctx, u64 ino, u64 gen, u64 uid, u64 gid)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_CHOWN);
 	if (ret < 0)
@@ -2523,11 +2523,11 @@ static int send_utimes(struct send_ctx *sctx, u64 ino, u64 gen)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	path = alloc_path_for_send();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2585,7 +2585,7 @@ static int send_create_inode(struct send_ctx *sctx, u64 ino)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (ino != sctx->cur_ino) {
 		ret = get_inode_info(sctx->send_root, ino, NULL, &gen, &mode,
@@ -2669,7 +2669,7 @@ static int did_create_dir(struct send_ctx *sctx, u64 dir)
 
 	path = alloc_path_for_send();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2774,7 +2774,7 @@ static int __record_ref(struct list_head *head, u64 dir,
 
 	ref = kmalloc(sizeof(*ref), GFP_KERNEL);
 	if (!ref)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ref->dir = dir;
 	ref->dir_gen = dir_gen;
@@ -2789,7 +2789,7 @@ static int dup_ref(struct recorded_ref *ref, struct list_head *list)
 
 	new = kmalloc(sizeof(*ref), GFP_KERNEL);
 	if (!new)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	new->dir = ref->dir;
 	new->dir_gen = ref->dir_gen;
@@ -2830,7 +2830,7 @@ static int orphanize_inode(struct send_ctx *sctx, u64 ino, u64 gen,
 
 	orphan = fs_path_alloc();
 	if (!orphan)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = gen_unique_name(sctx, ino, gen, orphan);
 	if (ret < 0)
@@ -2867,7 +2867,7 @@ static struct orphan_dir_info *add_orphan_dir_info(struct send_ctx *sctx,
 
 	odi = kmalloc(sizeof(*odi), GFP_KERNEL);
 	if (!odi)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	odi->ino = dir_ino;
 	odi->gen = dir_gen;
 	odi->last_dir_index_offset = 0;
@@ -2940,7 +2940,7 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = dir;
 	key.type = BTRFS_DIR_INDEX_KEY;
@@ -3028,7 +3028,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
 
 	dm = kmalloc(sizeof(*dm), GFP_KERNEL);
 	if (!dm)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	dm->ino = ino;
 	dm->rmdir_ino = 0;
 	dm->rmdir_gen = 0;
@@ -3096,7 +3096,7 @@ static int add_pending_dir_move(struct send_ctx *sctx,
 
 	pm = kmalloc(sizeof(*pm), GFP_KERNEL);
 	if (!pm)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	pm->parent_ino = parent_ino;
 	pm->ino = ino;
 	pm->gen = ino_gen;
@@ -3225,7 +3225,7 @@ static int apply_dir_move(struct send_ctx *sctx, struct pending_dir_move *pm)
 	name = fs_path_alloc();
 	from_path = fs_path_alloc();
 	if (!name || !from_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -3303,7 +3303,7 @@ static int apply_dir_move(struct send_ctx *sctx, struct pending_dir_move *pm)
 
 		name = fs_path_alloc();
 		if (!name) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 		ret = get_cur_path(sctx, rmdir_ino, gen, name);
@@ -3468,7 +3468,7 @@ static int wait_for_dest_dir_move(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = parent_ref->dir;
 	key.type = BTRFS_DIR_ITEM_KEY;
@@ -3588,13 +3588,13 @@ static int is_ancestor(struct btrfs_root *root,
 	if (!fs_path) {
 		fs_path = fs_path_alloc();
 		if (!fs_path)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		free_fs_path = true;
 	}
 
 	path = alloc_path_for_send();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -3684,7 +3684,7 @@ static int wait_for_parent_move(struct send_ctx *sctx,
 	path_after = fs_path_alloc();
 	path_before = fs_path_alloc();
 	if (!path_after || !path_before) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -3783,7 +3783,7 @@ static int update_ref_path(struct send_ctx *sctx, struct recorded_ref *ref)
 	 */
 	new_path = fs_path_alloc();
 	if (!new_path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_cur_path(sctx, ref->dir, ref->dir_gen, new_path);
 	if (ret < 0) {
@@ -3850,7 +3850,7 @@ static int refresh_ref_path(struct send_ctx *sctx, struct recorded_ref *ref)
 
 	name = kmemdup(ref->name, ref->name_len, GFP_KERNEL);
 	if (!name)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	fs_path_reset(ref->full_path);
 	ret = get_cur_path(sctx, ref->dir, ref->dir_gen, ref->full_path);
@@ -3900,7 +3900,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move)
 
 	valid_path = fs_path_alloc();
 	if (!valid_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4334,7 +4334,7 @@ static int record_ref(struct btrfs_root *root, u64 dir, struct fs_path *name,
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_inode_info(root, dir, NULL, &gen, NULL, NULL,
 			NULL, NULL);
@@ -4543,7 +4543,7 @@ static int process_all_refs(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (cmd == BTRFS_COMPARE_TREE_NEW) {
 		root = sctx->send_root;
@@ -4661,7 +4661,7 @@ static int __process_new_xattr(int num, struct btrfs_key *di_key,
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * This hack is needed because empty acls are stored as zero byte
@@ -4701,7 +4701,7 @@ static int __process_deleted_xattr(int num, struct btrfs_key *di_key,
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
 	if (ret < 0)
@@ -4751,7 +4751,7 @@ static int __find_xattr(int num, struct btrfs_key *di_key,
 		ctx->found_data_len = data_len;
 		ctx->found_data = kmemdup(data, data_len, GFP_KERNEL);
 		if (!ctx->found_data)
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		return 1;
 	}
 	return 0;
@@ -4864,7 +4864,7 @@ static int process_all_new_xattrs(struct send_ctx *sctx)
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	root = sctx->send_root;
 
@@ -4963,7 +4963,7 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len)
 			page = find_or_create_page(inode->i_mapping, index,
 					GFP_KERNEL);
 			if (!page) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				break;
 			}
 		}
@@ -5009,7 +5009,7 @@ static int send_write(struct send_ctx *sctx, u64 offset, u32 len)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	btrfs_debug(fs_info, "send_write offset=%llu, len=%d", offset, len);
 
@@ -5053,7 +5053,7 @@ static int send_clone(struct send_ctx *sctx,
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_CLONE);
 	if (ret < 0)
@@ -5119,7 +5119,7 @@ static int send_update_extent(struct send_ctx *sctx,
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = begin_cmd(sctx, BTRFS_SEND_C_UPDATE_EXTENT);
 	if (ret < 0)
@@ -5168,7 +5168,7 @@ static int send_hole(struct send_ctx *sctx, u64 end)
 
 	p = fs_path_alloc();
 	if (!p)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
 	if (ret < 0)
 		goto tlv_put_failure;
@@ -5238,7 +5238,7 @@ static int send_capabilities(struct send_ctx *sctx)
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	di = btrfs_lookup_xattr(NULL, sctx->send_root, path, sctx->cur_ino,
 				XATTR_NAME_CAPS, strlen(XATTR_NAME_CAPS), 0);
@@ -5256,7 +5256,7 @@ static int send_capabilities(struct send_ctx *sctx)
 	fspath = fs_path_alloc();
 	buf = kmalloc(buf_len, GFP_KERNEL);
 	if (!fspath || !buf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -5309,7 +5309,7 @@ static int clone_range(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * There are inodes that have extents that lie behind its i_size. Don't
@@ -5579,7 +5579,7 @@ static int is_extent_unchanged(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	eb = left_path->nodes[0];
 	slot = left_path->slots[0];
@@ -5753,7 +5753,7 @@ static int get_last_extent(struct send_ctx *sctx, u64 offset)
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	sctx->cur_inode_last_extent = 0;
 
@@ -5786,7 +5786,7 @@ static int range_is_hole_in_parent(struct send_ctx *sctx,
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = sctx->cur_ino;
 	key.type = BTRFS_EXTENT_DATA_KEY;
@@ -5956,7 +5956,7 @@ static int process_all_extents(struct send_ctx *sctx)
 	root = sctx->send_root;
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = sctx->cmp_key->objectid;
 	key.type = BTRFS_EXTENT_DATA_KEY;
@@ -6191,7 +6191,7 @@ static int btrfs_unlink_all_paths(struct send_ctx *sctx)
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = sctx->cur_ino;
 	key.type = BTRFS_INODE_REF_KEY;
@@ -6649,7 +6649,7 @@ static int full_send_tree(struct send_ctx *sctx)
 
 	path = alloc_path_for_send();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_FORWARD;
 
 	key.objectid = BTRFS_FIRST_FREE_OBJECTID;
@@ -6821,18 +6821,18 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
 
 	left_path = btrfs_alloc_path();
 	if (!left_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	right_path = btrfs_alloc_path();
 	if (!right_path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
 	tmp_buf = kvmalloc(fs_info->nodesize, GFP_KERNEL);
 	if (!tmp_buf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -6884,7 +6884,7 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
 			btrfs_clone_extent_buffer(left_root->commit_root);
 	if (!left_path->nodes[left_level]) {
 		up_read(&fs_info->commit_root_sem);
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -6894,7 +6894,7 @@ static int btrfs_compare_trees(struct btrfs_root *left_root,
 			btrfs_clone_extent_buffer(right_root->commit_root);
 	if (!right_path->nodes[right_level]) {
 		up_read(&fs_info->commit_root_sem);
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	up_read(&fs_info->commit_root_sem);
@@ -7235,7 +7235,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 
 	sctx = kzalloc(sizeof(struct send_ctx), GFP_KERNEL);
 	if (!sctx) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -7267,7 +7267,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 	sctx->send_max_size = BTRFS_SEND_BUF_SIZE;
 	sctx->send_buf = kvmalloc(sctx->send_max_size, GFP_KERNEL);
 	if (!sctx->send_buf) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -7279,7 +7279,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 				     arg->clone_sources_count + 1,
 				     GFP_KERNEL);
 	if (!sctx->clone_roots) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -7289,7 +7289,7 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg)
 	if (arg->clone_sources_count) {
 		clone_sources_tmp = kvmalloc(alloc_size, GFP_KERNEL);
 		if (!clone_sources_tmp) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 
diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
index 2dc674b..8a396d4 100644
--- a/fs/btrfs/space-info.c
+++ b/fs/btrfs/space-info.c
@@ -195,7 +195,7 @@ static int create_space_info(struct btrfs_fs_info *info, u64 flags)
 
 	space_info = kzalloc(sizeof(*space_info), GFP_NOFS);
 	if (!space_info)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = percpu_counter_init(&space_info->total_bytes_pinned, 0,
 				 GFP_KERNEL);
diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c
index c69049e..f05c789 100644
--- a/fs/btrfs/subpage.c
+++ b/fs/btrfs/subpage.c
@@ -50,7 +50,7 @@ int btrfs_alloc_subpage(const struct btrfs_fs_info *fs_info,
 
 	*ret = kzalloc(sizeof(struct btrfs_subpage), GFP_NOFS);
 	if (!*ret)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	spin_lock_init(&(*ret)->lock);
 	if (type == BTRFS_SUBPAGE_METADATA)
 		atomic_set(&(*ret)->eb_refs, 0);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 447b50e..b945249 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -498,7 +498,7 @@ static int parse_rescue_options(struct btrfs_fs_info *info, const char *options)
 
 	opts = kstrdup(options, GFP_KERNEL);
 	if (!opts)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	orig = opts;
 
 	while ((p = strsep(&opts, ":")) != NULL) {
@@ -821,7 +821,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
 				btrfs_info(info, "max_inline at %llu",
 					   info->max_inline);
 			} else {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			break;
@@ -1109,7 +1109,7 @@ static int btrfs_parse_device_options(const char *options, fmode_t flags,
 	 */
 	opts = kstrdup(options, GFP_KERNEL);
 	if (!opts)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	orig = opts;
 
 	while ((p = strsep(&opts, ",")) != NULL) {
@@ -1122,7 +1122,7 @@ static int btrfs_parse_device_options(const char *options, fmode_t flags,
 		if (token == Opt_device) {
 			device_name = match_strdup(&args[0]);
 			if (!device_name) {
-				error = -ENOMEM;
+				{dump_stack(); error = -ENOMEM;}
 				goto out;
 			}
 			device = btrfs_scan_one_device(device_name, flags,
@@ -1162,7 +1162,7 @@ static int btrfs_parse_subvol_options(const char *options, char **subvol_name,
 	 */
 	opts = kstrdup(options, GFP_KERNEL);
 	if (!opts)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	orig = opts;
 
 	while ((p = strsep(&opts, ",")) != NULL) {
@@ -1176,7 +1176,7 @@ static int btrfs_parse_subvol_options(const char *options, char **subvol_name,
 			kfree(*subvol_name);
 			*subvol_name = match_strdup(&args[0]);
 			if (!*subvol_name) {
-				error = -ENOMEM;
+				{dump_stack(); error = -ENOMEM;}
 				goto out;
 			}
 			break;
@@ -1217,13 +1217,13 @@ char *btrfs_get_subvol_name_from_objectid(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto err;
 	}
 
 	name = kmalloc(PATH_MAX, GFP_KERNEL);
 	if (!name) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto err;
 	}
 	ptr = name + PATH_MAX - 1;
@@ -1347,7 +1347,7 @@ static int get_default_subvol_objectid(struct btrfs_fs_info *fs_info, u64 *objec
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * Find the "default" dir item which points to the root item that we
@@ -1418,7 +1418,7 @@ static int btrfs_fill_super(struct super_block *sb,
 
 	sb->s_root = d_make_root(inode);
 	if (!sb->s_root) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto fail_close;
 	}
 
@@ -1724,7 +1724,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
 	 */
 	fs_info = kvzalloc(sizeof(struct btrfs_fs_info), GFP_KERNEL);
 	if (!fs_info) {
-		error = -ENOMEM;
+		{dump_stack(); error = -ENOMEM;}
 		goto error_sec_opts;
 	}
 	btrfs_init_fs_info(fs_info);
@@ -1732,7 +1732,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
 	fs_info->super_copy = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL);
 	fs_info->super_for_commit = kzalloc(BTRFS_SUPER_INFO_SIZE, GFP_KERNEL);
 	if (!fs_info->super_copy || !fs_info->super_for_commit) {
-		error = -ENOMEM;
+		{dump_stack(); error = -ENOMEM;}
 		goto error_fs_info;
 	}
 
@@ -2217,7 +2217,7 @@ static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
 	devices_info = kmalloc_array(nr_devices, sizeof(*devices_info),
 			       GFP_KERNEL);
 	if (!devices_info)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* calc min stripe number for data space allocation */
 	type = btrfs_data_alloc_profile(fs_info);
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index cf7e766..8eb820c 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -1589,7 +1589,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
 		btrfs_err(fs_devs->fs_info,
 			  "failed to init sysfs device interface");
 		btrfs_sysfs_remove_fsid(fs_devs);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	fs_devs->devinfo_kobj = kobject_create_and_add("devinfo",
@@ -1598,7 +1598,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs)
 		btrfs_err(fs_devs->fs_info,
 			  "failed to init sysfs devinfo kobject");
 		btrfs_sysfs_remove_fsid(fs_devs);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	return 0;
@@ -1628,7 +1628,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
 #ifdef CONFIG_BTRFS_DEBUG
 	fs_info->debug_kobj = kobject_create_and_add("debug", fsid_kobj);
 	if (!fs_info->debug_kobj) {
-		error = -ENOMEM;
+		{dump_stack(); error = -ENOMEM;}
 		goto failure;
 	}
 
@@ -1640,7 +1640,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
 	fs_info->discard_debug_kobj = kobject_create_and_add("discard",
 						     fs_info->debug_kobj);
 	if (!fs_info->discard_debug_kobj) {
-		error = -ENOMEM;
+		{dump_stack(); error = -ENOMEM;}
 		goto failure;
 	}
 
@@ -1661,7 +1661,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
 	fs_info->space_info_kobj = kobject_create_and_add("allocation",
 						  fsid_kobj);
 	if (!fs_info->space_info_kobj) {
-		error = -ENOMEM;
+		{dump_stack(); error = -ENOMEM;}
 		goto failure;
 	}
 
@@ -1797,7 +1797,7 @@ int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info)
 
 	fs_info->qgroups_kobj = kobject_create_and_add("qgroups", fsid_kobj);
 	if (!fs_info->qgroups_kobj) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	rbtree_postorder_for_each_entry_safe(qgroup, next,
@@ -1867,7 +1867,7 @@ int __init btrfs_init_sysfs(void)
 
 	btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
 	if (!btrfs_kset)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	init_feature_attrs();
 	ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index acff6bb..f3f867a 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -320,7 +320,7 @@ loop:
 
 	cur_trans = kmalloc(sizeof(*cur_trans), GFP_NOFS);
 	if (!cur_trans)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	spin_lock(&fs_info->trans_lock);
 	if (fs_info->running_transaction) {
@@ -655,7 +655,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
 again:
 	h = kmem_cache_zalloc(btrfs_trans_handle_cachep, GFP_NOFS);
 	if (!h) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto alloc_fail;
 	}
 
@@ -1904,7 +1904,7 @@ int btrfs_commit_transaction_async(struct btrfs_trans_handle *trans,
 
 	ac = kmalloc(sizeof(*ac), GFP_NOFS);
 	if (!ac)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	INIT_WORK(&ac->work, do_async_commit);
 	ac->newtrans = btrfs_join_transaction(trans->root);
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 7c45d96..c783f99 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -40,7 +40,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	level = btrfs_header_level(root->node);
 
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 72c4b66..bf16bb8 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -426,7 +426,7 @@ static noinline int overwrite_item(struct btrfs_trans_handle *trans,
 			btrfs_release_path(path);
 			kfree(dst_copy);
 			kfree(src_copy);
-			return -ENOMEM;
+			{dump_stack();return -ENOMEM;}
 		}
 
 		read_extent_buffer(eb, src_copy, src_ptr, item_size);
@@ -909,7 +909,7 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
 	name_len = btrfs_dir_name_len(leaf, di);
 	name = kmalloc(name_len, GFP_NOFS);
 	if (!name)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	read_extent_buffer(leaf, name, (unsigned long)(di + 1), name_len);
 	btrfs_release_path(path);
@@ -993,7 +993,7 @@ static noinline int backref_in_log(struct btrfs_root *log,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(NULL, log, key, path, 0, 0);
 	if (ret < 0) {
@@ -1066,7 +1066,7 @@ again:
 								   victim_ref);
 			victim_name = kmalloc(victim_name_len, GFP_NOFS);
 			if (!victim_name)
-				return -ENOMEM;
+				{dump_stack();return -ENOMEM;}
 
 			read_extent_buffer(leaf, victim_name,
 					   (unsigned long)(victim_ref + 1),
@@ -1131,7 +1131,7 @@ again:
 
 			victim_name = kmalloc(victim_name_len, GFP_NOFS);
 			if (!victim_name)
-				return -ENOMEM;
+				{dump_stack();return -ENOMEM;}
 			read_extent_buffer(leaf, victim_name, (unsigned long)&extref->name,
 					   victim_name_len);
 
@@ -1211,7 +1211,7 @@ static int extref_get_fields(struct extent_buffer *eb, unsigned long ref_ptr,
 	*namelen = btrfs_inode_extref_name_len(eb, extref);
 	*name = kmalloc(*namelen, GFP_NOFS);
 	if (*name == NULL)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	read_extent_buffer(eb, *name, (unsigned long)&extref->name,
 			   *namelen);
@@ -1234,7 +1234,7 @@ static int ref_get_fields(struct extent_buffer *eb, unsigned long ref_ptr,
 	*namelen = btrfs_inode_ref_name_len(eb, ref);
 	*name = kmalloc(*namelen, GFP_NOFS);
 	if (*name == NULL)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	read_extent_buffer(eb, *name, (unsigned long)(ref + 1), *namelen);
 
@@ -1344,7 +1344,7 @@ static int btrfs_inode_ref_exists(struct inode *inode, struct inode *dir,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = btrfs_ino(BTRFS_I(inode));
 	key.type = ref_type;
@@ -1384,7 +1384,7 @@ static int add_link(struct btrfs_trans_handle *trans, struct btrfs_root *root,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	dir_item = btrfs_lookup_dir_item(NULL, root, path,
 					 btrfs_ino(BTRFS_I(dir)),
@@ -1731,7 +1731,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = count_inode_refs(root, BTRFS_I(inode), path);
 	if (ret < 0)
@@ -1943,7 +1943,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
 	name_len = btrfs_dir_name_len(eb, di);
 	name = kmalloc(name_len, GFP_NOFS);
 	if (!name) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -2123,7 +2123,7 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans,
 			if (!fixup_path) {
 				fixup_path = btrfs_alloc_path();
 				if (!fixup_path) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					break;
 				}
 			}
@@ -2259,7 +2259,7 @@ again:
 		name_len = btrfs_dir_name_len(eb, di);
 		name = kmalloc(name_len, GFP_NOFS);
 		if (!name) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 		read_extent_buffer(eb, name, (unsigned long)(di + 1),
@@ -2344,7 +2344,7 @@ static int replay_xattr_deletes(struct btrfs_trans_handle *trans,
 
 	log_path = btrfs_alloc_path();
 	if (!log_path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	search_key.objectid = ino;
 	search_key.type = BTRFS_XATTR_ITEM_KEY;
@@ -2379,7 +2379,7 @@ process_leaf:
 
 			name = kmalloc(name_len, GFP_NOFS);
 			if (!name) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			read_extent_buffer(path->nodes[0], name,
@@ -2457,7 +2457,7 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans,
 	dir_key.type = BTRFS_DIR_ITEM_KEY;
 	log_path = btrfs_alloc_path();
 	if (!log_path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	dir = read_one_inode(root, dirid);
 	/* it isn't an error if the inode isn't there, that can happen
@@ -2568,7 +2568,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	nritems = btrfs_header_nritems(eb);
 	for (i = 0; i < nritems; i++) {
@@ -2887,7 +2887,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	level = btrfs_header_level(log->node);
 	orig_level = level;
@@ -3466,7 +3466,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
 	log = root->log_root;
 	path = btrfs_alloc_path();
 	if (!path) {
-		err = -ENOMEM;
+		{dump_stack(); err = -ENOMEM;}
 		goto out_unlock;
 	}
 
@@ -4039,7 +4039,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
 	ins_data = kmalloc(nr * sizeof(struct btrfs_key) +
 			   nr * sizeof(u32), GFP_NOFS);
 	if (!ins_data)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ins_sizes = (u32 *)ins_data;
 	ins_keys = (struct btrfs_key *)(ins_data + nr * sizeof(u32));
@@ -4461,7 +4461,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans,
 		if (!dst_path) {
 			dst_path = btrfs_alloc_path();
 			if (!dst_path) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 		}
@@ -4859,7 +4859,7 @@ static int btrfs_check_ref_name_override(struct extent_buffer *eb,
 
 	search_path = btrfs_alloc_path();
 	if (!search_path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	search_path->search_commit_root = 1;
 	search_path->skip_locking = 1;
 
@@ -4894,7 +4894,7 @@ static int btrfs_check_ref_name_override(struct extent_buffer *eb,
 
 			new_name = krealloc(name, this_name_len, GFP_NOFS);
 			if (!new_name) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			name_len = this_name_len;
@@ -4954,7 +4954,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
 
 	ino_elem = kmalloc(sizeof(*ino_elem), GFP_NOFS);
 	if (!ino_elem)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ino_elem->ino = ino;
 	ino_elem->parent = parent;
 	list_add_tail(&ino_elem->list, &inode_list);
@@ -5097,7 +5097,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans,
 			if (ret > 0) {
 				ino_elem = kmalloc(sizeof(*ino_elem), GFP_NOFS);
 				if (!ino_elem) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					break;
 				}
 				ino_elem->ino = other_ino;
@@ -5281,11 +5281,11 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	dst_path = btrfs_alloc_path();
 	if (!dst_path) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	min_key.objectid = ino;
@@ -5605,12 +5605,12 @@ static int log_new_dir_dentries(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	dir_elem = kmalloc(sizeof(*dir_elem), GFP_NOFS);
 	if (!dir_elem) {
 		btrfs_free_path(path);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 	dir_elem->ino = btrfs_ino(start_inode);
 	list_add_tail(&dir_elem->list, &dir_list);
@@ -5688,7 +5688,7 @@ process_leaf:
 				new_dir_elem = kmalloc(sizeof(*new_dir_elem),
 						       GFP_NOFS);
 				if (!new_dir_elem) {
-					ret = -ENOMEM;
+					{dump_stack(); ret = -ENOMEM;}
 					goto next_dir_inode;
 				}
 				new_dir_elem->ino = di_key.objectid;
@@ -5732,7 +5732,7 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->skip_locking = 1;
 	path->search_commit_root = 1;
 
@@ -5965,7 +5965,7 @@ static int log_all_new_ancestors(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	search_key.objectid = ino;
 	search_key.type = BTRFS_INODE_REF_KEY;
@@ -6198,7 +6198,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	set_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags);
 
diff --git a/fs/btrfs/ulist.c b/fs/btrfs/ulist.c
index 3374c9e..45187a0 100644
--- a/fs/btrfs/ulist.c
+++ b/fs/btrfs/ulist.c
@@ -202,7 +202,7 @@ int ulist_add_merge(struct ulist *ulist, u64 val, u64 aux,
 	}
 	node = kmalloc(sizeof(*node), gfp_mask);
 	if (!node)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	node->val = val;
 	node->aux = aux;
diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 74023c8..a5a7ba2 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -37,7 +37,7 @@ static int btrfs_uuid_tree_lookup(struct btrfs_root *uuid_root, u8 *uuid,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -105,7 +105,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -168,7 +168,7 @@ int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -300,7 +300,7 @@ int btrfs_uuid_tree_iterate(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b3ca5f0..b3cd0ba 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -350,7 +350,7 @@ static struct btrfs_fs_devices *alloc_fs_devices(const u8 *fsid,
 
 	fs_devs = kzalloc(sizeof(*fs_devs), GFP_KERNEL);
 	if (!fs_devs)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	mutex_init(&fs_devs->device_list_mutex);
 
@@ -415,7 +415,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	/*
 	 * Preallocate a bio that's always going to be used for flushing device
@@ -424,7 +424,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
 	dev->flush_bio = bio_kmalloc(GFP_KERNEL, 0);
 	if (!dev->flush_bio) {
 		kfree(dev);
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 	}
 
 	INIT_LIST_HEAD(&dev->dev_list);
@@ -899,7 +899,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
 		if (!name) {
 			btrfs_free_device(device);
 			mutex_unlock(&fs_devices->device_list_mutex);
-			return ERR_PTR(-ENOMEM);
+			{dump_stack();return ERR_PTR(-ENOMEM);}
 		}
 		rcu_assign_pointer(device->name, name);
 
@@ -999,7 +999,7 @@ static noinline struct btrfs_device *device_list_add(const char *path,
 		name = rcu_string_strdup(path, GFP_NOFS);
 		if (!name) {
 			mutex_unlock(&fs_devices->device_list_mutex);
-			return ERR_PTR(-ENOMEM);
+			{dump_stack();return ERR_PTR(-ENOMEM);}
 		}
 		rcu_string_free(device->name);
 		rcu_assign_pointer(device->name, name);
@@ -1061,7 +1061,7 @@ static struct btrfs_fs_devices *clone_fs_devices(struct btrfs_fs_devices *orig)
 					GFP_KERNEL);
 			if (!name) {
 				btrfs_free_device(device);
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto error;
 			}
 			rcu_assign_pointer(device->name, name);
@@ -1609,7 +1609,7 @@ static int find_free_dev_extent_start(struct btrfs_device *device,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	max_hole_start = search_start;
 	max_hole_size = 0;
@@ -1751,7 +1751,7 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = device->devid;
 	key.offset = start;
@@ -1811,7 +1811,7 @@ static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans,
 	WARN_ON(test_bit(BTRFS_DEV_STATE_REPLACE_TGT, &device->dev_state));
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = device->devid;
 	key.offset = start;
@@ -1866,7 +1866,7 @@ static noinline int find_next_devid(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
 	key.type = BTRFS_DEV_ITEM_KEY;
@@ -1915,7 +1915,7 @@ static int btrfs_add_dev_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
 	key.type = BTRFS_DEV_ITEM_KEY;
@@ -1982,7 +1982,7 @@ static int btrfs_rm_dev_item(struct btrfs_device *device)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	trans = btrfs_start_transaction(root, 0);
 	if (IS_ERR(trans)) {
@@ -2542,7 +2542,7 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
 	key.offset = 0;
@@ -2655,7 +2655,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 
 	name = rcu_string_strdup(device_path, GFP_KERNEL);
 	if (!name) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto error_free_device;
 	}
 	rcu_assign_pointer(device->name, name);
@@ -2855,7 +2855,7 @@ static noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
 	key.type = BTRFS_DEV_ITEM_KEY;
@@ -2937,7 +2937,7 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
 	key.offset = chunk_offset;
@@ -3198,7 +3198,7 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 again:
 	key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
@@ -3313,7 +3313,7 @@ static int insert_balance_item(struct btrfs_fs_info *fs_info,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	trans = btrfs_start_transaction(root, 0);
 	if (IS_ERR(trans)) {
@@ -3363,7 +3363,7 @@ static int del_balance_item(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	trans = btrfs_start_transaction_fallback_global_rsv(root, 0);
 	if (IS_ERR(trans)) {
@@ -3749,7 +3749,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto error;
 	}
 
@@ -4369,7 +4369,7 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = BTRFS_BALANCE_OBJECTID;
 	key.type = BTRFS_TEMPORARY_ITEM_KEY;
@@ -4385,7 +4385,7 @@ int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
 
 	bctl = kzalloc(sizeof(*bctl), GFP_NOFS);
 	if (!bctl) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4524,7 +4524,7 @@ int btrfs_uuid_scan_kthread(void *data)
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -4720,7 +4720,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	path->reada = READA_BACK;
 
@@ -5369,7 +5369,7 @@ static int create_chunk(struct btrfs_trans_handle *trans,
 
 	map = kmalloc(map_lookup_size(ctl->num_stripes), GFP_NOFS);
 	if (!map)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	map->num_stripes = ctl->num_stripes;
 
 	for (i = 0; i < ctl->ndevs; ++i) {
@@ -5391,7 +5391,7 @@ static int create_chunk(struct btrfs_trans_handle *trans,
 	em = alloc_extent_map();
 	if (!em) {
 		kfree(map);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 	set_bit(EXTENT_FLAG_FS_MAPPING, &em->flags);
 	em->map_lookup = map;
@@ -5481,7 +5481,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, u64 type)
 	devices_info = kcalloc(fs_devices->rw_devices, sizeof(*devices_info),
 			       GFP_NOFS);
 	if (!devices_info)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = gather_device_info(fs_devices, &ctl, devices_info);
 	if (ret < 0)
@@ -5533,7 +5533,7 @@ int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans,
 
 	chunk = kzalloc(item_size, GFP_NOFS);
 	if (!chunk) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -5996,7 +5996,7 @@ static int __btrfs_map_block_for_discard(struct btrfs_fs_info *fs_info,
 
 	bbio = alloc_btrfs_bio(num_stripes, 0);
 	if (!bbio) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -6522,7 +6522,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
 
 	bbio = alloc_btrfs_bio(num_alloc_stripes, tgtdev_indexes);
 	if (!bbio) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -6988,11 +6988,11 @@ static int read_one_chunk(struct btrfs_key *key, struct extent_buffer *leaf,
 
 	em = alloc_extent_map();
 	if (!em)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	map = kmalloc(map_lookup_size(num_stripes), GFP_NOFS);
 	if (!map) {
 		free_extent_map(em);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	set_bit(EXTENT_FLAG_FS_MAPPING, &em->flags);
@@ -7452,7 +7452,7 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/*
 	 * uuid_mutex is needed only if we are mounting a sprout FS
@@ -7650,7 +7650,7 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	mutex_lock(&fs_devices->device_list_mutex);
 	list_for_each_entry(device, &fs_devices->devices, dev_list) {
@@ -7690,7 +7690,7 @@ static int update_dev_stat_item(struct btrfs_trans_handle *trans,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);
 	if (ret < 0) {
 		btrfs_warn_in_rcu(fs_info,
@@ -8050,7 +8050,7 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	path->reada = READA_FORWARD;
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 03135db..1253868 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -32,7 +32,7 @@ int btrfs_getxattr(struct inode *inode, const char *name,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	/* lookup the xattr by name */
 	di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(BTRFS_I(inode)),
@@ -93,7 +93,7 @@ int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->skip_release_on_error = 1;
 
 	if (!value) {
@@ -291,7 +291,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	path->reada = READA_FORWARD;
 
 	/* search for our xattrs */
@@ -478,7 +478,7 @@ static int btrfs_initxattrs(struct inode *inode,
 		name = kmalloc(XATTR_SECURITY_PREFIX_LEN +
 			       strlen(xattr->name) + 1, GFP_KERNEL);
 		if (!name) {
-			err = -ENOMEM;
+			{dump_stack(); err = -ENOMEM;}
 			break;
 		}
 		strcpy(name, XATTR_SECURITY_PREFIX);
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index d524acf..6da78e0 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -59,7 +59,7 @@ struct list_head *zlib_alloc_workspace(unsigned int level)
 
 	workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
 	if (!workspace)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	workspacesize = max(zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL),
 			zlib_inflate_workspacesize());
@@ -88,7 +88,7 @@ struct list_head *zlib_alloc_workspace(unsigned int level)
 	return &workspace->list;
 fail:
 	zlib_free_workspace(&workspace->list);
-	return ERR_PTR(-ENOMEM);
+	{dump_stack();return ERR_PTR(-ENOMEM);}
 }
 
 int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
@@ -123,7 +123,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 
 	out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 	if (out_page == NULL) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	cpage_out = kmap(out_page);
@@ -204,7 +204,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 			}
 			out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 			if (out_page == NULL) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			cpage_out = kmap(out_page);
@@ -242,7 +242,7 @@ int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
 			}
 			out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 			if (out_page == NULL) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			cpage_out = kmap(out_page);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 816a926..a041ed2 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -211,7 +211,7 @@ static int calculate_emulated_zone_size(struct btrfs_fs_info *fs_info)
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
 	if (ret < 0)
@@ -290,7 +290,7 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device)
 
 	zone_info = kzalloc(sizeof(*zone_info), GFP_KERNEL);
 	if (!zone_info)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	if (!bdev_is_zoned(bdev)) {
 		if (!fs_info->zone_size) {
@@ -318,19 +318,19 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device)
 
 	zone_info->seq_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL);
 	if (!zone_info->seq_zones) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
 	zone_info->empty_zones = bitmap_zalloc(zone_info->nr_zones, GFP_KERNEL);
 	if (!zone_info->empty_zones) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
 	zones = kcalloc(BTRFS_REPORT_NR_ZONES, sizeof(struct blk_zone), GFP_KERNEL);
 	if (!zones) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 
@@ -954,7 +954,7 @@ static int calculate_alloc_pointer(struct btrfs_block_group *cache,
 
 	path = btrfs_alloc_path();
 	if (!path)
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 
 	key.objectid = cache->start + cache->length;
 	key.type = 0;
@@ -1037,7 +1037,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
 	alloc_offsets = kcalloc(map->num_stripes, sizeof(*alloc_offsets), GFP_NOFS);
 	if (!alloc_offsets) {
 		free_extent_map(em);
-		return -ENOMEM;
+		{dump_stack();return -ENOMEM;}
 	}
 
 	for (i = 0; i < map->num_stripes; i++) {
diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 8e9626d..aa2ad36 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -346,7 +346,7 @@ struct list_head *zstd_alloc_workspace(unsigned int level)
 
 	workspace = kzalloc(sizeof(*workspace), GFP_KERNEL);
 	if (!workspace)
-		return ERR_PTR(-ENOMEM);
+		{dump_stack();return ERR_PTR(-ENOMEM);}
 
 	workspace->size = zstd_ws_mem_sizes[level - 1];
 	workspace->level = level;
@@ -363,7 +363,7 @@ struct list_head *zstd_alloc_workspace(unsigned int level)
 	return &workspace->list;
 fail:
 	zstd_free_workspace(&workspace->list);
-	return ERR_PTR(-ENOMEM);
+	{dump_stack();return ERR_PTR(-ENOMEM);}
 }
 
 int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
@@ -407,7 +407,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 	/* Allocate and map in the output buffer */
 	out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 	if (out_page == NULL) {
-		ret = -ENOMEM;
+		{dump_stack(); ret = -ENOMEM;}
 		goto out;
 	}
 	pages[nr_pages++] = out_page;
@@ -454,7 +454,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 			}
 			out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 			if (out_page == NULL) {
-				ret = -ENOMEM;
+				{dump_stack(); ret = -ENOMEM;}
 				goto out;
 			}
 			pages[nr_pages++] = out_page;
@@ -514,7 +514,7 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
 		}
 		out_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
 		if (out_page == NULL) {
-			ret = -ENOMEM;
+			{dump_stack(); ret = -ENOMEM;}
 			goto out;
 		}
 		pages[nr_pages++] = out_page;
-- 
2.30.2


  reply	other threads:[~2021-03-30  6:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 15:01 xfstests generic/476 failed on btrfs(errno=-12 Out of memory, kernel 5.11.10) Wang Yugui
2021-03-27  9:25 ` Wang Yugui
2021-03-27 10:19   ` Wang Yugui
2021-03-27 15:04     ` Wang Yugui
2021-03-28 10:56       ` Wang Yugui
2021-03-30  6:24         ` Wang Yugui [this message]
2021-03-30  6:40           ` Nikolay Borisov
2021-03-30  7:16             ` Wang Yugui
2021-04-13  9:13               ` Martin Raiber
2021-04-13  9:58                 ` Wang Yugui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210330142446.AB2E.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).