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: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Родитель
ad0397a7a9
Коммит
7adf5dfbb3
|
@ -792,8 +792,12 @@ again:
|
||||||
for (i = 0; i < num_pages; i++) {
|
for (i = 0; i < num_pages; i++) {
|
||||||
pages[i] = grab_cache_page(inode->i_mapping, index + i);
|
pages[i] = grab_cache_page(inode->i_mapping, index + i);
|
||||||
if (!pages[i]) {
|
if (!pages[i]) {
|
||||||
err = -ENOMEM;
|
int c;
|
||||||
BUG_ON(1);
|
for (c = i - 1; c >= 0; c--) {
|
||||||
|
unlock_page(pages[c]);
|
||||||
|
page_cache_release(pages[c]);
|
||||||
|
}
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
wait_on_page_writeback(pages[i]);
|
wait_on_page_writeback(pages[i]);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче