Skip to content

Commit 560f7d7

Browse files
Li Zefankdave
authored andcommitted
Btrfs: remove BUG_ON() in compress_file_range()
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>
1 parent a05a9bb commit 560f7d7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎fs/btrfs/inode.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ static noinline int compress_file_range(struct inode *inode,
393393
(BTRFS_I(inode)->flags & BTRFS_INODE_COMPRESS))) {
394394
WARN_ON(pages);
395395
pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
396-
BUG_ON(!pages);
396+
if (!pages) {
397+
/* just bail out to the uncompressed code */
398+
goto cont;
399+
}
397400

398401
if (BTRFS_I(inode)->force_compress)
399402
compress_type = BTRFS_I(inode)->force_compress;
@@ -424,6 +427,7 @@ static noinline int compress_file_range(struct inode *inode,
424427
will_compress = 1;
425428
}
426429
}
430+
cont:
427431
if (start == 0) {
428432
trans = btrfs_join_transaction(root);
429433
BUG_ON(IS_ERR(trans));

0 commit comments

Comments
 (0)