* [PATCH] Btrfs: do not continue if out of memory happens
@ 2013-04-15 10:26 Wang Shilong
2013-04-17 22:21 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Wang Shilong @ 2013-04-15 10:26 UTC (permalink / raw)
To: Linux Btrfs; +Cc: wangshilong1991
If out of memory happens, we should return -ENOMEM directly to the caller
rather than continue the work.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
---
fs/btrfs/backref.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index bd605c8..2fd5703 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -352,6 +352,8 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
err = __resolve_indirect_ref(fs_info, search_commit_root,
time_seq, ref, parents,
extent_item_pos);
+ if (err == -ENOMEM)
+ goto out;
if (err)
continue;
@@ -367,7 +369,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
new_ref = kmalloc(sizeof(*new_ref), GFP_NOFS);
if (!new_ref) {
ret = -ENOMEM;
- break;
+ goto out;
}
memcpy(new_ref, ref, sizeof(*ref));
new_ref->parent = node->val;
@@ -377,7 +379,7 @@ static int __resolve_indirect_refs(struct btrfs_fs_info *fs_info,
}
ulist_reinit(parents);
}
-
+out:
ulist_free(parents);
return ret;
}
-- 1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Btrfs: do not continue if out of memory happens
2013-04-15 10:26 [PATCH] Btrfs: do not continue if out of memory happens Wang Shilong
@ 2013-04-17 22:21 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2013-04-17 22:21 UTC (permalink / raw)
To: Wang Shilong; +Cc: Linux Btrfs, wangshilong1991
On Mon, Apr 15, 2013 at 06:26:38PM +0800, Wang Shilong wrote:
> If out of memory happens, we should return -ENOMEM directly to the caller
> rather than continue the work.
Reviewed-by: David Sterba <dsterba@suse.cz>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-04-17 22:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-15 10:26 [PATCH] Btrfs: do not continue if out of memory happens Wang Shilong
2013-04-17 22:21 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox