filemap: Use filemap_read_folio() in do_read_cache_folio()
By passing ->read_folio to filemap_read_folio(), we can use filemap_read_folio() in do_read_cache_folio(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
This commit is contained in:
parent
1dfa24a4bf
commit
290e1a3204
29
mm/filemap.c
29
mm/filemap.c
@ -2381,7 +2381,7 @@ retry:
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static int filemap_read_folio(struct file *file, struct address_space *mapping,
|
||||
static int filemap_read_folio(struct file *file, filler_t filler,
|
||||
struct folio *folio)
|
||||
{
|
||||
int error;
|
||||
@ -2393,7 +2393,7 @@ static int filemap_read_folio(struct file *file, struct address_space *mapping,
|
||||
*/
|
||||
folio_clear_error(folio);
|
||||
/* Start the actual read. The read will unlock the page. */
|
||||
error = mapping->a_ops->read_folio(file, folio);
|
||||
error = filler(file, folio);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
@ -2402,7 +2402,8 @@ static int filemap_read_folio(struct file *file, struct address_space *mapping,
|
||||
return error;
|
||||
if (folio_test_uptodate(folio))
|
||||
return 0;
|
||||
shrink_readahead_size_eio(&file->f_ra);
|
||||
if (file)
|
||||
shrink_readahead_size_eio(&file->f_ra);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@ -2475,7 +2476,8 @@ static int filemap_update_page(struct kiocb *iocb,
|
||||
if (iocb->ki_flags & (IOCB_NOIO | IOCB_NOWAIT | IOCB_WAITQ))
|
||||
goto unlock;
|
||||
|
||||
error = filemap_read_folio(iocb->ki_filp, mapping, folio);
|
||||
error = filemap_read_folio(iocb->ki_filp, mapping->a_ops->read_folio,
|
||||
folio);
|
||||
goto unlock_mapping;
|
||||
unlock:
|
||||
folio_unlock(folio);
|
||||
@ -2518,7 +2520,7 @@ static int filemap_create_folio(struct file *file,
|
||||
if (error)
|
||||
goto error;
|
||||
|
||||
error = filemap_read_folio(file, mapping, folio);
|
||||
error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
|
||||
if (error)
|
||||
goto error;
|
||||
|
||||
@ -3202,7 +3204,7 @@ page_not_uptodate:
|
||||
* and we need to check for errors.
|
||||
*/
|
||||
fpin = maybe_unlock_mmap_for_io(vmf, fpin);
|
||||
error = filemap_read_folio(file, mapping, folio);
|
||||
error = filemap_read_folio(file, mapping->a_ops->read_folio, folio);
|
||||
if (fpin)
|
||||
goto out_retry;
|
||||
folio_put(folio);
|
||||
@ -3515,15 +3517,8 @@ repeat:
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* A previous I/O error may have been due to temporary
|
||||
* failures.
|
||||
* Clear page error before actual read, PG_error will be
|
||||
* set again if read page fails.
|
||||
*/
|
||||
folio_clear_error(folio);
|
||||
filler:
|
||||
err = filler(file, folio);
|
||||
err = filemap_read_folio(file, filler, folio);
|
||||
if (err) {
|
||||
folio_put(folio);
|
||||
if (err == AOP_TRUNCATED_PAGE)
|
||||
@ -3531,12 +3526,6 @@ filler:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
folio_wait_locked(folio);
|
||||
if (!folio_test_uptodate(folio)) {
|
||||
folio_put(folio);
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
|
||||
out:
|
||||
folio_mark_accessed(folio);
|
||||
return folio;
|
||||
|
Loading…
x
Reference in New Issue
Block a user