]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ext4; Convert __ext4_read_bh() to bh_submit()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 28 May 2026 17:31:25 +0000 (18:31 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 4 Jun 2026 08:28:07 +0000 (10:28 +0200)
Avoid an extra indirect function call and changing the buffer refcount
by converting ext4_end_bitmap_read() from bh_end_io_t to bio_end_io_t
and calling bh_submit().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20260528173150.1093780-13-willy@infradead.org
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/ext4/ext4.h
fs/ext4/ialloc.c
fs/ext4/super.c

index 94283a991e5c4f0fe5ad2ccdd6646960702d1af9..6af11f0ff1c584a04d50e62cf2f2730945be506b 100644 (file)
@@ -2959,7 +2959,7 @@ extern unsigned long ext4_count_dirs(struct super_block *);
 extern void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
 extern int ext4_init_inode_table(struct super_block *sb,
                                 ext4_group_t group, int barrier);
-extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
+void ext4_end_bitmap_read(struct bio *bio);
 
 /* fast_commit.c */
 int ext4_fc_info_show(struct seq_file *seq, void *v);
@@ -3184,10 +3184,10 @@ extern struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb,
                                                   sector_t block);
 extern struct buffer_head *ext4_sb_bread_nofail(struct super_block *sb,
                                                sector_t block);
-extern void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
-                               bh_end_io_t *end_io, bool simu_fail);
-extern int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
-                       bh_end_io_t *end_io, bool simu_fail);
+void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
+               bio_end_io_t end_io, bool simu_fail);
+int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
+               bio_end_io_t end_io, bool simu_fail);
 extern int ext4_read_bh_lock(struct buffer_head *bh, blk_opf_t op_flags, bool wait);
 extern void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block);
 extern int ext4_seq_options_show(struct seq_file *seq, void *offset);
index 3fd8f00998521fb4ec1bcab7d718b3b1e1fc5e76..9aacd629a683589da79c47656d59eb53d9f1d563 100644 (file)
@@ -66,14 +66,16 @@ void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap)
                memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
 }
 
-void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate)
+void ext4_end_bitmap_read(struct bio *bio)
 {
+       struct buffer_head *bh;
+       bool uptodate = bio_endio_bh(bio, &bh);
+
        if (uptodate) {
                set_buffer_uptodate(bh);
                set_bitmap_uptodate(bh);
        }
        unlock_buffer(bh);
-       put_bh(bh);
 }
 
 static int ext4_validate_inode_bitmap(struct super_block *sb,
index 6a77db4d3124ec89eefec768e1a515caac3055fa..bc7faedcb8e428027cf411d94ce62607d944f732 100644 (file)
@@ -161,7 +161,7 @@ MODULE_ALIAS("ext3");
 
 
 static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
-                                 bh_end_io_t *end_io, bool simu_fail)
+                                 bio_end_io_t end_io, bool simu_fail)
 {
        if (simu_fail) {
                clear_buffer_uptodate(bh);
@@ -176,13 +176,13 @@ static inline void __ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
         */
        clear_buffer_verified(bh);
 
-       bh->b_end_io = end_io ? end_io : end_buffer_read_sync;
-       get_bh(bh);
-       submit_bh(REQ_OP_READ | op_flags, bh);
+       if (!end_io)
+               end_io = bh_end_read;
+       bh_submit(bh, REQ_OP_READ | op_flags, end_io);
 }
 
 void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
-                        bh_end_io_t *end_io, bool simu_fail)
+                        bio_end_io_t end_io, bool simu_fail)
 {
        BUG_ON(!buffer_locked(bh));
 
@@ -194,7 +194,7 @@ void ext4_read_bh_nowait(struct buffer_head *bh, blk_opf_t op_flags,
 }
 
 int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_flags,
-                bh_end_io_t *end_io, bool simu_fail)
+                bio_end_io_t end_io, bool simu_fail)
 {
        BUG_ON(!buffer_locked(bh));