Commit f5daf2c7 authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: fix BUG_ON in btrfs_submit_compressed_write

This is similar to btrfs_submit_compressed_read(), if we fail after
bio is allocated, then we can use bio_endio() and errors are saved
 in bio->bi_error.  But please note that we don't return errors to
its caller because the caller assumes it won't call endio to cleanup
on error.
Signed-off-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e2bf6e89
...@@ -402,7 +402,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -402,7 +402,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
} }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */ if (ret) {
bio->bi_error = ret;
bio_endio(bio);
}
bio_put(bio); bio_put(bio);
...@@ -432,7 +435,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start, ...@@ -432,7 +435,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
} }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1); ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret); /* -ENOMEM */ if (ret) {
bio->bi_error = ret;
bio_endio(bio);
}
bio_put(bio); bio_put(bio);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment