diff options
author | Josef Bacik <josef@redhat.com> | 2011-01-25 17:11:54 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-01-28 16:42:34 -0500 |
commit | 7adf5dfbb3af65a00e20b3ead224c3a1b40e4ec4 (patch) | |
tree | 5723e9679a7926ea744c242cc8351e64ce7503e4 | |
parent | ad0397a7a97f55fd7f70998ec208c5d8b90310ff (diff) |
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>
-rw-r--r-- | fs/btrfs/file.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 65b2424a4116..9e097fbfc78d 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -792,8 +792,12 @@ again: | |||
792 | for (i = 0; i < num_pages; i++) { | 792 | for (i = 0; i < num_pages; i++) { |
793 | pages[i] = grab_cache_page(inode->i_mapping, index + i); | 793 | pages[i] = grab_cache_page(inode->i_mapping, index + i); |
794 | if (!pages[i]) { | 794 | if (!pages[i]) { |
795 | err = -ENOMEM; | 795 | int c; |
796 | BUG_ON(1); | 796 | for (c = i - 1; c >= 0; c--) { |
797 | unlock_page(pages[c]); | ||
798 | page_cache_release(pages[c]); | ||
799 | } | ||
800 | return -ENOMEM; | ||
797 | } | 801 | } |
798 | wait_on_page_writeback(pages[i]); | 802 | wait_on_page_writeback(pages[i]); |
799 | } | 803 | } |