2005-01-07 01:45:51 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Rick Macklem at The University of Guelph.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-05-31 17:27:58 +00:00
|
|
|
* @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* These functions support the macros and help fiddle mbuf chains for
|
2010-02-09 23:40:07 +00:00
|
|
|
* the nfs op functions. They do things like create the rpc header and
|
1994-05-24 10:09:53 +00:00
|
|
|
* copy data between mbuf chains and uio lists.
|
|
|
|
*/
|
2001-09-18 23:32:09 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
#include <sys/bio.h>
|
1999-06-27 11:44:22 +00:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/proc.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/vnode.h>
|
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/stat.h>
|
1995-06-27 11:07:30 +00:00
|
|
|
#include <sys/malloc.h>
|
2010-02-16 20:00:21 +00:00
|
|
|
#include <sys/module.h>
|
1994-09-22 22:10:49 +00:00
|
|
|
#include <sys/sysent.h>
|
|
|
|
#include <sys/syscall.h>
|
2010-02-09 23:45:14 +00:00
|
|
|
#include <sys/sysctl.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1994-10-02 17:27:07 +00:00
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_object.h>
|
|
|
|
#include <vm/vm_extern.h>
|
1994-10-02 17:27:07 +00:00
|
|
|
|
1995-06-27 11:07:30 +00:00
|
|
|
#include <nfs/nfsproto.h>
|
2001-09-18 23:32:09 +00:00
|
|
|
#include <nfsserver/nfs.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <nfs/xdr_subs.h>
|
2001-09-18 23:32:09 +00:00
|
|
|
#include <nfs/nfs_common.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
1995-12-17 21:14:36 +00:00
|
|
|
enum vtype nv3tov_type[8]= {
|
|
|
|
VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO
|
|
|
|
};
|
2001-09-18 23:32:09 +00:00
|
|
|
nfstype nfsv3_type[9] = {
|
|
|
|
NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK, NFFIFO, NFNON
|
1995-06-27 11:07:30 +00:00
|
|
|
};
|
|
|
|
|
2010-02-09 23:40:07 +00:00
|
|
|
static void *nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos,
|
|
|
|
int how);
|
2004-12-06 17:33:52 +00:00
|
|
|
|
2010-02-16 20:00:21 +00:00
|
|
|
SYSCTL_NODE(_vfs, OID_AUTO, nfs_common, CTLFLAG_RD, 0, "NFS common support");
|
2010-02-09 23:45:14 +00:00
|
|
|
|
|
|
|
static int nfs_realign_test;
|
2010-02-16 20:00:21 +00:00
|
|
|
SYSCTL_INT(_vfs_nfs_common, OID_AUTO, realign_test, CTLFLAG_RD,
|
|
|
|
&nfs_realign_test, 0, "Number of realign tests done");
|
2010-02-09 23:45:14 +00:00
|
|
|
|
|
|
|
static int nfs_realign_count;
|
2010-02-16 20:00:21 +00:00
|
|
|
SYSCTL_INT(_vfs_nfs_common, OID_AUTO, realign_count, CTLFLAG_RD,
|
|
|
|
&nfs_realign_count, 0, "Number of mbuf realignments done");
|
2010-02-09 23:45:14 +00:00
|
|
|
|
1998-03-30 09:56:58 +00:00
|
|
|
u_quad_t
|
2010-02-09 23:40:07 +00:00
|
|
|
nfs_curusec(void)
|
1998-03-30 09:56:58 +00:00
|
|
|
{
|
|
|
|
struct timeval tv;
|
2001-09-18 23:32:09 +00:00
|
|
|
|
1998-03-30 09:56:58 +00:00
|
|
|
getmicrotime(&tv);
|
|
|
|
return ((u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* copies mbuf chain to the uio scatter/gather list
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
2001-09-18 23:32:09 +00:00
|
|
|
nfsm_mbuftouio(struct mbuf **mrep, struct uio *uiop, int siz, caddr_t *dpos)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
char *mbufcp, *uiocp;
|
|
|
|
int xfer, left, len;
|
|
|
|
struct mbuf *mp;
|
1994-05-24 10:09:53 +00:00
|
|
|
long uiosiz, rem;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
mp = *mrep;
|
|
|
|
mbufcp = *dpos;
|
|
|
|
len = mtod(mp, caddr_t)+mp->m_len-mbufcp;
|
|
|
|
rem = nfsm_rndup(siz)-siz;
|
|
|
|
while (siz > 0) {
|
|
|
|
if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL)
|
|
|
|
return (EFBIG);
|
|
|
|
left = uiop->uio_iov->iov_len;
|
|
|
|
uiocp = uiop->uio_iov->iov_base;
|
|
|
|
if (left > siz)
|
|
|
|
left = siz;
|
|
|
|
uiosiz = left;
|
|
|
|
while (left > 0) {
|
|
|
|
while (len == 0) {
|
|
|
|
mp = mp->m_next;
|
|
|
|
if (mp == NULL)
|
|
|
|
return (EBADRPC);
|
|
|
|
mbufcp = mtod(mp, caddr_t);
|
|
|
|
len = mp->m_len;
|
|
|
|
}
|
|
|
|
xfer = (left > len) ? len : left;
|
|
|
|
#ifdef notdef
|
|
|
|
/* Not Yet.. */
|
|
|
|
if (uiop->uio_iov->iov_op != NULL)
|
|
|
|
(*(uiop->uio_iov->iov_op))
|
|
|
|
(mbufcp, uiocp, xfer);
|
|
|
|
else
|
|
|
|
#endif
|
2009-07-12 03:53:52 +00:00
|
|
|
if (uiop->uio_segflg == UIO_SYSSPACE)
|
1994-05-24 10:09:53 +00:00
|
|
|
bcopy(mbufcp, uiocp, xfer);
|
2009-07-12 03:53:52 +00:00
|
|
|
else
|
1994-05-24 10:09:53 +00:00
|
|
|
copyout(mbufcp, uiocp, xfer);
|
|
|
|
left -= xfer;
|
|
|
|
len -= xfer;
|
|
|
|
mbufcp += xfer;
|
|
|
|
uiocp += xfer;
|
|
|
|
uiop->uio_offset += xfer;
|
|
|
|
uiop->uio_resid -= xfer;
|
|
|
|
}
|
|
|
|
if (uiop->uio_iov->iov_len <= siz) {
|
|
|
|
uiop->uio_iovcnt--;
|
|
|
|
uiop->uio_iov++;
|
|
|
|
} else {
|
2002-10-11 14:58:34 +00:00
|
|
|
uiop->uio_iov->iov_base =
|
|
|
|
(char *)uiop->uio_iov->iov_base + uiosiz;
|
1994-05-24 10:09:53 +00:00
|
|
|
uiop->uio_iov->iov_len -= uiosiz;
|
|
|
|
}
|
|
|
|
siz -= uiosiz;
|
|
|
|
}
|
|
|
|
*dpos = mbufcp;
|
|
|
|
*mrep = mp;
|
|
|
|
if (rem > 0) {
|
|
|
|
if (len < rem)
|
|
|
|
error = nfs_adv(mrep, dpos, rem, len);
|
|
|
|
else
|
|
|
|
*dpos += rem;
|
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Help break down an mbuf chain by setting the first siz bytes contiguous
|
|
|
|
* pointed to by returned val.
|
2001-09-27 22:40:38 +00:00
|
|
|
* This is used by the macros nfsm_dissect for tough
|
1994-05-24 10:09:53 +00:00
|
|
|
* cases. (The macros use the vars. dpos and dpos2)
|
|
|
|
*/
|
2001-09-27 22:40:38 +00:00
|
|
|
void *
|
2004-12-06 17:33:52 +00:00
|
|
|
nfsm_disct(struct mbuf **mdp, caddr_t *dposp, int siz, int left, int how)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
struct mbuf *mp, *mp2;
|
|
|
|
int siz2, xfer;
|
2005-07-14 20:08:27 +00:00
|
|
|
caddr_t ptr, npos = NULL;
|
2001-09-27 22:40:38 +00:00
|
|
|
void *ret;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
mp = *mdp;
|
|
|
|
while (left == 0) {
|
|
|
|
*mdp = mp = mp->m_next;
|
|
|
|
if (mp == NULL)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (NULL);
|
1994-05-24 10:09:53 +00:00
|
|
|
left = mp->m_len;
|
|
|
|
*dposp = mtod(mp, caddr_t);
|
|
|
|
}
|
|
|
|
if (left >= siz) {
|
2001-09-27 22:40:38 +00:00
|
|
|
ret = *dposp;
|
1994-05-24 10:09:53 +00:00
|
|
|
*dposp += siz;
|
|
|
|
} else if (mp->m_next == NULL) {
|
2010-02-09 23:40:07 +00:00
|
|
|
return (NULL);
|
1994-05-24 10:09:53 +00:00
|
|
|
} else if (siz > MHLEN) {
|
|
|
|
panic("nfs S too big");
|
|
|
|
} else {
|
2004-12-06 17:33:52 +00:00
|
|
|
MGET(mp2, how, MT_DATA);
|
|
|
|
if (mp2 == NULL)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (NULL);
|
2005-07-14 20:08:27 +00:00
|
|
|
mp2->m_len = siz;
|
1994-05-24 10:09:53 +00:00
|
|
|
mp2->m_next = mp->m_next;
|
|
|
|
mp->m_next = mp2;
|
|
|
|
mp->m_len -= left;
|
|
|
|
mp = mp2;
|
2001-09-27 22:40:38 +00:00
|
|
|
ptr = mtod(mp, caddr_t);
|
|
|
|
ret = ptr;
|
2001-09-12 08:38:13 +00:00
|
|
|
bcopy(*dposp, ptr, left); /* Copy what was left */
|
1994-05-24 10:09:53 +00:00
|
|
|
siz2 = siz-left;
|
2001-09-12 08:38:13 +00:00
|
|
|
ptr += left;
|
1994-05-24 10:09:53 +00:00
|
|
|
mp2 = mp->m_next;
|
2005-07-14 20:08:27 +00:00
|
|
|
npos = mtod(mp2, caddr_t);
|
1994-05-24 10:09:53 +00:00
|
|
|
/* Loop around copying up the siz2 bytes */
|
|
|
|
while (siz2 > 0) {
|
|
|
|
if (mp2 == NULL)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (NULL);
|
1994-05-24 10:09:53 +00:00
|
|
|
xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2;
|
|
|
|
if (xfer > 0) {
|
2001-09-12 08:38:13 +00:00
|
|
|
bcopy(mtod(mp2, caddr_t), ptr, xfer);
|
2001-09-28 04:37:08 +00:00
|
|
|
mp2->m_data += xfer;
|
1994-05-24 10:09:53 +00:00
|
|
|
mp2->m_len -= xfer;
|
2001-09-12 08:38:13 +00:00
|
|
|
ptr += xfer;
|
1994-05-24 10:09:53 +00:00
|
|
|
siz2 -= xfer;
|
|
|
|
}
|
2005-07-14 20:08:27 +00:00
|
|
|
if (siz2 > 0) {
|
1994-05-24 10:09:53 +00:00
|
|
|
mp2 = mp2->m_next;
|
2005-07-14 20:08:27 +00:00
|
|
|
if (mp2 != NULL)
|
|
|
|
npos = mtod(mp2, caddr_t);
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
*mdp = mp2;
|
|
|
|
*dposp = mtod(mp2, caddr_t);
|
2005-07-14 20:08:27 +00:00
|
|
|
if (!nfsm_aligned(*dposp, u_int32_t)) {
|
|
|
|
bcopy(*dposp, npos, mp2->m_len);
|
|
|
|
mp2->m_data = npos;
|
|
|
|
*dposp = npos;
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2010-02-09 23:40:07 +00:00
|
|
|
return (ret);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance the position in the mbuf chain.
|
|
|
|
*/
|
1994-05-25 09:21:21 +00:00
|
|
|
int
|
2001-09-18 23:32:09 +00:00
|
|
|
nfs_adv(struct mbuf **mdp, caddr_t *dposp, int offs, int left)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
struct mbuf *m;
|
|
|
|
int s;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
m = *mdp;
|
|
|
|
s = left;
|
|
|
|
while (s < offs) {
|
|
|
|
offs -= s;
|
|
|
|
m = m->m_next;
|
|
|
|
if (m == NULL)
|
|
|
|
return (EBADRPC);
|
|
|
|
s = m->m_len;
|
|
|
|
}
|
|
|
|
*mdp = m;
|
|
|
|
*dposp = mtod(m, caddr_t)+offs;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-09-27 02:33:36 +00:00
|
|
|
void *
|
|
|
|
nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos)
|
1995-06-27 11:07:30 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
struct mbuf *mb2;
|
2001-09-27 02:33:36 +00:00
|
|
|
void *ret;
|
1995-06-27 11:07:30 +00:00
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
if (s > M_TRAILINGSPACE(*mb)) {
|
2008-03-25 09:39:02 +00:00
|
|
|
MGET(mb2, M_WAIT, MT_DATA);
|
2001-09-18 23:32:09 +00:00
|
|
|
if (s > MLEN)
|
|
|
|
panic("build > MLEN");
|
|
|
|
(*mb)->m_next = mb2;
|
|
|
|
*mb = mb2;
|
|
|
|
(*mb)->m_len = 0;
|
|
|
|
*bpos = mtod(*mb, caddr_t);
|
|
|
|
}
|
2001-09-27 02:33:36 +00:00
|
|
|
ret = *bpos;
|
2001-09-18 23:32:09 +00:00
|
|
|
(*mb)->m_len += s;
|
|
|
|
*bpos += s;
|
2010-02-09 23:40:07 +00:00
|
|
|
return (ret);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
2001-09-27 22:40:38 +00:00
|
|
|
void *
|
|
|
|
nfsm_dissect_xx(int s, struct mbuf **md, caddr_t *dpos)
|
2004-12-06 17:33:52 +00:00
|
|
|
{
|
2010-02-09 23:40:07 +00:00
|
|
|
|
|
|
|
return (nfsm_dissect_xx_sub(s, md, dpos, M_WAIT));
|
2004-12-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
nfsm_dissect_xx_nonblock(int s, struct mbuf **md, caddr_t *dpos)
|
|
|
|
{
|
2010-02-09 23:40:07 +00:00
|
|
|
|
|
|
|
return (nfsm_dissect_xx_sub(s, md, dpos, M_DONTWAIT));
|
2004-12-06 17:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *
|
|
|
|
nfsm_dissect_xx_sub(int s, struct mbuf **md, caddr_t *dpos, int how)
|
1995-06-27 11:07:30 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
int t1;
|
|
|
|
char *cp2;
|
2001-09-27 22:40:38 +00:00
|
|
|
void *ret;
|
2001-09-18 23:32:09 +00:00
|
|
|
|
|
|
|
t1 = mtod(*md, caddr_t) + (*md)->m_len - *dpos;
|
|
|
|
if (t1 >= s) {
|
2001-09-27 22:40:38 +00:00
|
|
|
ret = *dpos;
|
2001-09-18 23:32:09 +00:00
|
|
|
*dpos += s;
|
2010-02-09 23:40:07 +00:00
|
|
|
return (ret);
|
2001-09-18 23:32:09 +00:00
|
|
|
}
|
2010-02-09 23:40:07 +00:00
|
|
|
cp2 = nfsm_disct(md, dpos, s, t1, how);
|
|
|
|
return (cp2);
|
1995-06-27 11:07:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-12-18 01:22:09 +00:00
|
|
|
nfsm_strsiz_xx(int *s, int m, struct mbuf **mb, caddr_t *bpos)
|
1995-06-27 11:07:30 +00:00
|
|
|
{
|
2001-12-18 01:22:09 +00:00
|
|
|
u_int32_t *tl;
|
2001-09-18 23:32:09 +00:00
|
|
|
|
2001-12-18 01:22:09 +00:00
|
|
|
tl = nfsm_dissect_xx(NFSX_UNSIGNED, mb, bpos);
|
|
|
|
if (tl == NULL)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (EBADRPC);
|
2001-12-18 01:22:09 +00:00
|
|
|
*s = fxdr_unsigned(int32_t, *tl);
|
2001-09-18 23:32:09 +00:00
|
|
|
if (*s > m)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (EBADRPC);
|
|
|
|
return (0);
|
1995-06-27 11:07:30 +00:00
|
|
|
}
|
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int
|
2001-12-18 01:22:09 +00:00
|
|
|
nfsm_adv_xx(int s, struct mbuf **md, caddr_t *dpos)
|
1997-12-20 00:25:01 +00:00
|
|
|
{
|
2001-09-18 23:32:09 +00:00
|
|
|
int t1;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
2001-09-18 23:32:09 +00:00
|
|
|
t1 = mtod(*md, caddr_t) + (*md)->m_len - *dpos;
|
2001-12-31 06:56:31 +00:00
|
|
|
if (t1 >= s) {
|
2001-09-18 23:32:09 +00:00
|
|
|
*dpos += s;
|
2010-02-09 23:40:07 +00:00
|
|
|
return (0);
|
1998-05-31 17:27:58 +00:00
|
|
|
}
|
2001-09-18 23:32:09 +00:00
|
|
|
t1 = nfs_adv(md, dpos, s, t1);
|
|
|
|
if (t1)
|
2010-02-09 23:40:07 +00:00
|
|
|
return (t1);
|
|
|
|
return (0);
|
1998-05-31 17:27:58 +00:00
|
|
|
}
|
2010-02-09 23:45:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for badly aligned mbuf data and realign by copying the unaligned
|
|
|
|
* portion of the data into a new mbuf chain and freeing the portions of the
|
|
|
|
* old chain that were replaced.
|
|
|
|
*
|
|
|
|
* We cannot simply realign the data within the existing mbuf chain because
|
|
|
|
* the underlying buffers may contain other rpc commands and we cannot afford
|
|
|
|
* to overwrite them.
|
|
|
|
*
|
|
|
|
* We would prefer to avoid this situation entirely. The situation does not
|
|
|
|
* occur with NFS/UDP and is supposed to only occassionally occur with TCP.
|
2011-05-15 20:52:43 +00:00
|
|
|
* Use vfs.nfs_common.realign_count and realign_test to check this.
|
2010-02-09 23:45:14 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
nfs_realign(struct mbuf **pm, int how)
|
|
|
|
{
|
|
|
|
struct mbuf *m, *n;
|
|
|
|
int off;
|
|
|
|
|
|
|
|
++nfs_realign_test;
|
|
|
|
while ((m = *pm) != NULL) {
|
|
|
|
if (!nfsm_aligned(m->m_len, u_int32_t) ||
|
|
|
|
!nfsm_aligned(mtod(m, intptr_t), u_int32_t)) {
|
|
|
|
/*
|
|
|
|
* NB: we can't depend on m_pkthdr.len to help us
|
|
|
|
* decide what to do here. May not be worth doing
|
|
|
|
* the m_length calculation as m_copyback will
|
|
|
|
* expand the mbuf chain below as needed.
|
|
|
|
*/
|
|
|
|
if (m_length(m, NULL) >= MINCLSIZE) {
|
|
|
|
/* NB: m_copyback handles space > MCLBYTES */
|
|
|
|
n = m_getcl(how, MT_DATA, 0);
|
|
|
|
} else
|
|
|
|
n = m_get(how, MT_DATA);
|
|
|
|
if (n == NULL)
|
|
|
|
return (ENOMEM);
|
|
|
|
/*
|
|
|
|
* Align the remainder of the mbuf chain.
|
|
|
|
*/
|
|
|
|
n->m_len = 0;
|
|
|
|
off = 0;
|
|
|
|
while (m != NULL) {
|
|
|
|
m_copyback(n, off, m->m_len, mtod(m, caddr_t));
|
|
|
|
off += m->m_len;
|
|
|
|
m = m->m_next;
|
|
|
|
}
|
|
|
|
m_freem(*pm);
|
|
|
|
*pm = n;
|
|
|
|
++nfs_realign_count;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pm = &m->m_next;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
2010-02-16 20:00:21 +00:00
|
|
|
|
|
|
|
static moduledata_t nfs_common_mod = {
|
|
|
|
"nfs_common",
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
DECLARE_MODULE(nfs_common, nfs_common_mod, SI_SUB_VFS, SI_ORDER_ANY);
|
|
|
|
MODULE_VERSION(nfs_common, 1);
|