提交 7adf5dfb 编写于 作者: J Josef Bacik 提交者: Chris Mason

Btrfs: handle no memory properly in prepare_pages

Instead of doing a BUG_ON(1) in prepare_pages if grab_cache_page() fails, just
loop through the pages we've already grabbed and unlock and release them, then
return -ENOMEM like we should.  Thanks,
Signed-off-by: NJosef Bacik <josef@redhat.com>
Signed-off-by: NChris Mason <chris.mason@oracle.com>
上级 ad0397a7
......@@ -792,8 +792,12 @@ static noinline int prepare_pages(struct btrfs_root *root, struct file *file,
for (i = 0; i < num_pages; i++) {
pages[i] = grab_cache_page(inode->i_mapping, index + i);
if (!pages[i]) {
err = -ENOMEM;
BUG_ON(1);
int c;
for (c = i - 1; c >= 0; c--) {
unlock_page(pages[c]);
page_cache_release(pages[c]);
}
return -ENOMEM;
}
wait_on_page_writeback(pages[i]);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册