]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
btrfs: replace btrfs_io_bio::end_io with a simple helper
authorDavid Sterba <dsterba@suse.com>
Thu, 22 Nov 2018 16:16:49 +0000 (17:16 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Dec 2018 13:51:40 +0000 (14:51 +0100)
The end_io callback implemented as btrfs_io_bio_endio_readpage only
calls kfree. Also the callback is set only in case the csum buffer is
allocated and not pointing to the inline buffer. We can use that
information to drop the indirection and call a helper that will free the
csums only in the right case.

This shrinks struct btrfs_io_bio by 8 bytes.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/file-item.c
fs/btrfs/inode.c
fs/btrfs/volumes.h

index 4ea808d6cfbcc794c2dbeccde3fa6f6331b1d749..aef3c9866ff042b29693371f3820413189e6c5c3 100644 (file)
@@ -2623,8 +2623,7 @@ readpage_ok:
        if (extent_len)
                endio_readpage_release_extent(tree, extent_start, extent_len,
                                              uptodate);
-       if (io_bio->end_io)
-               io_bio->end_io(io_bio, blk_status_to_errno(bio->bi_status));
+       btrfs_io_bio_free_csum(io_bio);
        bio_put(bio);
 }
 
index 1f2d0a6ab634341e709b91900bba1e436b69fe85..920bf3b4b0ef5e5296d3cec2c2e82a8ab78dc0ac 100644 (file)
@@ -142,14 +142,6 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
        return ret;
 }
 
-static void btrfs_io_bio_endio_readpage(struct btrfs_io_bio *bio, int err)
-{
-       if (bio->csum != bio->csum_inline) {
-               kfree(bio->csum);
-               bio->csum = NULL;
-       }
-}
-
 static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio,
                                   u64 logical_offset, u32 *dst, int dio)
 {
@@ -184,7 +176,6 @@ static blk_status_t __btrfs_lookup_bio_sums(struct inode *inode, struct bio *bio
                                btrfs_free_path(path);
                                return BLK_STS_RESOURCE;
                        }
-                       btrfs_bio->end_io = btrfs_io_bio_endio_readpage;
                } else {
                        btrfs_bio->csum = btrfs_bio->csum_inline;
                }
index 26b8bec7c2dcace79a2efeedf97ab86f2b957721..6bfd37e58924821a49211c1fffd2e44e8fdc0e71 100644 (file)
@@ -8017,9 +8017,7 @@ static void btrfs_endio_direct_read(struct bio *bio)
 
        dio_bio->bi_status = err;
        dio_end_io(dio_bio);
-
-       if (io_bio->end_io)
-               io_bio->end_io(io_bio, blk_status_to_errno(err));
+       btrfs_io_bio_free_csum(io_bio);
        bio_put(bio);
 }
 
@@ -8372,8 +8370,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, struct inode *inode,
        if (!ret)
                return;
 
-       if (io_bio->end_io)
-               io_bio->end_io(io_bio, ret);
+       btrfs_io_bio_free_csum(io_bio);
 
 free_ordered:
        /*
index 702c78cf2b4df17a0848644810da63fa11fcbbe5..48e8bb546780bff15e6c01505263b63c32ebc503 100644 (file)
@@ -267,14 +267,12 @@ struct btrfs_fs_devices {
  * we allocate are actually btrfs_io_bios.  We'll cram as much of
  * struct btrfs_bio as we can into this over time.
  */
-typedef void (btrfs_io_bio_end_io_t) (struct btrfs_io_bio *bio, int err);
 struct btrfs_io_bio {
        unsigned int mirror_num;
        unsigned int stripe_index;
        u64 logical;
        u8 *csum;
        u8 csum_inline[BTRFS_BIO_INLINE_CSUM_SIZE];
-       btrfs_io_bio_end_io_t *end_io;
        struct bvec_iter iter;
        /*
         * This member must come last, bio_alloc_bioset will allocate enough
@@ -288,6 +286,14 @@ static inline struct btrfs_io_bio *btrfs_io_bio(struct bio *bio)
        return container_of(bio, struct btrfs_io_bio, bio);
 }
 
+static inline void btrfs_io_bio_free_csum(struct btrfs_io_bio *io_bio)
+{
+       if (io_bio->csum != io_bio->csum_inline) {
+               kfree(io_bio->csum);
+               io_bio->csum = NULL;
+       }
+}
+
 struct btrfs_bio_stripe {
        struct btrfs_device *dev;
        u64 physical;