Commit d31fa86a authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

mm/filemap: use filemap_read_page in filemap_fault

After splitting generic_file_buffered_read() into smaller parts, it turns
out we can reuse one of the parts in filemap_fault().  This fixes an
oversight -- waiting for the I/O to complete is now interruptible by a
fatal signal.  And it saves us a few bytes of text in an unlikely path.

  $ ./scripts/bloat-o-meter before.o after.o
  add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-207 (-207)
  Function                                     old     new   delta
  filemap_fault                               2187    1980    -207
  Total: Before=37491, After=37284, chg -0.55%

Link: https://lkml.kernel.org/r/20210226140011.2883498-1-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 985b71db
...@@ -2980,7 +2980,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) ...@@ -2980,7 +2980,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
struct file *file = vmf->vma->vm_file; struct file *file = vmf->vma->vm_file;
struct file *fpin = NULL; struct file *fpin = NULL;
struct address_space *mapping = file->f_mapping; struct address_space *mapping = file->f_mapping;
struct file_ra_state *ra = &file->f_ra;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
pgoff_t offset = vmf->pgoff; pgoff_t offset = vmf->pgoff;
pgoff_t max_off; pgoff_t max_off;
...@@ -3067,14 +3066,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) ...@@ -3067,14 +3066,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
* because there really aren't any performance issues here * because there really aren't any performance issues here
* and we need to check for errors. * and we need to check for errors.
*/ */
ClearPageError(page);
fpin = maybe_unlock_mmap_for_io(vmf, fpin); fpin = maybe_unlock_mmap_for_io(vmf, fpin);
error = mapping->a_ops->readpage(file, page); error = filemap_read_page(file, mapping, page);
if (!error) {
wait_on_page_locked(page);
if (!PageUptodate(page))
error = -EIO;
}
if (fpin) if (fpin)
goto out_retry; goto out_retry;
put_page(page); put_page(page);
...@@ -3082,7 +3075,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) ...@@ -3082,7 +3075,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
if (!error || error == AOP_TRUNCATED_PAGE) if (!error || error == AOP_TRUNCATED_PAGE)
goto retry_find; goto retry_find;
shrink_readahead_size_eio(ra);
return VM_FAULT_SIGBUS; return VM_FAULT_SIGBUS;
out_retry: out_retry:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment