Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsclient/nfs_clvnops.c
Show First 20 Lines • Show All 3,577 Lines • ▼ Show 20 Lines | |||||
nfs_allocate(struct vop_allocate_args *ap) | nfs_allocate(struct vop_allocate_args *ap) | ||||
{ | { | ||||
struct vnode *vp = ap->a_vp; | struct vnode *vp = ap->a_vp; | ||||
struct thread *td = curthread; | struct thread *td = curthread; | ||||
struct nfsvattr nfsva; | struct nfsvattr nfsva; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
int attrflag, error, ret; | int attrflag, error, ret; | ||||
if ((ap->a_flags & SPACECTL_F_CANEXTEND) == 0) | |||||
*ap->a_len = omin( | |||||
*ap->a_len, VTONFS(vp)->n_size - *ap->a_offset); | |||||
if (*ap->a_len == 0) | |||||
return (0); | |||||
attrflag = 0; | attrflag = 0; | ||||
nmp = VFSTONFS(vp->v_mount); | nmp = VFSTONFS(vp->v_mount); | ||||
mtx_lock(&nmp->nm_mtx); | mtx_lock(&nmp->nm_mtx); | ||||
if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && | if (NFSHASNFSV4(nmp) && nmp->nm_minorvers >= NFSV42_MINORVERSION && | ||||
(nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { | (nmp->nm_privflag & NFSMNTP_NOALLOCATE) == 0) { | ||||
mtx_unlock(&nmp->nm_mtx); | mtx_unlock(&nmp->nm_mtx); | ||||
/* | /* | ||||
* Flush first to ensure that the allocate adds to the | * Flush first to ensure that the allocate adds to the | ||||
* file's allocation on the server. | * file's allocation on the server. | ||||
*/ | */ | ||||
error = ncl_flush(vp, MNT_WAIT, td, 1, 0); | error = ncl_flush(vp, MNT_WAIT, td, 1, 0); | ||||
if (error == 0) | if (error == 0) | ||||
error = nfsrpc_allocate(vp, *ap->a_offset, *ap->a_len, | error = nfsrpc_allocate(vp, *ap->a_offset, *ap->a_len, | ||||
&nfsva, &attrflag, td->td_ucred, td, NULL); | &nfsva, &attrflag, ap->a_cred, td, NULL); | ||||
if (error == 0) { | if (error == 0) { | ||||
*ap->a_offset += *ap->a_len; | *ap->a_offset += *ap->a_len; | ||||
*ap->a_len = 0; | *ap->a_len = 0; | ||||
} else if (error == NFSERR_NOTSUPP) { | } else if (error == NFSERR_NOTSUPP) { | ||||
mtx_lock(&nmp->nm_mtx); | mtx_lock(&nmp->nm_mtx); | ||||
nmp->nm_privflag |= NFSMNTP_NOALLOCATE; | nmp->nm_privflag |= NFSMNTP_NOALLOCATE; | ||||
mtx_unlock(&nmp->nm_mtx); | mtx_unlock(&nmp->nm_mtx); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 684 Lines • Show Last 20 Lines |