[Midnightbsd-cvs] src [7886] U trunk/sys: reduce code duplication.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Sep 14 12:55:53 EDT 2016
Revision: 7886
http://svnweb.midnightbsd.org/src/?rev=7886
Author: laffer1
Date: 2016-09-14 12:55:53 -0400 (Wed, 14 Sep 2016)
Log Message:
-----------
reduce code duplication.
Modified Paths:
--------------
trunk/sys/fs/nfsclient/nfs_clbio.c
trunk/sys/fs/nwfs/nwfs_io.c
trunk/sys/fs/smbfs/smbfs_io.c
trunk/sys/nfsclient/nfs_bio.c
trunk/sys/vm/vm_page.c
trunk/sys/vm/vm_page.h
trunk/sys/vm/vnode_pager.c
Property Changed:
----------------
trunk/sys/fs/nwfs/nwfs_io.c
trunk/sys/fs/smbfs/smbfs_io.c
trunk/sys/nfsclient/nfs_bio.c
trunk/sys/vm/vm_page.c
trunk/sys/vm/vm_page.h
trunk/sys/vm/vnode_pager.c
Modified: trunk/sys/fs/nfsclient/nfs_clbio.c
===================================================================
--- trunk/sys/fs/nfsclient/nfs_clbio.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/fs/nfsclient/nfs_clbio.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -217,42 +217,18 @@
("nfs_getpages: page %p is dirty", m));
} else {
/*
- * Read operation was short. If no error occured
- * we may have hit a zero-fill section. We simply
- * leave valid set to 0.
+ * Read operation was short. If no error
+ * occured we may have hit a zero-fill
+ * section. We leave valid set to 0, and page
+ * is freed by vm_page_readahead_finish() if
+ * its index is not equal to requested, or
+ * page is zeroed and set valid by
+ * vm_pager_get_pages() for requested page.
*/
;
}
- if (i != ap->a_reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->oflags & VPO_WANTED) {
- vm_page_lock(m);
- vm_page_activate(m);
- vm_page_unlock(m);
- } else {
- vm_page_lock(m);
- vm_page_deactivate(m);
- vm_page_unlock(m);
- }
- vm_page_wakeup(m);
- } else {
- vm_page_lock(m);
- vm_page_free(m);
- vm_page_unlock(m);
- }
- }
+ if (i != ap->a_reqpage)
+ vm_page_readahead_finish(m);
}
VM_OBJECT_UNLOCK(object);
return (0);
Modified: trunk/sys/fs/nwfs/nwfs_io.c
===================================================================
--- trunk/sys/fs/nwfs/nwfs_io.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/fs/nwfs/nwfs_io.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -457,36 +457,8 @@
("nwfs_getpages: page %p is dirty", m));
}
- if (i != ap->a_reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->oflags & VPO_WANTED) {
- vm_page_lock(m);
- vm_page_activate(m);
- vm_page_unlock(m);
- } else {
- vm_page_lock(m);
- vm_page_deactivate(m);
- vm_page_unlock(m);
- }
- vm_page_wakeup(m);
- } else {
- vm_page_lock(m);
- vm_page_free(m);
- vm_page_unlock(m);
- }
- }
+ if (i != ap->a_reqpage)
+ vm_page_readahead_finish(m);
}
VM_OBJECT_UNLOCK(object);
return 0;
Property changes on: trunk/sys/fs/nwfs/nwfs_io.c
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.6
\ No newline at end of property
Modified: trunk/sys/fs/smbfs/smbfs_io.c
===================================================================
--- trunk/sys/fs/smbfs/smbfs_io.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/fs/smbfs/smbfs_io.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -521,36 +521,8 @@
;
}
- if (i != reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->oflags & VPO_WANTED) {
- vm_page_lock(m);
- vm_page_activate(m);
- vm_page_unlock(m);
- } else {
- vm_page_lock(m);
- vm_page_deactivate(m);
- vm_page_unlock(m);
- }
- vm_page_wakeup(m);
- } else {
- vm_page_lock(m);
- vm_page_free(m);
- vm_page_unlock(m);
- }
- }
+ if (i != reqpage)
+ vm_page_readahead_finish(m);
}
VM_OBJECT_UNLOCK(object);
return 0;
Property changes on: trunk/sys/fs/smbfs/smbfs_io.c
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.6
\ No newline at end of property
Modified: trunk/sys/nfsclient/nfs_bio.c
===================================================================
--- trunk/sys/nfsclient/nfs_bio.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/nfsclient/nfs_bio.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -211,42 +211,18 @@
("nfs_getpages: page %p is dirty", m));
} else {
/*
- * Read operation was short. If no error occured
- * we may have hit a zero-fill section. We simply
- * leave valid set to 0.
+ * Read operation was short. If no error
+ * occured we may have hit a zero-fill
+ * section. We leave valid set to 0, and page
+ * is freed by vm_page_readahead_finish() if
+ * its index is not equal to requested, or
+ * page is zeroed and set valid by
+ * vm_pager_get_pages() for requested page.
*/
;
}
- if (i != ap->a_reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->oflags & VPO_WANTED) {
- vm_page_lock(m);
- vm_page_activate(m);
- vm_page_unlock(m);
- } else {
- vm_page_lock(m);
- vm_page_deactivate(m);
- vm_page_unlock(m);
- }
- vm_page_wakeup(m);
- } else {
- vm_page_lock(m);
- vm_page_free(m);
- vm_page_unlock(m);
- }
- }
+ if (i != ap->a_reqpage)
+ vm_page_readahead_finish(m);
}
VM_OBJECT_UNLOCK(object);
return (0);
Property changes on: trunk/sys/nfsclient/nfs_bio.c
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.6
\ No newline at end of property
Modified: trunk/sys/vm/vm_page.c
===================================================================
--- trunk/sys/vm/vm_page.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/vm/vm_page.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -754,6 +754,45 @@
}
/*
+ * Unbusy and handle the page queueing for a page from the VOP_GETPAGES()
+ * array which is not the request page.
+ */
+void
+vm_page_readahead_finish(vm_page_t m)
+{
+
+ if (m->valid != 0) {
+ /*
+ * Since the page is not the requested page, whether
+ * it should be activated or deactivated is not
+ * obvious. Empirical results have shown that
+ * deactivating the page is usually the best choice,
+ * unless the page is wanted by another thread.
+ */
+ if (m->oflags & VPO_WANTED) {
+ vm_page_lock(m);
+ vm_page_activate(m);
+ vm_page_unlock(m);
+ } else {
+ vm_page_lock(m);
+ vm_page_deactivate(m);
+ vm_page_unlock(m);
+ }
+ vm_page_wakeup(m);
+ } else {
+ /*
+ * Free the completely invalid page. Such page state
+ * occurs due to the short read operation which did
+ * not covered our page at all, or in case when a read
+ * error happens.
+ */
+ vm_page_lock(m);
+ vm_page_free(m);
+ vm_page_unlock(m);
+ }
+}
+
+/*
* vm_page_sleep:
*
* Sleep and release the page and page queues locks.
Property changes on: trunk/sys/vm/vm_page.c
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.6
\ No newline at end of property
Modified: trunk/sys/vm/vm_page.h
===================================================================
--- trunk/sys/vm/vm_page.h 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/vm/vm_page.h 2016-09-14 16:55:53 UTC (rev 7886)
@@ -386,6 +386,7 @@
int vm_page_pa_tryrelock(pmap_t, vm_paddr_t, vm_paddr_t *);
vm_page_t vm_page_prev(vm_page_t m);
void vm_page_putfake(vm_page_t m);
+void vm_page_readahead_finish(vm_page_t m);
void vm_page_reference(vm_page_t m);
void vm_page_remove (vm_page_t);
void vm_page_rename (vm_page_t, vm_object_t, vm_pindex_t);
Property changes on: trunk/sys/vm/vm_page.h
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.5
\ No newline at end of property
Modified: trunk/sys/vm/vnode_pager.c
===================================================================
--- trunk/sys/vm/vnode_pager.c 2016-09-14 16:53:17 UTC (rev 7885)
+++ trunk/sys/vm/vnode_pager.c 2016-09-14 16:55:53 UTC (rev 7886)
@@ -983,37 +983,8 @@
mt));
}
- if (i != reqpage) {
-
- /*
- * whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere. (it already is in the object). Result:
- * It appears that empirical results show that
- * deactivating pages is best.
- */
-
- /*
- * just in case someone was asking for this page we
- * now tell them that it is ok to use
- */
- if (!error) {
- if (mt->oflags & VPO_WANTED) {
- vm_page_lock(mt);
- vm_page_activate(mt);
- vm_page_unlock(mt);
- } else {
- vm_page_lock(mt);
- vm_page_deactivate(mt);
- vm_page_unlock(mt);
- }
- vm_page_wakeup(mt);
- } else {
- vm_page_lock(mt);
- vm_page_free(mt);
- vm_page_unlock(mt);
- }
- }
+ if (i != reqpage)
+ vm_page_readahead_finish(mt);
}
VM_OBJECT_UNLOCK(object);
if (error) {
Property changes on: trunk/sys/vm/vnode_pager.c
___________________________________________________________________
Deleted: cvs2svn:cvs-rev
## -1 +0,0 ##
-1.7
\ No newline at end of property
More information about the Midnightbsd-cvs
mailing list