Allow submission of bio through ext4_bio_write_page() without io_end. For the case where we are not converting unwritten extents we don't need io_end for anything anyway. Signed-off-by: Jan Kara <jack@xxxxxxx> --- fs/ext4/page-io.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 208241b06662..a8a6caf4752a 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -298,23 +298,20 @@ static void ext4_end_bio(struct bio *bio) ext4_io_end_t *io_end = bio->bi_private; sector_t bi_sector = bio->bi_iter.bi_sector; - BUG_ON(!io_end); bio->bi_end_io = NULL; if (bio->bi_error) { struct inode *inode = io_end->inode; ext4_warning(inode->i_sb, "I/O error %d writing to inode %lu " - "(offset %llu size %ld starting block %llu)", + "(starting block %llu)", bio->bi_error, inode->i_ino, - (unsigned long long) io_end->offset, - (long) io_end->size, (unsigned long long) bi_sector >> (inode->i_blkbits - 9)); mapping_set_error(inode->i_mapping, bio->bi_error); } - if (io_end->flag & EXT4_IO_END_UNWRITTEN) { + if (io_end && io_end->flag & EXT4_IO_END_UNWRITTEN) { /* * Link bio into list hanging from io_end. We have to do it * atomically as bio completions can be racing against each @@ -322,15 +319,17 @@ static void ext4_end_bio(struct bio *bio) */ bio->bi_private = xchg(&io_end->bio, bio); ext4_put_io_end_defer(io_end); - } else { + return; + } + if (io_end) { /* * Drop io_end reference early. Inode can get freed once * we finish the bio. */ ext4_put_io_end_defer(io_end); - ext4_finish_bio(bio); - bio_put(bio); } + ext4_finish_bio(bio); + bio_put(bio); } void ext4_io_submit(struct ext4_io_submit *io) @@ -366,7 +365,8 @@ static int io_submit_init_bio(struct ext4_io_submit *io, bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio->bi_bdev = bh->b_bdev; bio->bi_end_io = ext4_end_bio; - bio->bi_private = ext4_get_io_end(io->io_end); + if (io->io_end) + bio->bi_private = ext4_get_io_end(io->io_end); io->io_bio = bio; io->io_next_block = bh->b_blocknr; return 0; -- 2.12.0