filemap_fault can lose errors
Subsystems (3)
Matthew Wilcox
maintainerIf we encounter an error on a page, we can lose the error if we've dropped the mmap_sem while we wait for the I/O. That can result in taking the fault multiple times, and retrying the read multiple times. Spotted by inspection.
Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Fixes 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations")
mm/filemap.c +4 -2
@@ -2615,6 +2615,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)if (!PageUptodate (page)) error = -EIO ; } +if (error <0 ) + ret |=VM_FAULT_SIGBUS ;if (fpin) goto out_retry;put_page (page);
@@ -2622,9 +2624,9 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)if (!error || error ==AOP_TRUNCATED_PAGE ) goto retry_find; -/* Things didn't work out. Return zero to tell the mm layer so. */ +/* Things didn't work out. */ shrink_readahead_size_eio (file, ra); -return VM_FAULT_SIGBUS ; +return ret; out_retry:/*
Quoted 5 lines · Matthew Wilcox
If we encounter an error on a page, we can lose the error if we've dropped the
mmap_semwhile we wait for the I/O. That can result in taking the fault multiple times, and retrying the read multiple times. Spotted by inspection.
But does the patch make any difference?
Looking into x86 code, VM_FAULT_RETRY makes it retry the fault or return to userspace before it checks for VM_FAULT_SIGBUS bit.
Signature · 1 line
Kirill A. Shutemov