[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree
zrouter-src-freebsd at zrouter.org
zrouter-src-freebsd at zrouter.org
Wed Feb 1 10:56:27 UTC 2012
details: http://zrouter.org/hg/FreeBSD/head//rev/48da769ef822
changeset: 306:48da769ef822
user: ray at terran.dlink.ua
date: Wed Feb 01 11:31:17 2012 +0200
description:
Update sys/fs
diffstat:
head/sys/fs/cd9660/cd9660_vfsops.c | 4 +-
head/sys/fs/fdescfs/fdesc_vfsops.c | 4 +-
head/sys/fs/hpfs/hpfs_vfsops.c | 4 +-
head/sys/fs/msdosfs/msdosfs_vfsops.c | 4 +-
head/sys/fs/nfs/nfs_commonkrpc.c | 51 ++++++++-----
head/sys/fs/nfsclient/nfs_clbio.c | 16 +--
head/sys/fs/nfsclient/nfs_clnode.c | 3 +-
head/sys/fs/nfsclient/nfs_clport.c | 3 +-
head/sys/fs/nfsclient/nfs_clrpcops.c | 7 +-
head/sys/fs/nfsclient/nfs_clvfsops.c | 46 +++++++++--
head/sys/fs/nfsclient/nfs_clvnops.c | 130 ++++++++++++++++------------------
head/sys/fs/nfsclient/nfsmount.h | 7 +-
head/sys/fs/nfsclient/nfsnode.h | 5 +-
head/sys/fs/ntfs/ntfs_vfsops.c | 4 +-
head/sys/fs/nullfs/null_subr.c | 4 +-
head/sys/fs/nwfs/nwfs_vfsops.c | 4 +-
head/sys/fs/portalfs/portal_vfsops.c | 4 +-
head/sys/fs/pseudofs/pseudofs.c | 4 +-
head/sys/fs/pseudofs/pseudofs.h | 4 +-
head/sys/fs/smbfs/smbfs_vfsops.c | 4 +-
head/sys/fs/tmpfs/tmpfs_vfsops.c | 6 +-
21 files changed, 176 insertions(+), 142 deletions(-)
diffs (919 lines):
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/cd9660/cd9660_vfsops.c
--- a/head/sys/fs/cd9660/cd9660_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/cd9660/cd9660_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/cd9660/cd9660_vfsops.c 222167 2011-05-22 01:07:54Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/cd9660/cd9660_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -95,7 +95,7 @@
*/
static int
-cd9660_cmount(struct mntarg *ma, void *data, int flags)
+cd9660_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
struct iso_args args;
struct export_args exp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/fdescfs/fdesc_vfsops.c
--- a/head/sys/fs/fdescfs/fdesc_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/fdescfs/fdesc_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -31,7 +31,7 @@
*
* @(#)fdesc_vfsops.c 8.4 (Berkeley) 1/21/94
*
- * $FreeBSD: head/sys/fs/fdescfs/fdesc_vfsops.c 220400 2011-04-06 19:13:04Z trasz $
+ * $FreeBSD: head/sys/fs/fdescfs/fdesc_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
/*
@@ -65,7 +65,7 @@
* Compatibility shim for old mount(2) system call.
*/
int
-fdesc_cmount(struct mntarg *ma, void *data, int flags)
+fdesc_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
return kernel_mount(ma, flags);
}
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/hpfs/hpfs_vfsops.c
--- a/head/sys/fs/hpfs/hpfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/hpfs/hpfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/hpfs/hpfs_vfsops.c 222167 2011-05-22 01:07:54Z rmacklem $
+ * $FreeBSD: head/sys/fs/hpfs/hpfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
@@ -73,7 +73,7 @@
hpfs_cmount (
struct mntarg *ma,
void *data,
- int flags)
+ uint64_t flags)
{
struct hpfs_args args;
struct export_args exp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/msdosfs/msdosfs_vfsops.c
--- a/head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/msdosfs/msdosfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_vfsops.c 227817 2011-11-22 13:30:36Z kib $ */
+/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $ */
/* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */
/*-
@@ -197,7 +197,7 @@
}
static int
-msdosfs_cmount(struct mntarg *ma, void *data, int flags)
+msdosfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
struct msdosfs_args args;
struct export_args exp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfs/nfs_commonkrpc.c
--- a/head/sys/fs/nfs/nfs_commonkrpc.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfs/nfs_commonkrpc.c Wed Feb 01 11:31:17 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonkrpc.c 229802 2012-01-08 01:54:46Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonkrpc.c 230345 2012-01-20 00:58:51Z rmacklem $");
/*
* Socket operations for use by nfs
@@ -472,7 +472,7 @@
{
u_int32_t *tl;
time_t waituntil;
- int i, j, set_uid = 0, set_sigset = 0, timeo;
+ int i, j, set_sigset = 0, timeo;
int trycnt, error = 0, usegssname = 0, secflavour = AUTH_SYS;
u_int16_t procnum;
u_int trylater_delay = 1;
@@ -483,8 +483,8 @@
enum clnt_stat stat;
struct nfsreq *rep = NULL;
char *srv_principal = NULL;
- uid_t saved_uid = (uid_t)-1;
sigset_t oldset;
+ struct ucred *authcred;
if (xidp != NULL)
*xidp = 0;
@@ -494,6 +494,14 @@
return (ESTALE);
}
+ /*
+ * Set authcred, which is used to acquire RPC credentials to
+ * the cred argument, by default. The crhold() should not be
+ * necessary, but will ensure that some future code change
+ * doesn't result in the credential being free'd prematurely.
+ */
+ authcred = crhold(cred);
+
/* For client side interruptible mounts, mask off the signals. */
if (nmp != NULL && td != NULL && NFSHASINT(nmp)) {
newnfs_set_sigmask(td, &oldset);
@@ -532,13 +540,16 @@
/*
* If there is a client side host based credential,
* use that, otherwise use the system uid, if set.
+ * The system uid is in the nmp->nm_sockreq.nr_cred
+ * credentials.
*/
if (nmp->nm_krbnamelen > 0) {
usegssname = 1;
} else if (nmp->nm_uid != (uid_t)-1) {
- saved_uid = cred->cr_uid;
- cred->cr_uid = nmp->nm_uid;
- set_uid = 1;
+ KASSERT(nmp->nm_sockreq.nr_cred != NULL,
+ ("newnfs_request: NULL nr_cred"));
+ crfree(authcred);
+ authcred = crhold(nmp->nm_sockreq.nr_cred);
}
} else if (nmp->nm_krbnamelen == 0 &&
nmp->nm_uid != (uid_t)-1 && cred->cr_uid == (uid_t)0) {
@@ -547,10 +558,13 @@
* the system uid is set and this is root, use the
* system uid, since root won't have user
* credentials in a credentials cache file.
+ * The system uid is in the nmp->nm_sockreq.nr_cred
+ * credentials.
*/
- saved_uid = cred->cr_uid;
- cred->cr_uid = nmp->nm_uid;
- set_uid = 1;
+ KASSERT(nmp->nm_sockreq.nr_cred != NULL,
+ ("newnfs_request: NULL nr_cred"));
+ crfree(authcred);
+ authcred = crhold(nmp->nm_sockreq.nr_cred);
}
if (NFSHASINTEGRITY(nmp))
secflavour = RPCSEC_GSS_KRB5I;
@@ -566,13 +580,13 @@
* Use the uid that did the mount when the RPC is doing
* NFSv4 system operations, as indicated by the
* ND_USEGSSNAME flag, for the AUTH_SYS case.
+ * The credentials in nm_sockreq.nr_cred were used for the
+ * mount.
*/
- saved_uid = cred->cr_uid;
- if (nmp->nm_uid != (uid_t)-1)
- cred->cr_uid = nmp->nm_uid;
- else
- cred->cr_uid = 0;
- set_uid = 1;
+ KASSERT(nmp->nm_sockreq.nr_cred != NULL,
+ ("newnfs_request: NULL nr_cred"));
+ crfree(authcred);
+ authcred = crhold(nmp->nm_sockreq.nr_cred);
}
if (nmp != NULL) {
@@ -588,12 +602,11 @@
auth = authnone_create();
else if (usegssname)
auth = nfs_getauth(nrp, secflavour, nmp->nm_krbname,
- srv_principal, NULL, cred);
+ srv_principal, NULL, authcred);
else
auth = nfs_getauth(nrp, secflavour, NULL,
- srv_principal, NULL, cred);
- if (set_uid)
- cred->cr_uid = saved_uid;
+ srv_principal, NULL, authcred);
+ crfree(authcred);
if (auth == NULL) {
m_freem(nd->nd_mreq);
if (set_sigset)
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clbio.c
--- a/head/sys/fs/nfsclient/nfs_clbio.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clbio.c Wed Feb 01 11:31:17 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 228156 2011-11-30 17:39:00Z kib $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 230605 2012-01-27 02:46:12Z rmacklem $");
#include "opt_kdtrace.h"
@@ -480,7 +480,7 @@
/* No caching/ no readaheads. Just read data into the user buffer */
return ncl_readrpc(vp, uio, cred);
- biosize = vp->v_mount->mnt_stat.f_iosize;
+ biosize = vp->v_bufobj.bo_bsize;
seqcount = (int)((off_t)(ioflag >> IO_SEQSHIFT) * biosize / BKVASIZE);
error = nfs_bioread_check_cons(vp, td, cred);
@@ -960,7 +960,7 @@
if (vn_rlimit_fsize(vp, uio, td))
return (EFBIG);
- biosize = vp->v_mount->mnt_stat.f_iosize;
+ biosize = vp->v_bufobj.bo_bsize;
/*
* Find all of this file's B_NEEDCOMMIT buffers. If our writes
* would exceed the local maximum per-file write commit size when
@@ -1264,12 +1264,8 @@
bp = getblk(vp, bn, size, 0, 0, 0);
}
- if (vp->v_type == VREG) {
- int biosize;
-
- biosize = mp->mnt_stat.f_iosize;
- bp->b_blkno = bn * (biosize / DEV_BSIZE);
- }
+ if (vp->v_type == VREG)
+ bp->b_blkno = bn * (vp->v_bufobj.bo_bsize / DEV_BSIZE);
return (bp);
}
@@ -1785,7 +1781,7 @@
{
struct nfsnode *np = VTONFS(vp);
u_quad_t tsize;
- int biosize = vp->v_mount->mnt_stat.f_iosize;
+ int biosize = vp->v_bufobj.bo_bsize;
int error = 0;
mtx_lock(&np->n_mtx);
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clnode.c
--- a/head/sys/fs/nfsclient/nfs_clnode.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clnode.c Wed Feb 01 11:31:17 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clnode.c 224606 2011-08-02 11:28:42Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clnode.c 230605 2012-01-27 02:46:12Z rmacklem $");
#include "opt_kdtrace.h"
@@ -136,6 +136,7 @@
return (error);
}
vp = nvp;
+ KASSERT(vp->v_bufobj.bo_bsize != 0, ("ncl_nget: bo_bsize == 0"));
vp->v_bufobj.bo_ops = &buf_ops_newnfs;
vp->v_data = np;
np->n_vnode = vp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clport.c
--- a/head/sys/fs/nfsclient/nfs_clport.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clport.c Wed Feb 01 11:31:17 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 229802 2012-01-08 01:54:46Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 230605 2012-01-27 02:46:12Z rmacklem $");
#include "opt_inet6.h"
#include "opt_kdtrace.h"
@@ -212,6 +212,7 @@
return (error);
}
vp = nvp;
+ KASSERT(vp->v_bufobj.bo_bsize != 0, ("nfscl_nget: bo_bsize == 0"));
vp->v_bufobj.bo_ops = &buf_ops_newnfs;
vp->v_data = np;
np->n_vnode = vp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clrpcops.c
--- a/head/sys/fs/nfsclient/nfs_clrpcops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clrpcops.c Wed Feb 01 11:31:17 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clrpcops.c 229802 2012-01-08 01:54:46Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clrpcops.c 230394 2012-01-20 20:02:01Z jhb $");
/*
* Rpc op calls, generally called from the vnode op calls or through the
@@ -3317,8 +3317,9 @@
ndp->ni_vp = newvp;
NFSCNHASH(cnp, HASHINIT);
if (cnp->cn_namelen <= NCHNAMLEN) {
- np->n_ctime = np->n_vattr.na_ctime;
- cache_enter(ndp->ni_dvp,ndp->ni_vp,cnp);
+ cache_enter_time(ndp->ni_dvp,
+ ndp->ni_vp, cnp,
+ &nfsva.na_ctime);
}
if (unlocknewvp)
vput(newvp);
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clvfsops.c
--- a/head/sys/fs/nfsclient/nfs_clvfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clvfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvfsops.c 227517 2011-11-15 01:39:02Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvfsops.c 230803 2012-01-31 03:58:26Z rmacklem $");
#include "opt_bootp.h"
@@ -104,7 +104,7 @@
static int mountnfs(struct nfs_args *, struct mount *,
struct sockaddr *, char *, u_char *, int, u_char *, int,
u_char *, int, struct vnode **, struct ucred *,
- struct thread *, int);
+ struct thread *, int, int);
static void nfs_getnlminfo(struct vnode *, uint8_t *, size_t *,
struct sockaddr_storage *, int *, off_t *,
struct timeval *);
@@ -520,7 +520,8 @@
dirlen = 0;
nam = sodupsockaddr((struct sockaddr *)sin, M_WAITOK);
if ((error = mountnfs(args, mp, nam, path, NULL, 0, dirpath, dirlen,
- NULL, 0, vpp, td->td_ucred, td, NFS_DEFAULT_NEGNAMETIMEO)) != 0) {
+ NULL, 0, vpp, td->td_ucred, td, NFS_DEFAULT_NAMETIMEO,
+ NFS_DEFAULT_NEGNAMETIMEO)) != 0) {
printf("nfs_mountroot: mount %s on /: %d\n", path, error);
return (error);
}
@@ -715,7 +716,7 @@
"retrans", "acregmin", "acregmax", "acdirmin", "acdirmax", "resvport",
"readahead", "hostname", "timeout", "addr", "fh", "nfsv3", "sec",
"principal", "nfsv4", "gssname", "allgssname", "dirpath",
- "negnametimeo", "nocto", "wcommitsize",
+ "nametimeo", "negnametimeo", "nocto", "wcommitsize",
NULL };
/*
@@ -760,6 +761,7 @@
char hst[MNAMELEN];
u_char nfh[NFSX_FHMAX], krbname[100], dirpath[100], srvkrbname[100];
char *opt, *name, *secname;
+ int nametimeo = NFS_DEFAULT_NAMETIMEO;
int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO;
int dirlen, has_nfs_args_opt, krbnamelen, srvkrbnamelen;
size_t hstlen;
@@ -968,6 +970,14 @@
}
args.flags |= NFSMNT_TIMEO;
}
+ if (vfs_getopt(mp->mnt_optnew, "nametimeo", (void **)&opt, NULL) == 0) {
+ ret = sscanf(opt, "%d", &nametimeo);
+ if (ret != 1 || nametimeo < 0) {
+ vfs_mount_error(mp, "illegal nametimeo: %s", opt);
+ error = EINVAL;
+ goto out;
+ }
+ }
if (vfs_getopt(mp->mnt_optnew, "negnametimeo", (void **)&opt, NULL)
== 0) {
ret = sscanf(opt, "%d", &negnametimeo);
@@ -989,6 +999,19 @@
error = EIO;
goto out;
}
+
+ /*
+ * If a change from TCP->UDP is done and there are thread(s)
+ * that have I/O RPC(s) in progress with a tranfer size
+ * greater than NFS_MAXDGRAMDATA, those thread(s) will be
+ * hung, retrying the RPC(s) forever. Usually these threads
+ * will be seen doing an uninterruptible sleep on wait channel
+ * "newnfsreq" (truncated to "newnfsre" by procstat).
+ */
+ if (args.sotype == SOCK_DGRAM && nmp->nm_sotype == SOCK_STREAM)
+ tprintf(td->td_proc, LOG_WARNING,
+ "Warning: mount -u that changes TCP->UDP can result in hung threads\n");
+
/*
* When doing an update, we can't change version,
* security, switch lockd strategies or change cookie
@@ -1109,7 +1132,7 @@
args.fh = nfh;
error = mountnfs(&args, mp, nam, hst, krbname, krbnamelen, dirpath,
dirlen, srvkrbname, srvkrbnamelen, &vp, td->td_ucred, td,
- negnametimeo);
+ nametimeo, negnametimeo);
out:
if (!error) {
MNT_ILOCK(mp);
@@ -1131,7 +1154,7 @@
*/
/* ARGSUSED */
static int
-nfs_cmount(struct mntarg *ma, void *data, int flags)
+nfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
int error;
struct nfs_args args;
@@ -1153,7 +1176,7 @@
mountnfs(struct nfs_args *argp, struct mount *mp, struct sockaddr *nam,
char *hst, u_char *krbname, int krbnamelen, u_char *dirpath, int dirlen,
u_char *srvkrbname, int srvkrbnamelen, struct vnode **vpp,
- struct ucred *cred, struct thread *td, int negnametimeo)
+ struct ucred *cred, struct thread *td, int nametimeo, int negnametimeo)
{
struct nfsmount *nmp;
struct nfsnode *np;
@@ -1220,13 +1243,14 @@
}
vfs_getnewfsid(mp);
nmp->nm_mountp = mp;
- mtx_init(&nmp->nm_mtx, "NFSmount lock", NULL, MTX_DEF | MTX_DUPOK);
+ mtx_init(&nmp->nm_mtx, "NFSmount lock", NULL, MTX_DEF | MTX_DUPOK);
/*
- * Since nfs_decode_args() might optionally set them, these need to
- * set to defaults before the call, so that the optional settings
- * aren't overwritten.
+ * Since nfs_decode_args() might optionally set them, these
+ * need to be set to defaults before the call, so that the
+ * optional settings aren't overwritten.
*/
+ nmp->nm_nametimeo = nametimeo;
nmp->nm_negnametimeo = negnametimeo;
nmp->nm_timeo = NFS_TIMEO;
nmp->nm_retry = NFS_RETRANS;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfs_clvnops.c
--- a/head/sys/fs/nfsclient/nfs_clvnops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clvnops.c Wed Feb 01 11:31:17 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvnops.c 227543 2011-11-15 23:35:43Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvnops.c 230552 2012-01-25 20:48:20Z kib $");
/*
* vnode op calls for Sun NFS version 2, 3 and 4
@@ -1016,12 +1016,12 @@
struct vnode *newvp;
struct nfsmount *nmp;
struct nfsnode *np, *newnp;
- int error = 0, attrflag, dattrflag, ltype;
+ int error = 0, attrflag, dattrflag, ltype, ncticks;
struct thread *td = cnp->cn_thread;
struct nfsfh *nfhp;
struct nfsvattr dnfsva, nfsva;
struct vattr vattr;
- struct timespec dmtime;
+ struct timespec nctime;
*vpp = NULLVP;
if ((flags & ISLASTCN) && (mp->mnt_flag & MNT_RDONLY) &&
@@ -1042,15 +1042,29 @@
if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0)
return (error);
- error = cache_lookup(dvp, vpp, cnp);
+ error = cache_lookup_times(dvp, vpp, cnp, &nctime, &ncticks);
if (error > 0 && error != ENOENT)
return (error);
if (error == -1) {
/*
+ * Lookups of "." are special and always return the
+ * current directory. cache_lookup() already handles
+ * associated locking bookkeeping, etc.
+ */
+ if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
+ /* XXX: Is this really correct? */
+ if (cnp->cn_nameiop != LOOKUP &&
+ (flags & ISLASTCN))
+ cnp->cn_flags |= SAVENAME;
+ return (0);
+ }
+
+ /*
* We only accept a positive hit in the cache if the
* change time of the file matches our cached copy.
* Otherwise, we discard the cache entry and fallback
- * to doing a lookup RPC.
+ * to doing a lookup RPC. We also only trust cache
+ * entries for less than nm_nametimeo seconds.
*
* To better handle stale file handles and attributes,
* clear the attribute cache of this node if it is a
@@ -1072,8 +1086,9 @@
mtx_unlock(&newnp->n_mtx);
}
if (nfscl_nodeleg(newvp, 0) == 0 ||
- (VOP_GETATTR(newvp, &vattr, cnp->cn_cred) == 0 &&
- timespeccmp(&vattr.va_ctime, &newnp->n_ctime, ==))) {
+ ((u_int)(ticks - ncticks) < (nmp->nm_nametimeo * hz) &&
+ VOP_GETATTR(newvp, &vattr, cnp->cn_cred) == 0 &&
+ timespeccmp(&vattr.va_ctime, &nctime, ==))) {
NFSINCRGLOBAL(newnfsstats.lookupcache_hits);
if (cnp->cn_nameiop != LOOKUP &&
(flags & ISLASTCN))
@@ -1092,36 +1107,21 @@
/*
* We only accept a negative hit in the cache if the
* modification time of the parent directory matches
- * our cached copy. Otherwise, we discard all of the
- * negative cache entries for this directory. We also
- * only trust -ve cache entries for less than
- * nm_negative_namecache_timeout seconds.
+ * the cached copy in the name cache entry.
+ * Otherwise, we discard all of the negative cache
+ * entries for this directory. We also only trust
+ * negative cache entries for up to nm_negnametimeo
+ * seconds.
*/
- if ((u_int)(ticks - np->n_dmtime_ticks) <
- (nmp->nm_negnametimeo * hz) &&
+ if ((u_int)(ticks - ncticks) < (nmp->nm_negnametimeo * hz) &&
VOP_GETATTR(dvp, &vattr, cnp->cn_cred) == 0 &&
- timespeccmp(&vattr.va_mtime, &np->n_dmtime, ==)) {
+ timespeccmp(&vattr.va_mtime, &nctime, ==)) {
NFSINCRGLOBAL(newnfsstats.lookupcache_hits);
return (ENOENT);
}
cache_purge_negative(dvp);
- mtx_lock(&np->n_mtx);
- timespecclear(&np->n_dmtime);
- mtx_unlock(&np->n_mtx);
}
- /*
- * Cache the modification time of the parent directory in case
- * the lookup fails and results in adding the first negative
- * name cache entry for the directory. Since this is reading
- * a single time_t, don't bother with locking. The
- * modification time may be a bit stale, but it must be read
- * before performing the lookup RPC to prevent a race where
- * another lookup updates the timestamp on the directory after
- * the lookup RPC has been performed on the server but before
- * n_dmtime is set at the end of this function.
- */
- dmtime = np->n_vattr.na_mtime;
error = 0;
newvp = NULLVP;
NFSINCRGLOBAL(newnfsstats.lookupcache_misses);
@@ -1157,30 +1157,22 @@
return (EJUSTRETURN);
}
- if ((cnp->cn_flags & MAKEENTRY) && cnp->cn_nameiop != CREATE) {
+ if ((cnp->cn_flags & MAKEENTRY) && cnp->cn_nameiop != CREATE &&
+ dattrflag) {
/*
- * Maintain n_dmtime as the modification time
- * of the parent directory when the oldest -ve
- * name cache entry for this directory was
- * added. If a -ve cache entry has already
- * been added with a newer modification time
- * by a concurrent lookup, then don't bother
- * adding a cache entry. The modification
- * time of the directory might have changed
- * due to the file this lookup failed to find
- * being created. In that case a subsequent
- * lookup would incorrectly use the entry
- * added here instead of doing an extra
- * lookup.
+ * Cache the modification time of the parent
+ * directory from the post-op attributes in
+ * the name cache entry. The negative cache
+ * entry will be ignored once the directory
+ * has changed. Don't bother adding the entry
+ * if the directory has already changed.
*/
mtx_lock(&np->n_mtx);
- if (timespeccmp(&np->n_dmtime, &dmtime, <=)) {
- if (!timespecisset(&np->n_dmtime)) {
- np->n_dmtime = dmtime;
- np->n_dmtime_ticks = ticks;
- }
+ if (timespeccmp(&np->n_vattr.na_mtime,
+ &dnfsva.na_mtime, ==)) {
mtx_unlock(&np->n_mtx);
- cache_enter(dvp, NULL, cnp);
+ cache_enter_time(dvp, NULL, cnp,
+ &dnfsva.na_mtime);
} else
mtx_unlock(&np->n_mtx);
}
@@ -1279,9 +1271,8 @@
if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
cnp->cn_flags |= SAVENAME;
if ((cnp->cn_flags & MAKEENTRY) &&
- (cnp->cn_nameiop != DELETE || !(flags & ISLASTCN))) {
- np->n_ctime = np->n_vattr.na_vattr.va_ctime;
- cache_enter(dvp, newvp, cnp);
+ (cnp->cn_nameiop != DELETE || !(flags & ISLASTCN)) && attrflag) {
+ cache_enter_time(dvp, newvp, cnp, &nfsva.na_ctime);
}
*vpp = newvp;
return (0);
@@ -1442,8 +1433,6 @@
}
}
if (!error) {
- if ((cnp->cn_flags & MAKEENTRY))
- cache_enter(dvp, newvp, cnp);
*vpp = newvp;
} else if (NFS_ISV4(dvp)) {
error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid,
@@ -1601,8 +1590,8 @@
}
}
if (!error) {
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(dvp, newvp, cnp);
+ if ((cnp->cn_flags & MAKEENTRY) && attrflag)
+ cache_enter_time(dvp, newvp, cnp, &nfsva.na_ctime);
*ap->a_vpp = newvp;
} else if (NFS_ISV4(dvp)) {
error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid,
@@ -1977,8 +1966,9 @@
* must care about lookup caching hit rate, so...
*/
if (VFSTONFS(vp->v_mount)->nm_negnametimeo != 0 &&
- (cnp->cn_flags & MAKEENTRY))
- cache_enter(tdvp, vp, cnp);
+ (cnp->cn_flags & MAKEENTRY) && dattrflag) {
+ cache_enter_time(tdvp, vp, cnp, &dnfsva.na_mtime);
+ }
if (error && NFS_ISV4(vp))
error = nfscl_maperr(cnp->cn_thread, error, (uid_t)0,
(gid_t)0);
@@ -2034,15 +2024,6 @@
error = nfscl_maperr(cnp->cn_thread, error,
vap->va_uid, vap->va_gid);
} else {
- /*
- * If negative lookup caching is enabled, I might as well
- * add an entry for this node. Not necessary for correctness,
- * but if negative caching is enabled, then the system
- * must care about lookup caching hit rate, so...
- */
- if (VFSTONFS(dvp->v_mount)->nm_negnametimeo != 0 &&
- (cnp->cn_flags & MAKEENTRY))
- cache_enter(dvp, newvp, cnp);
*ap->a_vpp = newvp;
}
@@ -2052,6 +2033,16 @@
if (dattrflag != 0) {
mtx_unlock(&dnp->n_mtx);
(void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1);
+ /*
+ * If negative lookup caching is enabled, I might as well
+ * add an entry for this node. Not necessary for correctness,
+ * but if negative caching is enabled, then the system
+ * must care about lookup caching hit rate, so...
+ */
+ if (VFSTONFS(dvp->v_mount)->nm_negnametimeo != 0 &&
+ (cnp->cn_flags & MAKEENTRY)) {
+ cache_enter_time(dvp, newvp, cnp, &dnfsva.na_mtime);
+ }
} else {
dnp->n_attrstamp = 0;
mtx_unlock(&dnp->n_mtx);
@@ -2127,8 +2118,9 @@
* must care about lookup caching hit rate, so...
*/
if (VFSTONFS(dvp->v_mount)->nm_negnametimeo != 0 &&
- (cnp->cn_flags & MAKEENTRY))
- cache_enter(dvp, newvp, cnp);
+ (cnp->cn_flags & MAKEENTRY) && dattrflag) {
+ cache_enter_time(dvp, newvp, cnp, &dnfsva.na_mtime);
+ }
*ap->a_vpp = newvp;
}
return (error);
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfsmount.h
--- a/head/sys/fs/nfsclient/nfsmount.h Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfsmount.h Wed Feb 01 11:31:17 2012 +0200
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: head/sys/fs/nfsclient/nfsmount.h 230547 2012-01-25 20:05:58Z jhb $
*/
#ifndef _NFSCLIENT_NFSMOUNT_H_
@@ -66,6 +66,7 @@
u_int64_t nm_maxfilesize; /* maximum file size */
int nm_tprintf_initial_delay; /* initial delay */
int nm_tprintf_delay; /* interval for messages */
+ int nm_nametimeo; /* timeout for +ve entries (sec) */
int nm_negnametimeo; /* timeout for -ve entries (sec) */
/* Newnfs additions */
@@ -106,6 +107,10 @@
*/
#define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data))
+#ifndef NFS_DEFAULT_NAMETIMEO
+#define NFS_DEFAULT_NAMETIMEO 60
+#endif
+
#ifndef NFS_DEFAULT_NEGNAMETIMEO
#define NFS_DEFAULT_NEGNAMETIMEO 60
#endif
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nfsclient/nfsnode.h
--- a/head/sys/fs/nfsclient/nfsnode.h Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nfsclient/nfsnode.h Wed Feb 01 11:31:17 2012 +0200
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/nfsclient/nfsnode.h 224606 2011-08-02 11:28:42Z rmacklem $
+ * $FreeBSD: head/sys/fs/nfsclient/nfsnode.h 230394 2012-01-20 20:02:01Z jhb $
*/
#ifndef _NFSCLIENT_NFSNODE_H_
@@ -99,9 +99,6 @@
time_t n_attrstamp; /* Attr. cache timestamp */
struct nfs_accesscache n_accesscache[NFS_ACCESSCACHESIZE];
struct timespec n_mtime; /* Prev modify time. */
- struct timespec n_ctime; /* Prev create time. */
- struct timespec n_dmtime; /* Prev dir modify time. */
- int n_dmtime_ticks; /* Tick of -ve cache entry */
struct nfsfh *n_fhp; /* NFS File Handle */
struct vnode *n_vnode; /* associated vnode */
struct vnode *n_dvp; /* parent vnode */
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/ntfs/ntfs_vfsops.c
--- a/head/sys/fs/ntfs/ntfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/ntfs/ntfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/ntfs/ntfs_vfsops.c 222167 2011-05-22 01:07:54Z rmacklem $
+ * $FreeBSD: head/sys/fs/ntfs/ntfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
@@ -117,7 +117,7 @@
ntfs_cmount (
struct mntarg *ma,
void *data,
- int flags)
+ uint64_t flags)
{
struct ntfs_args args;
struct export_args exp;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nullfs/null_subr.c
--- a/head/sys/fs/nullfs/null_subr.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nullfs/null_subr.c Wed Feb 01 11:31:17 2012 +0200
@@ -31,7 +31,7 @@
*
* @(#)null_subr.c 8.7 (Berkeley) 5/14/95
*
- * $FreeBSD: head/sys/fs/nullfs/null_subr.c 229600 2012-01-05 17:06:04Z dim $
+ * $FreeBSD: head/sys/fs/nullfs/null_subr.c 230304 2012-01-18 11:23:46Z rea $
*/
#include <sys/param.h>
@@ -90,7 +90,7 @@
{
mtx_destroy(&null_hashmtx);
- free(null_node_hashtbl, M_NULLFSHASH);
+ hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_node_hash);
return (0);
}
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/nwfs/nwfs_vfsops.c
--- a/head/sys/fs/nwfs/nwfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/nwfs/nwfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/nwfs/nwfs_vfsops.c 229272 2012-01-02 12:12:10Z ed $
+ * $FreeBSD: head/sys/fs/nwfs/nwfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
#include <sys/param.h>
@@ -123,7 +123,7 @@
return 0;
}
-static int nwfs_cmount(struct mntarg *ma, void *data, int flags)
+static int nwfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
struct nwfs_args args; /* will hold data from mount request */
int error;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/portalfs/portal_vfsops.c
--- a/head/sys/fs/portalfs/portal_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/portalfs/portal_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -31,7 +31,7 @@
*
* @(#)portal_vfsops.c 8.11 (Berkeley) 5/14/95
*
- * $FreeBSD: head/sys/fs/portalfs/portal_vfsops.c 224778 2011-08-11 12:30:23Z rwatson $
+ * $FreeBSD: head/sys/fs/portalfs/portal_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
/*
@@ -69,7 +69,7 @@
};
static int
-portal_cmount(struct mntarg *ma, void *data, int flags)
+portal_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
struct portal_args args;
int error;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/pseudofs/pseudofs.c
--- a/head/sys/fs/pseudofs/pseudofs.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/pseudofs/pseudofs.c Wed Feb 01 11:31:17 2012 +0200
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs.c 230132 2012-01-15 13:23:18Z uqs $");
+__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs.c 230249 2012-01-17 01:08:01Z mckusick $");
#include "opt_pseudofs.h"
@@ -330,7 +330,7 @@
* Compatibility shim for old mount(2) system call
*/
int
-pfs_cmount(struct mntarg *ma, void *data, int flags)
+pfs_cmount(struct mntarg *ma, void *data, uint64_t flags)
{
int error;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/pseudofs/pseudofs.h
--- a/head/sys/fs/pseudofs/pseudofs.h Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/pseudofs/pseudofs.h Wed Feb 01 11:31:17 2012 +0200
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/pseudofs/pseudofs.h 230132 2012-01-15 13:23:18Z uqs $
+ * $FreeBSD: head/sys/fs/pseudofs/pseudofs.h 230249 2012-01-17 01:08:01Z mckusick $
*/
#ifndef _PSEUDOFS_H_INCLUDED
@@ -242,7 +242,7 @@
* VFS interface
*/
int pfs_mount (struct pfs_info *pi, struct mount *mp);
-int pfs_cmount (struct mntarg *ma, void *data, int flags);
+int pfs_cmount (struct mntarg *ma, void *data, uint64_t flags);
int pfs_unmount (struct mount *mp, int mntflags);
int pfs_root (struct mount *mp, int flags,
struct vnode **vpp);
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/smbfs/smbfs_vfsops.c
--- a/head/sys/fs/smbfs/smbfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/smbfs/smbfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/smbfs/smbfs_vfsops.c 229272 2012-01-02 12:12:10Z ed $
+ * $FreeBSD: head/sys/fs/smbfs/smbfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
*/
#include <sys/param.h>
@@ -98,7 +98,7 @@
int smbfs_pbuf_freecnt = -1; /* start out unlimited */
static int
-smbfs_cmount(struct mntarg *ma, void * data, int flags)
+smbfs_cmount(struct mntarg *ma, void * data, uint64_t flags)
{
struct smbfs_args args;
int error;
diff -r 393510e878e5 -r 48da769ef822 head/sys/fs/tmpfs/tmpfs_vfsops.c
--- a/head/sys/fs/tmpfs/tmpfs_vfsops.c Wed Feb 01 11:31:00 2012 +0200
+++ b/head/sys/fs/tmpfs/tmpfs_vfsops.c Wed Feb 01 11:31:17 2012 +0200
@@ -41,7 +41,7 @@
* allocate and release resources.
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 230208 2012-01-16 10:25:22Z kevlo $");
+__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 230252 2012-01-17 01:25:53Z kevlo $");
#include <sys/param.h>
#include <sys/limits.h>
@@ -150,8 +150,12 @@
return (EINVAL);
if (mp->mnt_flag & MNT_UPDATE) {
+ /*
+ * Only support update mounts for NFS export.
+ */
if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
return (0);
+ return (EOPNOTSUPP);
}
vn_lock(mp->mnt_vnodecovered, LK_SHARED | LK_RETRY);
More information about the Zrouter-src-freebsd
mailing list