Author: alc
Date: Thu May 19 19:27:33 2016
New Revision: 300225
URL: https://svnweb.freebsd.org/changeset/base/300225

Log:
  Clean up the handling of errors from vm_pager_get_pages().  Mostly, this
  cleanup consists of fixes to comments.  However, there is one change to
  code: Remove special-case handling of errors involving the kernel map.
  We do not perform I/O on the kernel map, so there is no need for this
  special case.
  
  Reviewed by:  kib (an earlier version)

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==============================================================================
--- head/sys/vm/vm_fault.c      Thu May 19 19:13:43 2016        (r300224)
+++ head/sys/vm/vm_fault.c      Thu May 19 19:27:33 2016        (r300225)
@@ -657,48 +657,40 @@ vnode_locked:
                                hardfault++;
                                break; /* break to PAGE HAS BEEN FOUND */
                        }
-                       /*
-                        * Remove the bogus page (which does not exist at this
-                        * object/offset); before doing so, we must get back
-                        * our object lock to preserve our invariant.
-                        *
-                        * Also wake up any other process that may want to bring
-                        * in this page.
-                        *
-                        * If this is the top-level object, we must leave the
-                        * busy page to prevent another process from rushing
-                        * past us, and inserting the page in that object at
-                        * the same time that we are.
-                        */
                        if (rv == VM_PAGER_ERROR)
                                printf("vm_fault: pager read error, pid %d 
(%s)\n",
                                    curproc->p_pid, curproc->p_comm);
+
                        /*
-                        * Data outside the range of the pager or an I/O error
-                        */
-                       /*
-                        * XXX - the check for kernel_map is a kludge to work
-                        * around having the machine panic on a kernel space
-                        * fault w/ I/O error.
+                        * If an I/O error occurred or the requested page was
+                        * outside the range of the pager, clean up and return
+                        * an error.
                         */
-                       if (((fs.map != kernel_map) && (rv == VM_PAGER_ERROR)) 
||
-                               (rv == VM_PAGER_BAD)) {
+                       if (rv == VM_PAGER_ERROR || rv == VM_PAGER_BAD) {
                                vm_page_lock(fs.m);
                                vm_page_free(fs.m);
                                vm_page_unlock(fs.m);
                                fs.m = NULL;
                                unlock_and_deallocate(&fs);
-                               return ((rv == VM_PAGER_ERROR) ? KERN_FAILURE : 
KERN_PROTECTION_FAILURE);
+                               return (rv == VM_PAGER_ERROR ? KERN_FAILURE :
+                                   KERN_PROTECTION_FAILURE);
                        }
+
+                       /*
+                        * The requested page does not exist at this object/
+                        * offset.  Remove the invalid page from the object,
+                        * waking up anyone waiting for it, and continue on to
+                        * the next object.  However, if this is the top-level
+                        * object, we must leave the busy page in place to
+                        * prevent another process from rushing past us, and
+                        * inserting the page in that object at the same time
+                        * that we are.
+                        */
                        if (fs.object != fs.first_object) {
                                vm_page_lock(fs.m);
                                vm_page_free(fs.m);
                                vm_page_unlock(fs.m);
                                fs.m = NULL;
-                               /*
-                                * XXX - we cannot just fall out at this
-                                * point, m has been freed and is invalid!
-                                */
                        }
                }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to