fuse: use fuse_range_is_writeback() instead of iterating pages

fuse_send_readpages() waits for writeback on each page.  This can be
replaced by a single call to fuse_range_is_writeback().

[SzM: split this off from "fuse: convert readahead to use folios"]

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Josef Bacik 2024-09-30 09:45:09 -04:00 committed by Miklos Szeredi
parent 86b74eb5a1
commit aaa32429da

View File

@ -992,12 +992,17 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file)
static void fuse_readahead(struct readahead_control *rac)
{
struct inode *inode = rac->mapping->host;
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode);
unsigned int i, max_pages, nr_pages = 0;
pgoff_t first = readahead_index(rac);
pgoff_t last = first + readahead_count(rac) - 1;
if (fuse_is_bad(inode))
return;
wait_event(fi->page_waitq, !fuse_range_is_writeback(inode, first, last));
max_pages = min_t(unsigned int, fc->max_pages,
fc->max_read / PAGE_SIZE);
@ -1024,8 +1029,6 @@ static void fuse_readahead(struct readahead_control *rac)
ap = &ia->ap;
nr_pages = __readahead_batch(rac, ap->pages, nr_pages);
for (i = 0; i < nr_pages; i++) {
fuse_wait_on_page_writeback(inode,
readahead_index(rac) + i);
ap->descs[i].length = PAGE_SIZE;
}
ap->num_pages = nr_pages;