Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsclient/nfs_clport.c
Show First 20 Lines • Show All 408 Lines • ▼ Show 20 Lines | |||||
nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper, | nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper, | ||||
void *stuff, int writeattr, int dontshrink) | void *stuff, int writeattr, int dontshrink) | ||||
{ | { | ||||
struct vnode *vp = *vpp; | struct vnode *vp = *vpp; | ||||
struct vattr *vap, *nvap = &nap->na_vattr, *vaper = nvaper; | struct vattr *vap, *nvap = &nap->na_vattr, *vaper = nvaper; | ||||
struct nfsnode *np; | struct nfsnode *np; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
struct timespec mtime_save; | struct timespec mtime_save; | ||||
vm_object_t object; | |||||
u_quad_t nsize; | |||||
int error, force_fid_err; | int error, force_fid_err; | ||||
bool setnsize; | |||||
error = 0; | error = 0; | ||||
/* | /* | ||||
* If v_type == VNON it is a new node, so fill in the v_type, | * If v_type == VNON it is a new node, so fill in the v_type, | ||||
* n_mtime fields. Check to see if it represents a special | * n_mtime fields. Check to see if it represents a special | ||||
* device, and if so, check for a possible alias. Once the | * device, and if so, check for a possible alias. Once the | ||||
* correct vnode has been obtained, fill in the rest of the | * correct vnode has been obtained, fill in the rest of the | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | if (vaper != NULL) { | ||||
} | } | ||||
} | } | ||||
out: | out: | ||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
if (np->n_attrstamp != 0) | if (np->n_attrstamp != 0) | ||||
KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error); | KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error); | ||||
#endif | #endif | ||||
(void)ncl_pager_setsize(vp, NULL); | |||||
return (error); | |||||
} | |||||
rmacklem: It might be nice to have a comment here noting that the function
unlocks the NFS node, but only… | |||||
bool | |||||
ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep) | |||||
{ | |||||
struct nfsnode *np; | |||||
vm_object_t object; | |||||
struct vattr *vap; | |||||
u_quad_t nsize; | |||||
bool setnsize; | |||||
np = VTONFS(vp); | |||||
NFSASSERTNODE(np); | |||||
vap = &np->n_vattr.na_vattr; | |||||
nsize = vap->va_size; | nsize = vap->va_size; | ||||
object = vp->v_object; | object = vp->v_object; | ||||
setnsize = false; | setnsize = false; | ||||
if (object != NULL) { | |||||
if (OFF_TO_IDX(nsize + PAGE_MASK) < object->size) { | if (object != NULL && nsize != object->un_pager.vnp.vnp_size) { | ||||
/* | if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE) | ||||
* When shrinking the size, the call to | |||||
* vnode_pager_setsize() cannot be done with | |||||
* the mutex held, because we might need to | |||||
* wait for a busy page. Delay it until after | |||||
* the node is unlocked. | |||||
*/ | |||||
setnsize = true; | setnsize = true; | ||||
} else { | else | ||||
vnode_pager_setsize(vp, nsize); | np->n_flag |= NVNSETSZSKIP; | ||||
} | } | ||||
} | if (nsizep == NULL) { | ||||
NFSUNLOCKNODE(np); | NFSUNLOCKNODE(np); | ||||
if (setnsize) | if (setnsize) | ||||
vnode_pager_setsize(vp, nsize); | vnode_pager_setsize(vp, nsize); | ||||
return (error); | setnsize = false; | ||||
} else { | |||||
*nsizep = nsize; | |||||
} | |||||
return (setnsize); | |||||
} | } | ||||
/* | /* | ||||
* Fill in the client id name. For these bytes: | * Fill in the client id name. For these bytes: | ||||
* 1 - they must be unique | * 1 - they must be unique | ||||
* 2 - they should be persistent across client reboots | * 2 - they should be persistent across client reboots | ||||
* 1 is more critical than 2 | * 1 is more critical than 2 | ||||
* Use the mount point's unique id plus either the uuid or, if that | * Use the mount point's unique id plus either the uuid or, if that | ||||
▲ Show 20 Lines • Show All 794 Lines • Show Last 20 Lines |
It might be nice to have a comment here noting that the function
unlocks the NFS node, but only when nsizep == NULL.
(I find I have to look at the function closely to notice this.)
But it is just a suggestion.