aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/nfsclient
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/nfsclient')
-rw-r--r--sys/fs/nfsclient/nfs_clport.c13
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c8
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c31
3 files changed, 24 insertions, 28 deletions
diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c
index 704aeeeabdf2..77e71d4153c9 100644
--- a/sys/fs/nfsclient/nfs_clport.c
+++ b/sys/fs/nfsclient/nfs_clport.c
@@ -412,7 +412,7 @@ nfscl_warn_fileid(struct nfsmount *nmp, struct nfsvattr *oldnap,
}
void
-ncl_copy_vattr(struct vattr *dst, struct vattr *src)
+ncl_copy_vattr(struct vnode *vp, struct vattr *dst, struct vattr *src)
{
dst->va_type = src->va_type;
dst->va_mode = src->va_mode;
@@ -429,7 +429,7 @@ ncl_copy_vattr(struct vattr *dst, struct vattr *src)
dst->va_birthtime = src->va_birthtime;
dst->va_gen = src->va_gen;
dst->va_flags = src->va_flags;
- dst->va_rdev = src->va_rdev;
+ dst->va_rdev = VN_ISDEV(vp) ? src->va_rdev : NODEV;
dst->va_bytes = src->va_bytes;
dst->va_filerev = src->va_filerev;
}
@@ -595,7 +595,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper,
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
}
if (vaper != NULL) {
- ncl_copy_vattr(vaper, vap);
+ ncl_copy_vattr(vp, vaper, vap);
if (np->n_flag & NCHG) {
if (np->n_flag & NACC)
vaper->va_atime = np->n_atim;
@@ -1098,9 +1098,10 @@ newnfs_copyincred(struct ucred *cr, struct nfscred *nfscr)
KASSERT(cr->cr_ngroups >= 0,
("newnfs_copyincred: negative cr_ngroups"));
nfscr->nfsc_uid = cr->cr_uid;
- nfscr->nfsc_ngroups = MIN(cr->cr_ngroups, NFS_MAXGRPS + 1);
- for (i = 0; i < nfscr->nfsc_ngroups; i++)
- nfscr->nfsc_groups[i] = cr->cr_groups[i];
+ nfscr->nfsc_ngroups = MIN(cr->cr_ngroups + 1, NFS_MAXGRPS + 1);
+ nfscr->nfsc_groups[0] = cr->cr_gid;
+ for (i = 1; i < nfscr->nfsc_ngroups; i++)
+ nfscr->nfsc_groups[i] = cr->cr_groups[i - 1];
}
/*
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 4ec621de2eff..ad9404a18fc8 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -3981,7 +3981,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
int len, left;
struct dirent *dp = NULL;
u_int32_t *tl;
- vnode_t newvp = NULLVP;
+ vnode_t newvp = NULL;
struct nfsrv_descript nfsd, *nd = &nfsd;
struct nameidata nami, *ndp = &nami;
struct componentname *cnp = &ndp->ni_cnd;
@@ -4387,7 +4387,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
attr_ok = true;
if (NFSRV_CMPFH(nfhp->nfh_fh, nfhp->nfh_len,
dnp->n_fhp->nfh_fh, dnp->n_fhp->nfh_len)) {
- VREF(vp);
+ vref(vp);
newvp = vp;
unlocknewvp = 0;
free(nfhp, M_NFSFH);
@@ -4436,7 +4436,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
}
}
nfhp = NULL;
- if (newvp != NULLVP) {
+ if (newvp != NULL) {
if (attr_ok)
error = nfscl_loadattrcache(&newvp,
&nfsva, NULL, 0, 0);
@@ -4466,7 +4466,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
vput(newvp);
else
vrele(newvp);
- newvp = NULLVP;
+ newvp = NULL;
}
}
} else if (nfhp != NULL) {
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 52f72dc43c3f..e9ae91e046e7 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -1026,7 +1026,7 @@ nfs_getattr(struct vop_getattr_args *ap)
* cached attributes should be ignored.
*/
if (nmp->nm_fhsize > 0 && ncl_getattrcache(vp, &vattr) == 0) {
- ncl_copy_vattr(vap, &vattr);
+ ncl_copy_vattr(vp, vap, &vattr);
/*
* Get the local modify time for the case of a write
@@ -1284,7 +1284,7 @@ nfs_lookup(struct vop_lookup_args *ap)
bool is_nameddir, needs_nameddir, opennamed;
dattrflag = 0;
- *vpp = NULLVP;
+ *vpp = NULL;
nmp = VFSTONFS(mp);
opennamed = (flags & (OPENNAMED | ISLASTCN)) == (OPENNAMED | ISLASTCN);
if (opennamed && (!NFSHASNFSV4(nmp) || !NFSHASNFSV4N(nmp)))
@@ -1309,7 +1309,7 @@ nfs_lookup(struct vop_lookup_args *ap)
/*
* If the named attribute directory is needed, acquire it now.
*/
- newvp = NULLVP;
+ newvp = NULL;
if (needs_nameddir) {
KASSERT(np->n_v4 == NULL, ("nfs_lookup: O_NAMEDATTR when"
" n_v4 not NULL"));
@@ -1322,10 +1322,10 @@ nfs_lookup(struct vop_lookup_args *ap)
}
dvp = newvp;
np = VTONFS(dvp);
- newvp = NULLVP;
+ newvp = NULL;
} else if (opennamed && cnp->cn_namelen == 1 &&
*cnp->cn_nameptr == '.') {
- VREF(dvp);
+ vref(dvp);
*vpp = dvp;
return (0);
}
@@ -1399,7 +1399,7 @@ nfs_lookup(struct vop_lookup_args *ap)
vput(newvp);
else
vrele(newvp);
- *vpp = NULLVP;
+ *vpp = NULL;
} else if (error == ENOENT) {
if (VN_IS_DOOMED(dvp))
return (ENOENT);
@@ -1450,7 +1450,7 @@ nfs_lookup(struct vop_lookup_args *ap)
NFSUNLOCKMNT(nmp);
#endif
- newvp = NULLVP;
+ newvp = NULL;
NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses);
nanouptime(&ts);
error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen,
@@ -1464,9 +1464,9 @@ nfs_lookup(struct vop_lookup_args *ap)
}
handle_error:
if (error) {
- if (newvp != NULLVP) {
+ if (newvp != NULL) {
vput(newvp);
- *vpp = NULLVP;
+ *vpp = NULL;
}
if (error != ENOENT) {
@@ -1587,7 +1587,7 @@ handle_error:
0, 1);
} else if (NFS_CMPFH(np, nfhp->nfh_fh, nfhp->nfh_len)) {
free(nfhp, M_NFSFH);
- VREF(dvp);
+ vref(dvp);
newvp = dvp;
if (attrflag)
(void) nfscl_loadattrcache(&newvp, &nfsva, NULL,
@@ -2863,7 +2863,7 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
M_NEWNFSREQ, M_WAITOK);
sp->s_cred = crhold(cnp->cn_cred);
sp->s_dvp = dvp;
- VREF(dvp);
+ vref(dvp);
/*
* Fudge together a funny name.
@@ -2961,7 +2961,7 @@ nfs_lookitup(struct vnode *dvp, char *name, int len, struct ucred *cred,
newvp = NFSTOV(np);
} else if (NFS_CMPFH(dnp, nfhp->nfh_fh, nfhp->nfh_len)) {
free(nfhp, M_NFSFH);
- VREF(dvp);
+ vref(dvp);
newvp = dvp;
} else {
cn.cn_nameptr = name;
@@ -3474,7 +3474,7 @@ nfs_advlock(struct vop_advlock_args *ap)
u_quad_t size;
struct nfsmount *nmp;
- error = NFSVOPLOCK(vp, LK_SHARED);
+ error = NFSVOPLOCK(vp, LK_EXCLUSIVE);
if (error != 0)
return (EBADF);
nmp = VFSTONFS(vp->v_mount);
@@ -3511,11 +3511,6 @@ nfs_advlock(struct vop_advlock_args *ap)
cred = p->p_ucred;
else
cred = td->td_ucred;
- NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY);
- if (VN_IS_DOOMED(vp)) {
- error = EBADF;
- goto out;
- }
/*
* If this is unlocking a write locked region, flush and