]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: derive compression type from extent map during reads
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Tue, 26 Apr 2022 13:47:34 +0000 (08:47 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:17:31 +0000 (17:17 +0200)
Derive the compression type from extent map as opposed to the bio flags
passed. This makes it more precise and not reliant on function
parameters.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/inode.c

index 8fda38a58706714130d685b58d2fe8ff0747b50d..f4564f32f6d93b61b7952e13dbf2a071c0dadf46 100644 (file)
@@ -802,7 +802,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
  * bio we were passed and then call the bio end_io calls
  */
 void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
-                                 int mirror_num, unsigned long bio_flags)
+                                 int mirror_num)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct extent_map_tree *em_tree;
@@ -853,14 +853,14 @@ void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
        em_len = em->len;
        em_start = em->start;
 
-       free_extent_map(em);
-       em = NULL;
-
        cb->len = bio->bi_iter.bi_size;
        cb->compressed_len = compressed_len;
-       cb->compress_type = extent_compress_type(bio_flags);
+       cb->compress_type = em->compress_type;
        cb->orig_bio = bio;
 
+       free_extent_map(em);
+       em = NULL;
+
        cb->nr_pages = DIV_ROUND_UP(compressed_len, PAGE_SIZE);
        cb->compressed_pages = kcalloc(cb->nr_pages, sizeof(struct page *), GFP_NOFS);
        if (!cb->compressed_pages) {
index ac3c79f8c3492e079e75df08a577e1d363d7c94a..2707404389a5d0bdbdc3fef7d4115e9194d7f314 100644 (file)
@@ -103,7 +103,7 @@ blk_status_t btrfs_submit_compressed_write(struct btrfs_inode *inode, u64 start,
                                  struct cgroup_subsys_state *blkcg_css,
                                  bool writeback);
 void btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
-                                 int mirror_num, unsigned long bio_flags);
+                                 int mirror_num);
 
 unsigned int btrfs_compress_str2level(unsigned int type, const char *str);
 
index a907b3ba7d6228d97d0c767546c75f7d1c748db8..e6be5ebe76116364ebc939a1c2f86f1c43906ac2 100644 (file)
@@ -2606,8 +2606,7 @@ void btrfs_submit_data_bio(struct inode *inode, struct bio *bio,
                         * the bio if there were any errors, so just return
                         * here.
                         */
-                       btrfs_submit_compressed_read(inode, bio, mirror_num,
-                                                    bio_flags);
+                       btrfs_submit_compressed_read(inode, bio, mirror_num);
                        return;
                } else {
                        /*