FreeBSD/sys/fs/nfsclient/nfs_clstate.c
/*
 * Create a new open, as required.
 */
Create a new open, as required.
Create a new open as required .
static void
nfscl_newopen(struct nfsclclient *clp, struct nfscldeleg *dp,
    struct nfsclowner **owpp, struct nfsclowner **nowpp, struct nfsclopen **opp,
    struct nfsclopen **nopp, u_int8_t *own, u_int8_t *fhp, int fhlen,
    int *newonep)
{
	struct nfsclowner *owp = *owpp, *nowp;
	struct nfsclopen *op, *nop;
	if (nowpp != NULL)
		nowp = *nowpp;
	else
		nowp = NULL;
	if (nopp != NULL)
		nop = *nopp;
	else
		nop = NULL;
	if (owp == NULL && nowp != NULL) {
		NFSBCOPY(own, nowp->nfsow_owner, NFSV4CL_LOCKNAMELEN);
		LIST_INIT(&nowp->nfsow_open);
		nowp->nfsow_clp = clp;
		nowp->nfsow_seqid = 0;
		nowp->nfsow_defunct = 0;
		nfscl_lockinit(&nowp->nfsow_rwlock);
		if (dp != NULL) {
			newnfsstats.cllocalopenowners++;
			LIST_INSERT_HEAD(&dp->nfsdl_owner, nowp, nfsow_list);
		} else {
			newnfsstats.clopenowners++;
			LIST_INSERT_HEAD(&clp->nfsc_owner, nowp, nfsow_list);
		}
		owp = *owpp = nowp;
		*nowpp = NULL;
		if (newonep != NULL)
			*newonep = 1;
	}
	if (fhp != NULL) {
		LIST_FOREACH(op, &owp->nfsow_open, nfso_list) {
			if (op->nfso_fhlen == fhlen &&
			    !NFSBCMP(op->nfso_fh, fhp, fhlen))
				break;
		}
		if (op == NULL && nop != NULL) {
			nop->nfso_own = owp;
			nop->nfso_mode = 0;
			nop->nfso_opencnt = 0;
			nop->nfso_posixlock = 1;
			nop->nfso_fhlen = fhlen;
			NFSBCOPY(fhp, nop->nfso_fh, fhlen);
			LIST_INIT(&nop->nfso_lock);
			nop->nfso_stateid.seqid = 0;
			nop->nfso_stateid.other[0] = 0;
			nop->nfso_stateid.other[1] = 0;
			nop->nfso_stateid.other[2] = 0;
			if (dp != NULL) {
				TAILQ_REMOVE(&clp->nfsc_deleg, dp, nfsdl_list);
				TAILQ_INSERT_HEAD(&clp->nfsc_deleg, dp,
				    nfsdl_list);
				dp->nfsdl_timestamp = NFSD_MONOSEC + 120;
				newnfsstats.cllocalopens++;
			} else {
				newnfsstats.clopens++;
			}
			LIST_INSERT_HEAD(&owp->nfsow_open, nop, nfso_list);
			*opp = nop;
			*nopp = NULL;
			if (newonep != NULL)
				*newonep = 1;
		} else {
			*opp = op;
		}
	}
}
static void nfscl_newopen ( struct nfsclclient * clp , struct nfscldeleg * dp , struct nfsclowner * * owpp , struct nfsclowner * * nowpp , struct nfsclopen * * opp , struct nfsclopen * * nopp , u_int8_t * own , u_int8_t * fhp , int fhlen , int * newonep ) { struct nfsclowner * owp = * owpp , * nowp ; struct nfsclopen * op , * nop ; if ( nowpp != NULL ) nowp = * nowpp ; else nowp = NULL ; if ( nopp != NULL ) nop = * nopp ; else nop = NULL ; if ( owp == NULL && nowp != NULL ) { NFSBCOPY ( own , nowp -> nfsow_owner , NFSV4CL_LOCKNAMELEN ) ; LIST_INIT ( & nowp -> nfsow_open ) ; nowp -> nfsow_clp = clp ; nowp -> nfsow_seqid = 0 ; nowp -> nfsow_defunct = 0 ; nfscl_lockinit ( & nowp -> nfsow_rwlock ) ; if ( dp != NULL ) { newnfsstats . cllocalopenowners ++ ; LIST_INSERT_HEAD ( & dp -> nfsdl_owner , nowp , nfsow_list ) ; } else { newnfsstats . clopenowners ++ ; LIST_INSERT_HEAD ( & clp -> nfsc_owner , nowp , nfsow_list ) ; } owp = * owpp = nowp ; * nowpp = NULL ; if ( newonep != NULL ) * newonep = 1 ; } if ( fhp != NULL ) { LIST_FOREACH ( op , & owp -> nfsow_open , nfso_list ) { if ( op -> nfso_fhlen == fhlen && ! NFSBCMP ( op -> nfso_fh , fhp , fhlen ) ) break ; } if ( op == NULL && nop != NULL ) { nop -> nfso_own = owp ; nop -> nfso_mode = 0 ; nop -> nfso_opencnt = 0 ; nop -> nfso_posixlock = 1 ; nop -> nfso_fhlen = fhlen ; NFSBCOPY ( fhp , nop -> nfso_fh , fhlen ) ; LIST_INIT ( & nop -> nfso_lock ) ; nop -> nfso_stateid . seqid = 0 ; nop -> nfso_stateid . other [ 0 ] = 0 ; nop -> nfso_stateid . other [ 1 ] = 0 ; nop -> nfso_stateid . other [ 2 ] = 0 ; if ( dp != NULL ) { TAILQ_REMOVE ( & clp -> nfsc_deleg , dp , nfsdl_list ) ; TAILQ_INSERT_HEAD ( & clp -> nfsc_deleg , dp , nfsdl_list ) ; dp -> nfsdl_timestamp = NFSD_MONOSEC + 120 ; newnfsstats . cllocalopens ++ ; } else { newnfsstats . clopens ++ ; } LIST_INSERT_HEAD ( & owp -> nfsow_open , nop , nfso_list ) ; * opp = nop ; * nopp = NULL ; if ( newonep != NULL ) * newonep = 1 ; } else { * opp = op ; } } }
Create a new open, as required.
Create a new open as required .
/* If an fhp has been specified, create an Open as well. */ /* and look for the correct open, based upon FH */