Initialize the bio lifetime to the data lifetime information that is available in struct inode. This patch reverts a small subset of commit c75e707fe1aa ("block: remove the per-bio/request write hint"). Cc: Jan Kara <jack@xxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Christian Brauner <brauner@xxxxxxxxxx> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- block/fops.c | 3 +++ fs/iomap/buffered-io.c | 2 ++ fs/iomap/direct-io.c | 1 + fs/mpage.c | 1 + 4 files changed, 7 insertions(+) diff --git a/block/fops.c b/block/fops.c index acff3d5d22d4..c9ca9f0fd48f 100644 --- a/block/fops.c +++ b/block/fops.c @@ -74,6 +74,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, } bio.bi_iter.bi_sector = pos >> SECTOR_SHIFT; bio.bi_ioprio = iocb->ki_ioprio; + bio.bi_lifetime = iocb->ki_filp->f_inode->i_write_hint; ret = bio_iov_iter_get_pages(&bio, iter); if (unlikely(ret)) @@ -206,6 +207,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, bio->bi_private = dio; bio->bi_end_io = blkdev_bio_end_io; bio->bi_ioprio = iocb->ki_ioprio; + bio->bi_lifetime = iocb->ki_filp->f_inode->i_write_hint; ret = bio_iov_iter_get_pages(bio, iter); if (unlikely(ret)) { @@ -323,6 +325,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT; bio->bi_end_io = blkdev_bio_end_io_async; bio->bi_ioprio = iocb->ki_ioprio; + bio->bi_lifetime = iocb->ki_filp->f_inode->i_write_hint; if (iov_iter_is_bvec(iter)) { /* diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 644479ccefbd..fe82c8882c62 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1660,6 +1660,7 @@ iomap_alloc_ioend(struct inode *inode, struct iomap_writepage_ctx *wpc, REQ_OP_WRITE | wbc_to_write_flags(wbc), GFP_NOFS, &iomap_ioend_bioset); bio->bi_iter.bi_sector = sector; + bio->bi_lifetime = inode->i_write_hint; wbc_init_bio(wbc, bio); ioend = container_of(bio, struct iomap_ioend, io_inline_bio); @@ -1690,6 +1691,7 @@ iomap_chain_bio(struct bio *prev) new = bio_alloc(prev->bi_bdev, BIO_MAX_VECS, prev->bi_opf, GFP_NOFS); bio_clone_blkg_association(new, prev); new->bi_iter.bi_sector = bio_end_sector(prev); + new->bi_lifetime = prev->bi_lifetime; bio_chain(prev, new); bio_get(prev); /* for iomap_finish_ioend */ diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index bcd3f8cf5ea4..df095b9700a7 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -381,6 +381,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter, GFP_KERNEL); bio->bi_iter.bi_sector = iomap_sector(iomap, pos); bio->bi_ioprio = dio->iocb->ki_ioprio; + bio->bi_lifetime = dio->iocb->ki_filp->f_inode->i_write_hint; bio->bi_private = dio; bio->bi_end_io = iomap_dio_bio_end_io; diff --git a/fs/mpage.c b/fs/mpage.c index 242e213ee064..19b7ced1a9aa 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -612,6 +612,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, GFP_NOFS); bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9); wbc_init_bio(wbc, bio); + bio->bi_lifetime = inode->i_write_hint; } /*