Re: [PATCH v8 05/19] block, fs: Restore the per-bio/request data lifetime fields

Kanchan Joshi
2024-01-22T09:23:51Z

On 12/19/2023 5:37 AM, Bart Van Assche wrote:

> diff --git a/block/fops.c b/block/fops.c
> index 0abaac705daf..787ce52bc2c6 100644
> --- a/block/fops.c
> +++ b/block/fops.c
> @@ -73,6 +73,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb,
> bio_init(&bio, bdev, vecs, nr_pages, dio_bio_write_op(iocb));
> }
> bio.bi_iter.bi_sector = pos >> SECTOR_SHIFT;
> + bio.bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint;
> bio.bi_ioprio = iocb->ki_ioprio;
>
> ret = bio_iov_iter_get_pages(&bio, iter);
> @@ -203,6 +204,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
>
> for (;;) {
> bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT;
> + bio->bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint;
> bio->bi_private = dio;
> bio->bi_end_io = blkdev_bio_end_io;
> bio->bi_ioprio = iocb->ki_ioprio;
> @@ -321,6 +323,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb,
> dio->flags = 0;
> dio->iocb = iocb;
> bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT;
> + bio->bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint;

This (and two more places above) should rather be changed to:

bio.bi_write_hint = bdev_file_inode(iocb->ki_filp)->i_write_hint;

Note that at other places too (e.g., blkdev_fallocate, blkdev_mmap,
blkdev_lseek) bdev inode is used and not file inode.