Commit 7edb9a3e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: move zero filling of compressed read bios into common code

All algorithms have to fill the remainder of the orig_bio with zeroes,
so do it in common code.
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 34f888ce
...@@ -965,6 +965,8 @@ static int btrfs_decompress_bio(struct compressed_bio *cb) ...@@ -965,6 +965,8 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)
ret = compression_decompress_bio(workspace, cb); ret = compression_decompress_bio(workspace, cb);
put_workspace(type, workspace); put_workspace(type, workspace);
if (!ret)
zero_fill_bio(cb->orig_bio);
return ret; return ret;
} }
......
...@@ -389,8 +389,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -389,8 +389,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
*/ */
btrfs_err(fs_info, "unexpectedly large lzo segment len %u", btrfs_err(fs_info, "unexpectedly large lzo segment len %u",
seg_len); seg_len);
ret = -EIO; return -EIO;
goto out;
} }
/* Copy the compressed segment payload into workspace */ /* Copy the compressed segment payload into workspace */
...@@ -401,8 +400,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -401,8 +400,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
workspace->buf, &out_len); workspace->buf, &out_len);
if (ret != LZO_E_OK) { if (ret != LZO_E_OK) {
btrfs_err(fs_info, "failed to decompress"); btrfs_err(fs_info, "failed to decompress");
ret = -EIO; return -EIO;
goto out;
} }
/* Copy the data into inode pages */ /* Copy the data into inode pages */
...@@ -411,7 +409,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -411,7 +409,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
/* All data read, exit */ /* All data read, exit */
if (ret == 0) if (ret == 0)
goto out; return 0;
ret = 0; ret = 0;
/* Check if the sector has enough space for a segment header */ /* Check if the sector has enough space for a segment header */
...@@ -422,10 +420,8 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -422,10 +420,8 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
/* Skip the padding zeros */ /* Skip the padding zeros */
cur_in += sector_bytes_left; cur_in += sector_bytes_left;
} }
out:
if (!ret) return 0;
zero_fill_bio(cb->orig_bio);
return ret;
} }
int lzo_decompress(struct list_head *ws, const u8 *data_in, int lzo_decompress(struct list_head *ws, const u8 *data_in,
......
...@@ -350,8 +350,6 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -350,8 +350,6 @@ int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
zlib_inflateEnd(&workspace->strm); zlib_inflateEnd(&workspace->strm);
if (data_in) if (data_in)
kunmap_local(data_in); kunmap_local(data_in);
if (!ret)
zero_fill_bio(cb->orig_bio);
return ret; return ret;
} }
......
...@@ -609,7 +609,6 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ...@@ -609,7 +609,6 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
} }
} }
ret = 0; ret = 0;
zero_fill_bio(cb->orig_bio);
done: done:
if (workspace->in_buf.src) if (workspace->in_buf.src)
kunmap_local(workspace->in_buf.src); kunmap_local(workspace->in_buf.src);
......
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