svn commit: r274754 - in projects/sendfile/sys: sys vm
Gleb Smirnoff
glebius at FreeBSD.org
Thu Nov 20 17:36:26 UTC 2014
Author: glebius
Date: Thu Nov 20 17:36:25 2014
New Revision: 274754
URL: https://svnweb.freebsd.org/changeset/base/274754
Log:
o Since pager bufs are never put on freelist, share the space in
the structure in union.
o Add iodone callback pointer to the b_pager.
o In vnode_pager use new b_pager.pg_iodone to store iodone
pointer, eliminating the getpages_data structure and need to
allocate it.
Suggested by: kib
Sponsored by: Netflix
Sponsored by: Nginx, Inc.
Modified:
projects/sendfile/sys/sys/buf.h
projects/sendfile/sys/vm/vnode_pager.c
Modified: projects/sendfile/sys/sys/buf.h
==============================================================================
--- projects/sendfile/sys/sys/buf.h Thu Nov 20 17:31:25 2014 (r274753)
+++ projects/sendfile/sys/sys/buf.h Thu Nov 20 17:36:25 2014 (r274754)
@@ -107,7 +107,6 @@ struct buf {
off_t b_offset; /* Offset into file. */
TAILQ_ENTRY(buf) b_bobufs; /* (V) Buffer's associated vnode. */
uint32_t b_vflags; /* (V) BV_* flags */
- TAILQ_ENTRY(buf) b_freelist; /* (Q) Free list position inactive. */
unsigned short b_qindex; /* (Q) buffer queue index */
uint32_t b_flags; /* B_* flags. */
b_xflags_t b_xflags; /* extra flags */
@@ -124,9 +123,15 @@ struct buf {
struct ucred *b_rcred; /* Read credentials reference. */
struct ucred *b_wcred; /* Write credentials reference. */
void *b_saveaddr; /* Original b_addr for physio. */
- union pager_info {
- int pg_reqpage;
- } b_pager;
+ union {
+ TAILQ_ENTRY(buf) bu_freelist; /* (Q) */
+ struct {
+ void (*pg_iodone)(void *, vm_page_t *, int, int);
+ int pg_reqpage;
+ } bu_pager;
+ } b_union;
+#define b_freelist b_union.bu_freelist
+#define b_pager b_union.bu_pager
union cluster_info {
TAILQ_HEAD(cluster_list_head, buf) cluster_head;
TAILQ_ENTRY(buf) cluster_entry;
Modified: projects/sendfile/sys/vm/vnode_pager.c
==============================================================================
--- projects/sendfile/sys/vm/vnode_pager.c Thu Nov 20 17:31:25 2014 (r274753)
+++ projects/sendfile/sys/vm/vnode_pager.c Thu Nov 20 17:36:25 2014 (r274754)
@@ -77,15 +77,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vnode_pager.h>
#include <vm/vm_extern.h>
-/*
- * Structure to pass state from vnode_pager_generic_getpages()
- * to vnode_pager_generic_getpages_done_async().
- */
-struct getpages_data {
- void (*iodone)(void *, vm_page_t *, int, int);
- void *arg;
-};
-
static int vnode_pager_addr(struct vnode *vp, vm_ooffset_t address,
daddr_t *rtaddress, int *run);
static int vnode_pager_input_smlfs(vm_object_t object, vm_page_t m);
@@ -991,12 +982,8 @@ vnode_pager_generic_getpages(struct vnod
bp->b_iooffset = dbtob(bp->b_blkno);
if (iodone) { /* async */
- struct getpages_data *d;
-
- d = malloc(sizeof(*d), M_TEMP, M_WAITOK);
- d->iodone = iodone;
- d->arg = arg;
- bp->b_caller1 = d;
+ bp->b_pager.pg_iodone = iodone;
+ bp->b_caller1 = arg;
bp->b_iodone = vnode_pager_generic_getpages_done_async;
bp->b_flags |= B_ASYNC;
BUF_KERNPROC(bp);
@@ -1020,17 +1007,16 @@ vnode_pager_generic_getpages(struct vnod
static void
vnode_pager_generic_getpages_done_async(struct buf *bp)
{
- struct getpages_data *d = bp->b_caller1;
int error;
error = vnode_pager_generic_getpages_done(bp);
- d->iodone(d->arg, bp->b_pages, bp->b_pager.pg_reqpage, error);
+ bp->b_pager.pg_iodone(bp->b_caller1, bp->b_pages,
+ bp->b_pager.pg_reqpage, error);
for (int i = 0; i < bp->b_npages; i++)
bp->b_pages[i] = NULL;
bp->b_vp = NULL;
pbrelbo(bp);
relpbuf(bp, &vnode_pbuf_freecnt);
- free(d, M_TEMP);
}
static int
More information about the svn-src-projects
mailing list