Re: [RFC PATCH 2/2] mm: introduce budgt control in readahead

From: Matthew Wilcox
Date: Wed May 08 2024 - 23:15:56 EST


On Thu, May 09, 2024 at 10:39:37AM +0800, zhaoyang.huang wrote:
> -static unsigned long get_next_ra_size(struct file_ra_state *ra,
> +static unsigned long get_next_ra_size(struct readahead_control *ractl,
> unsigned long max)
> {
> - unsigned long cur = ra->size;
> + unsigned long cur = ractl->ra->size;
> + struct inode *inode = ractl->mapping->host;
> + unsigned long budgt = inode->i_sb->s_bdev ?
> + blk_throttle_budgt(inode->i_sb->s_bdev) : 0;

You can't do this. There's no guarantee that the IO is going to
mapping->host->i_sb->s_bdev. You'd have to figure out how to ask the
filesystem to get the bdev for the particular range (eg the fs might
implement RAID internally).