Skip to content

Commit

Permalink
Btrfs: remove BUG_ON() in compress_file_range()
Browse files Browse the repository at this point in the history
It's not a big deal if we fail to allocate the array, and instead of
panic we can just give up compressing.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
  • Loading branch information
Li Zefan authored and David Sterba committed Oct 20, 2011
1 parent a05a9bb commit 560f7d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ static noinline int compress_file_range(struct inode *inode,
(BTRFS_I(inode)->flags & BTRFS_INODE_COMPRESS))) {
WARN_ON(pages);
pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
BUG_ON(!pages);
if (!pages) {
/* just bail out to the uncompressed code */
goto cont;
}

if (BTRFS_I(inode)->force_compress)
compress_type = BTRFS_I(inode)->force_compress;
Expand Down Expand Up @@ -424,6 +427,7 @@ static noinline int compress_file_range(struct inode *inode,
will_compress = 1;
}
}
cont:
if (start == 0) {
trans = btrfs_join_transaction(root);
BUG_ON(IS_ERR(trans));
Expand Down

0 comments on commit 560f7d7

Please sign in to comment.