Pass the sf buf to MEXTADD() as the optional argument. This permits
the simplification of socow_iodone() and sf_buf_free(); they don't have to reverse engineer the sf buf from the data's address.
This commit is contained in:
parent
5501d40bb9
commit
42de97a50a
@ -77,9 +77,6 @@ struct netsend_cow_stats {
|
||||
|
||||
static struct netsend_cow_stats socow_stats = {0,0,0,0,0,0,0,0,0,0,0};
|
||||
|
||||
extern struct sf_buf *sf_bufs;
|
||||
extern vm_offset_t sf_base;
|
||||
#define dtosf(x) (&sf_bufs[((uintptr_t)(x) - (uintptr_t)sf_base) >> PAGE_SHIFT])
|
||||
static void socow_iodone(void *addr, void *args);
|
||||
|
||||
static void
|
||||
@ -89,7 +86,7 @@ socow_iodone(void *addr, void *args)
|
||||
struct sf_buf *sf;
|
||||
vm_page_t pp;
|
||||
|
||||
sf = dtosf(addr);
|
||||
sf = args;
|
||||
pp = sf->m;
|
||||
s = splvm();
|
||||
/* remove COW mapping */
|
||||
@ -98,7 +95,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, NULL);
|
||||
sf_buf_free(addr, args);
|
||||
socow_stats.iodone++;
|
||||
}
|
||||
|
||||
@ -153,7 +150,7 @@ socow_setup(struct mbuf *m0, struct uio *uio)
|
||||
*/
|
||||
m0->m_data = (caddr_t)sf->kva;
|
||||
m0->m_len = PAGE_SIZE;
|
||||
MEXTADD(m0, sf->kva, PAGE_SIZE, socow_iodone, NULL, 0, EXT_SFBUF);
|
||||
MEXTADD(m0, sf->kva, PAGE_SIZE, socow_iodone, sf, 0, EXT_SFBUF);
|
||||
socow_stats.success++;
|
||||
|
||||
iov = uio->uio_iov;
|
||||
|
@ -1661,8 +1661,6 @@ sf_buf_alloc()
|
||||
return (sf);
|
||||
}
|
||||
|
||||
#define dtosf(x) (&sf_bufs[((uintptr_t)(x) - (uintptr_t)sf_base) >> PAGE_SHIFT])
|
||||
|
||||
/*
|
||||
* Detatch mapped page and release resources back to the system.
|
||||
*/
|
||||
@ -1672,7 +1670,7 @@ sf_buf_free(void *addr, void *args)
|
||||
struct sf_buf *sf;
|
||||
struct vm_page *m;
|
||||
|
||||
sf = dtosf(addr);
|
||||
sf = args;
|
||||
pmap_qremove((vm_offset_t)addr, 1);
|
||||
m = sf->m;
|
||||
vm_page_lock_queues();
|
||||
@ -1955,14 +1953,14 @@ do_sendfile(struct thread *td, struct sendfile_args *uap, int compat)
|
||||
MGETHDR(m, M_TRYWAIT, MT_DATA);
|
||||
if (m == NULL) {
|
||||
error = ENOBUFS;
|
||||
sf_buf_free((void *)sf->kva, NULL);
|
||||
sf_buf_free((void *)sf->kva, sf);
|
||||
sbunlock(&so->so_snd);
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
* Setup external storage for mbuf.
|
||||
*/
|
||||
MEXTADD(m, sf->kva, PAGE_SIZE, sf_buf_free, NULL, M_RDONLY,
|
||||
MEXTADD(m, sf->kva, PAGE_SIZE, sf_buf_free, sf, M_RDONLY,
|
||||
EXT_SFBUF);
|
||||
m->m_data = (char *) sf->kva + pgoff;
|
||||
m->m_pkthdr.len = m->m_len = xfsize;
|
||||
|
Loading…
Reference in New Issue
Block a user