btrfs: move zero filling of compressed read bios into common code
authorChristoph Hellwig <hch@lst.de>
Tue, 7 Mar 2023 16:39:38 +0000 (17:39 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Apr 2023 16:01:17 +0000 (18:01 +0200)
All algorithms have to fill the remainder of the orig_bio with zeroes,
so do it in common code.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/lzo.c
fs/btrfs/zlib.c
fs/btrfs/zstd.c

index 5b1de1c19991e9eb1cb7a06bfb869dcb9053b4ad..64c804dc3962f6d42bc5a96b421a8e190427b1d9 100644 (file)
@@ -965,6 +965,8 @@ static int btrfs_decompress_bio(struct compressed_bio *cb)
        ret = compression_decompress_bio(workspace, cb);
        put_workspace(type, workspace);
 
+       if (!ret)
+               zero_fill_bio(cb->orig_bio);
        return ret;
 }
 
index dc66ee98989e90cf3c7d4971c134bb5a61fe7a7e..3a095b9c6373eaba53d8751cb645b8cf01548dae 100644 (file)
@@ -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",
                                        seg_len);
-                       ret = -EIO;
-                       goto out;
+                       return -EIO;
                }
 
                /* Copy the compressed segment payload into workspace */
@@ -401,8 +400,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
                                            workspace->buf, &out_len);
                if (ret != LZO_E_OK) {
                        btrfs_err(fs_info, "failed to decompress");
-                       ret = -EIO;
-                       goto out;
+                       return -EIO;
                }
 
                /* Copy the data into inode pages */
@@ -411,7 +409,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
 
                /* All data read, exit */
                if (ret == 0)
-                       goto out;
+                       return 0;
                ret = 0;
 
                /* 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)
                /* Skip the padding zeros */
                cur_in += sector_bytes_left;
        }
-out:
-       if (!ret)
-               zero_fill_bio(cb->orig_bio);
-       return ret;
+
+       return 0;
 }
 
 int lzo_decompress(struct list_head *ws, const u8 *data_in,
index da7bb9187b68a3e2d17bbbbfb0774d45aa94936e..8acb05e176c540460dc5acd4e25ea6609a0f86bc 100644 (file)
@@ -350,8 +350,6 @@ done:
        zlib_inflateEnd(&workspace->strm);
        if (data_in)
                kunmap_local(data_in);
-       if (!ret)
-               zero_fill_bio(cb->orig_bio);
        return ret;
 }
 
index e34f1ab99d56fe26d0d0a14658fd53205817f9a2..f798da267590d4c1ade2df464008cc39595c3587 100644 (file)
@@ -609,7 +609,6 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
                }
        }
        ret = 0;
-       zero_fill_bio(cb->orig_bio);
 done:
        if (workspace->in_buf.src)
                kunmap_local(workspace->in_buf.src);