Changeset View
Standalone View
sys/fs/nfsserver/nfs_nfsdport.c
Show First 20 Lines • Show All 3,239 Lines • ▼ Show 20 Lines | |||||
* - if mpp != NULL, return the mount point so that it can | * - if mpp != NULL, return the mount point so that it can | ||||
* be used for vn_finished_write() by the caller | * be used for vn_finished_write() by the caller | ||||
*/ | */ | ||||
void | void | ||||
nfsd_fhtovp(struct nfsrv_descript *nd, struct nfsrvfh *nfp, int lktype, | nfsd_fhtovp(struct nfsrv_descript *nd, struct nfsrvfh *nfp, int lktype, | ||||
struct vnode **vpp, struct nfsexstuff *exp, | struct vnode **vpp, struct nfsexstuff *exp, | ||||
struct mount **mpp, int startwrite) | struct mount **mpp, int startwrite) | ||||
{ | { | ||||
struct mount *mp; | struct mount *mp, *mpw; | ||||
struct ucred *credanon; | struct ucred *credanon; | ||||
fhandle_t *fhp; | fhandle_t *fhp; | ||||
int error; | |||||
if (*mpp != NULL) | |||||
rmacklem: This causes crashes. I think you meant..
if (mpp != NULL)
| |||||
*mpp = NULL; | |||||
*vpp = NULL; | |||||
fhp = (fhandle_t *)nfp->nfsrvfh_data; | fhp = (fhandle_t *)nfp->nfsrvfh_data; | ||||
/* | |||||
* Check for the special case of the nfsv4root_fh. | |||||
*/ | |||||
mp = vfs_busyfs(&fhp->fh_fsid); | mp = vfs_busyfs(&fhp->fh_fsid); | ||||
if (mpp != NULL) | |||||
*mpp = mp; | |||||
if (mp == NULL) { | if (mp == NULL) { | ||||
*vpp = NULL; | |||||
nd->nd_repstat = ESTALE; | nd->nd_repstat = ESTALE; | ||||
goto out; | goto out; | ||||
} | } | ||||
if (startwrite) { | if (startwrite) { | ||||
vn_start_write(NULL, mpp, V_WAIT); | mpw = mp; | ||||
error = vn_start_write(NULL, &mpw, V_WAIT); | |||||
if (error != 0) { | |||||
mpw = NULL; | |||||
vfs_unbusy(mp); | |||||
Not Done Inline ActionsSure. But at least for NFSv4, the recognized errors The only one of these that is recognized by rmacklem: Sure. But at least for NFSv4, the recognized errors
for this operation (PutFH) are in… | |||||
nd->nd_repstat = EIO; | |||||
rmacklemUnsubmitted Done Inline ActionsIt might be better to set ESTALE here. rmacklem: It might be better to set ESTALE here.
It is the error that tells the NFS client
that the file… | |||||
rmacklemUnsubmitted Done Inline ActionsI think that ESTALE might be better here. Having said that, it does not appear that rmacklem: I think that ESTALE might be better here.
It is what NFS clients expect when translation
of a… | |||||
kibAuthorUnsubmitted Done Inline ActionsThis is not a translation of the file handle, but attempt to prepare for operation. Anyway, I changed the error to ESTALE. I cannot guarantee that vn_start_write() would not return an error for V_WAIT forever. I see no reason to not use the VFS KPI in a way that is more future-proof. kib: This is not a translation of the file handle, but attempt to prepare for operation. Anyway, I… | |||||
goto out; | |||||
} | |||||
if (lktype == LK_SHARED && !(MNT_SHARED_WRITES(mp))) | if (lktype == LK_SHARED && !(MNT_SHARED_WRITES(mp))) | ||||
lktype = LK_EXCLUSIVE; | lktype = LK_EXCLUSIVE; | ||||
} | } else | ||||
mpw = NULL; | |||||
nd->nd_repstat = nfsvno_fhtovp(mp, fhp, nd->nd_nam, lktype, vpp, exp, | nd->nd_repstat = nfsvno_fhtovp(mp, fhp, nd->nd_nam, lktype, vpp, exp, | ||||
&credanon); | &credanon); | ||||
vfs_unbusy(mp); | vfs_unbusy(mp); | ||||
/* | /* | ||||
* For NFSv4 without a pseudo root fs, unexported file handles | * For NFSv4 without a pseudo root fs, unexported file handles | ||||
* can be returned, so that Lookup works everywhere. | * can be returned, so that Lookup works everywhere. | ||||
*/ | */ | ||||
if (!nd->nd_repstat && exp->nes_exflag == 0 && | if (!nd->nd_repstat && exp->nes_exflag == 0 && | ||||
!(nd->nd_flag & ND_NFSV4)) { | !(nd->nd_flag & ND_NFSV4)) { | ||||
vput(*vpp); | vput(*vpp); | ||||
*vpp = NULL; | |||||
nd->nd_repstat = EACCES; | nd->nd_repstat = EACCES; | ||||
} | } | ||||
/* | /* | ||||
* If TLS is required by the export, check the flags in nd_flag. | * If TLS is required by the export, check the flags in nd_flag. | ||||
*/ | */ | ||||
if (nd->nd_repstat == 0 && ((NFSVNO_EXTLS(exp) && | if (nd->nd_repstat == 0 && ((NFSVNO_EXTLS(exp) && | ||||
(nd->nd_flag & ND_TLS) == 0) || | (nd->nd_flag & ND_TLS) == 0) || | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | if (!nd->nd_repstat) { | ||||
nd->nd_saveduid = nd->nd_cred->cr_uid; | nd->nd_saveduid = nd->nd_cred->cr_uid; | ||||
nd->nd_repstat = nfsd_excred(nd, exp, credanon); | nd->nd_repstat = nfsd_excred(nd, exp, credanon); | ||||
if (nd->nd_repstat) | if (nd->nd_repstat) | ||||
vput(*vpp); | vput(*vpp); | ||||
} | } | ||||
if (credanon != NULL) | if (credanon != NULL) | ||||
crfree(credanon); | crfree(credanon); | ||||
if (nd->nd_repstat) { | if (nd->nd_repstat) { | ||||
if (startwrite) | vn_finished_write(mpw); | ||||
vn_finished_write(mp); | |||||
*vpp = NULL; | *vpp = NULL; | ||||
if (mpp != NULL) | } else if (mpp != NULL) { | ||||
*mpp = NULL; | *mpp = mpw; | ||||
} | } | ||||
out: | out: | ||||
NFSEXITCODE2(0, nd); | NFSEXITCODE2(0, nd); | ||||
} | } | ||||
/* | /* | ||||
* glue for fp. | * glue for fp. | ||||
▲ Show 20 Lines • Show All 3,359 Lines • Show Last 20 Lines |
This causes crashes. I think you meant..