sf_buf.h revision 253351
1122780Salc/*- 2137372Salc * Copyright (c) 2003-2004 Alan L. Cox <alc@cs.rice.edu> 3122780Salc * All rights reserved. 4122780Salc * 5122780Salc * Redistribution and use in source and binary forms, with or without 6122780Salc * modification, are permitted provided that the following conditions 7122780Salc * are met: 8122780Salc * 1. Redistributions of source code must retain the above copyright 9122780Salc * notice, this list of conditions and the following disclaimer. 10122780Salc * 2. Redistributions in binary form must reproduce the above copyright 11122780Salc * notice, this list of conditions and the following disclaimer in the 12122780Salc * documentation and/or other materials provided with the distribution. 13122780Salc * 14122780Salc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15122780Salc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16122780Salc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17122780Salc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18122780Salc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19122780Salc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20122780Salc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21122780Salc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22122780Salc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23122780Salc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24122780Salc * SUCH DAMAGE. 25122780Salc * 26122780Salc * $FreeBSD: head/sys/sys/sf_buf.h 253351 2013-07-15 06:16:57Z ae $ 27122780Salc */ 28122780Salc 29122780Salc#ifndef _SYS_SF_BUF_H_ 30122780Salc#define _SYS_SF_BUF_H_ 31122780Salc 32137372Salc/* 33137372Salc * Options to sf_buf_alloc() are specified through its flags argument. This 34137372Salc * argument's value should be the result of a bitwise or'ing of one or more 35137372Salc * of the following values. 36137372Salc */ 37137372Salc#define SFB_CATCH 1 /* Check signals if the allocation 38137372Salc sleeps. */ 39137372Salc#define SFB_CPUPRIVATE 2 /* Create a CPU private mapping. */ 40137372Salc#define SFB_DEFAULT 0 41137372Salc#define SFB_NOWAIT 4 /* Return NULL if all bufs are used. */ 42137372Salc 43122780Salcstruct vm_page; 44122780Salc 45123931Ssilbyextern int nsfbufs; /* Number of sendfile(2) bufs alloced */ 46123931Ssilbyextern int nsfbufspeak; /* Peak of nsfbufsused */ 47123931Ssilbyextern int nsfbufsused; /* Number of sendfile(2) bufs in use */ 48123931Ssilby 49253351Saestruct sfstat { /* sendfile statistics */ 50253351Sae uint64_t sf_iocnt; /* times sendfile had to do disk I/O */ 51253351Sae uint64_t sf_allocfail; /* times sfbuf allocation failed */ 52253351Sae uint64_t sf_allocwait; /* times sfbuf allocation had to wait */ 53253351Sae}; 54253351Sae 55253351Sae#ifdef _KERNEL 56253351Sae#include <machine/sf_buf.h> 57253351Sae#include <sys/counter.h> 58253351Sae 59253351Saeextern counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)]; 60253351Sae#define SFSTAT_ADD(name, val) \ 61253351Sae counter_u64_add(sfstat[offsetof(struct sfstat, name) / sizeof(uint64_t)],\ 62253351Sae (val)) 63253351Sae#define SFSTAT_INC(name) SFSTAT_ADD(name, 1) 64253351Sae#endif /* _KERNEL */ 65253351Sae 66122780Salcstruct sf_buf * 67137372Salc sf_buf_alloc(struct vm_page *m, int flags); 68127086Salcvoid sf_buf_free(struct sf_buf *sf); 69127086Salcvoid sf_buf_mext(void *addr, void *args); 70122780Salc 71122780Salc#endif /* !_SYS_SF_BUF_H_ */ 72