summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2004-03-16 19:04:28 +0000
committeralc <alc@FreeBSD.org>2004-03-16 19:04:28 +0000
commita2e820d27ba39950df6b8aae95fdca17e3eeb69d (patch)
tree23b7ae48f580ace96e1510d279da96896036cc35 /sys/kern
parent71c3a1c44c43ab6da664e5414fb5ae531038d5c5 (diff)
downloadFreeBSD-src-a2e820d27ba39950df6b8aae95fdca17e3eeb69d.zip
FreeBSD-src-a2e820d27ba39950df6b8aae95fdca17e3eeb69d.tar.gz
Refactor the existing machine-dependent sf_buf_free() into a machine-
dependent function by the same name and a machine-independent function, sf_buf_mext(). Aside from the virtue of making more of the code machine- independent, this change also makes the interface more logical. Before, sf_buf_free() did more than simply undo an sf_buf_alloc(); it also unwired and if necessary freed the page. That is now the purpose of sf_buf_mext(). Thus, sf_buf_alloc() and sf_buf_free() can now be used as a general-purpose emphemeral map cache.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_cow.c2
-rw-r--r--sys/kern/uipc_syscalls.c26
2 files changed, 25 insertions, 3 deletions
diff --git a/sys/kern/uipc_cow.c b/sys/kern/uipc_cow.c
index ca6b2d8..8c00ffe 100644
--- a/sys/kern/uipc_cow.c
+++ b/sys/kern/uipc_cow.c
@@ -85,7 +85,7 @@ socow_iodone(void *addr, void *args)
vm_page_unlock_queues();
splx(s);
/* note that sf_buf_free() unwires the page for us*/
- sf_buf_free(addr, args);
+ sf_buf_mext(addr, args);
socow_stats.iodone++;
}
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 78405a7..9827021 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1632,6 +1632,28 @@ getsockaddr(namp, uaddr, len)
}
/*
+ * Detatch mapped page and release resources back to the system.
+ */
+void
+sf_buf_mext(void *addr, void *args)
+{
+ vm_page_t m;
+
+ m = sf_buf_page(args);
+ sf_buf_free(args);
+ vm_page_lock_queues();
+ vm_page_unwire(m, 0);
+ /*
+ * Check for the object going away on us. This can
+ * happen since we don't hold a reference to it.
+ * If so, we're responsible for freeing the page.
+ */
+ if (m->wire_count == 0 && m->object == NULL)
+ vm_page_free(m);
+ vm_page_unlock_queues();
+}
+
+/*
* sendfile(2)
*
* MPSAFE
@@ -1917,14 +1939,14 @@ retry_lookup:
MGETHDR(m, M_TRYWAIT, MT_DATA);
if (m == NULL) {
error = ENOBUFS;
- sf_buf_free((void *)sf_buf_kva(sf), sf);
+ sf_buf_mext((void *)sf_buf_kva(sf), sf);
sbunlock(&so->so_snd);
goto done;
}
/*
* Setup external storage for mbuf.
*/
- MEXTADD(m, sf_buf_kva(sf), PAGE_SIZE, sf_buf_free, sf, M_RDONLY,
+ MEXTADD(m, sf_buf_kva(sf), PAGE_SIZE, sf_buf_mext, sf, M_RDONLY,
EXT_SFBUF);
m->m_data = (char *)sf_buf_kva(sf) + pgoff;
m->m_pkthdr.len = m->m_len = xfsize;
OpenPOWER on IntegriCloud