summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_page.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-05-24 07:22:27 +0000
committerdillon <dillon@FreeBSD.org>2001-05-24 07:22:27 +0000
commita179ee09ab9ca2d9d1d09dc4752c53a13609f5e9 (patch)
treefaca8401754525a67aa26f144230806cf238e370 /sys/vm/vm_page.c
parenta26134411c10ba2364d3d85686667b8a87f0015f (diff)
downloadFreeBSD-src-a179ee09ab9ca2d9d1d09dc4752c53a13609f5e9.zip
FreeBSD-src-a179ee09ab9ca2d9d1d09dc4752c53a13609f5e9.tar.gz
This patch implements O_DIRECT about 80% of the way. It takes a patchset
Tor created a while ago, removes the raw I/O piece (that has cache coherency problems), and adds a buffer cache / VM freeing piece. Essentially this patch causes O_DIRECT I/O to not be left in the cache, but does not prevent it from going through the cache, hence the 80%. For the last 20% we need a method by which the I/O can be issued directly to buffer supplied by the user process and bypass the buffer cache entirely, but still maintain cache coherency. I also have the code working under -stable but the changes made to sys/file.h may not be MFCable, so an MFC is not on the table yet. Submitted by: tegge, dillon
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r--sys/vm/vm_page.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index c1817d5..dc391cb 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -1304,6 +1304,29 @@ vm_page_try_to_cache(vm_page_t m)
}
/*
+ * vm_page_try_to_free()
+ *
+ * Attempt to free the page. If we cannot free it, we do nothing.
+ * 1 is returned on success, 0 on failure.
+ */
+int
+vm_page_try_to_free(m)
+ vm_page_t m;
+{
+ if (m->dirty || m->hold_count || m->busy || m->wire_count ||
+ (m->flags & (PG_BUSY|PG_UNMANAGED))) {
+ return(0);
+ }
+ vm_page_test_dirty(m);
+ if (m->dirty)
+ return(0);
+ vm_page_busy(m);
+ vm_page_protect(m, VM_PROT_NONE);
+ vm_page_free(m);
+ return(1);
+}
+
+/*
* vm_page_cache
*
* Put the specified page onto the page cache queue (if appropriate).
OpenPOWER on IntegriCloud