Commit d44ed4f8 authored by Paolo 'Blaisorblade' Giarrusso's avatar Paolo 'Blaisorblade' Giarrusso Committed by Linus Torvalds

[PATCH] shmem_populate: avoid an useless check, and some comments

Either shmem_getpage returns a failure, or it found a page, or it was told
it couldn't do any I/O.  So it's useless to check nonblock in the else
branch.  We could add a BUG() there but I preferred to comment the
offending function.

This was taken out from one Ingo Molnar's old patch I'm resurrecting.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0abf40c1
...@@ -1504,8 +1504,12 @@ repeat: ...@@ -1504,8 +1504,12 @@ repeat:
return -EINVAL; return -EINVAL;
page = filemap_getpage(file, pgoff, nonblock); page = filemap_getpage(file, pgoff, nonblock);
/* XXX: This is wrong, a filesystem I/O error may have happened. Fix that as
* done in shmem_populate calling shmem_getpage */
if (!page && !nonblock) if (!page && !nonblock)
return -ENOMEM; return -ENOMEM;
if (page) { if (page) {
err = install_page(mm, vma, addr, page, prot); err = install_page(mm, vma, addr, page, prot);
if (err) { if (err) {
...@@ -1513,6 +1517,9 @@ repeat: ...@@ -1513,6 +1517,9 @@ repeat:
return err; return err;
} }
} else { } else {
/* No page was found just because we can't read it in now (being
* here implies nonblock != 0), but the page may exist, so set
* the PTE to fault it in later. */
err = install_file_pte(mm, vma, addr, pgoff, prot); err = install_file_pte(mm, vma, addr, pgoff, prot);
if (err) if (err)
return err; return err;
......
...@@ -1195,6 +1195,7 @@ static int shmem_populate(struct vm_area_struct *vma, ...@@ -1195,6 +1195,7 @@ static int shmem_populate(struct vm_area_struct *vma,
err = shmem_getpage(inode, pgoff, &page, sgp, NULL); err = shmem_getpage(inode, pgoff, &page, sgp, NULL);
if (err) if (err)
return err; return err;
/* Page may still be null, but only if nonblock was set. */
if (page) { if (page) {
mark_page_accessed(page); mark_page_accessed(page);
err = install_page(mm, vma, addr, page, prot); err = install_page(mm, vma, addr, page, prot);
...@@ -1202,7 +1203,10 @@ static int shmem_populate(struct vm_area_struct *vma, ...@@ -1202,7 +1203,10 @@ static int shmem_populate(struct vm_area_struct *vma,
page_cache_release(page); page_cache_release(page);
return err; return err;
} }
} else if (nonblock) { } else {
/* No page was found just because we can't read it in
* now (being here implies nonblock != 0), but the page
* may exist, so set the PTE to fault it in later. */
err = install_file_pte(mm, vma, addr, pgoff, prot); err = install_file_pte(mm, vma, addr, pgoff, prot);
if (err) if (err)
return err; return err;
......
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