FreeBSD/sys/fs/nfsclient/nfs_clstate.c
/*
 * Commit all layouts for a file (vnode).
 */
Commit all layouts for a file (vnode).
Commit all layouts for a file ( vnode ) .
int
nfscl_layoutcommit(vnode_t vp, NFSPROC_T *p)
{
	struct nfsclclient *clp;
	struct nfscllayout *lyp;
	struct nfsnode *np = VTONFS(vp);
	mount_t mp;
	struct nfsmount *nmp;
	mp = vnode_mount(vp);
	nmp = VFSTONFS(mp);
	if (NFSHASNOLAYOUTCOMMIT(nmp))
		return (0);
	NFSLOCKCLSTATE();
	clp = nmp->nm_clp;
	if (clp == NULL) {
		NFSUNLOCKCLSTATE();
		return (EPERM);
	}
	lyp = nfscl_findlayout(clp, np->n_fhp->nfh_fh, np->n_fhp->nfh_len);
	if (lyp == NULL) {
		NFSUNLOCKCLSTATE();
		return (EPERM);
	}
	nfsv4_getref(&lyp->nfsly_lock, NULL, NFSCLSTATEMUTEXPTR, mp);
	if ((mp->mnt_kern_flag & MNTK_UNMOUNTF) != 0) {
		NFSUNLOCKCLSTATE();
		return (EPERM);
	}
tryagain:
	if ((lyp->nfsly_flags & NFSLY_WRITTEN) != 0) {
		lyp->nfsly_flags &= ~NFSLY_WRITTEN;
		NFSUNLOCKCLSTATE();
		NFSCL_DEBUG(4, "do layoutcommit2\n");
		nfscl_dolayoutcommit(clp->nfsc_nmp, lyp, NFSPROCCRED(p), p);
		NFSLOCKCLSTATE();
		goto tryagain;
	}
	nfsv4_relref(&lyp->nfsly_lock);
	NFSUNLOCKCLSTATE();
	return (0);
}
int nfscl_layoutcommit ( vnode_t vp , NFSPROC_T * p ) { struct nfsclclient * clp ; struct nfscllayout * lyp ; struct nfsnode * np = VTONFS ( vp ) ; mount_t mp ; struct nfsmount * nmp ; mp = vnode_mount ( vp ) ; nmp = VFSTONFS ( mp ) ; if ( NFSHASNOLAYOUTCOMMIT ( nmp ) ) return ( 0 ) ; NFSLOCKCLSTATE ( ) ; clp = nmp -> nm_clp ; if ( clp == NULL ) { NFSUNLOCKCLSTATE ( ) ; return ( EPERM ) ; } lyp = nfscl_findlayout ( clp , np -> n_fhp -> nfh_fh , np -> n_fhp -> nfh_len ) ; if ( lyp == NULL ) { NFSUNLOCKCLSTATE ( ) ; return ( EPERM ) ; } nfsv4_getref ( & lyp -> nfsly_lock , NULL , NFSCLSTATEMUTEXPTR , mp ) ; if ( ( mp -> mnt_kern_flag & MNTK_UNMOUNTF ) != 0 ) { NFSUNLOCKCLSTATE ( ) ; return ( EPERM ) ; } tryagain : if ( ( lyp -> nfsly_flags & NFSLY_WRITTEN ) != 0 ) { lyp -> nfsly_flags &= ~ NFSLY_WRITTEN ; NFSUNLOCKCLSTATE ( ) ; NFSCL_DEBUG ( 4 , " \n " ) ; nfscl_dolayoutcommit ( clp -> nfsc_nmp , lyp , NFSPROCCRED ( p ) , p ) ; NFSLOCKCLSTATE ( ) ; goto tryagain ; } nfsv4_relref ( & lyp -> nfsly_lock ) ; NFSUNLOCKCLSTATE ( ) ; return ( 0 ) ; }
Commit all layouts for a file (vnode).
Commit all layouts for a file ( vnode ) .