Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/nfsclient/nfs_clstate.c
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, | ||||
* Might need one or both of these, so MALLOC them now, to | * Might need one or both of these, so MALLOC them now, to | ||||
* avoid a tsleep() in MALLOC later. | * avoid a tsleep() in MALLOC later. | ||||
*/ | */ | ||||
nowp = malloc(sizeof (struct nfsclowner), | nowp = malloc(sizeof (struct nfsclowner), | ||||
M_NFSCLOWNER, M_WAITOK); | M_NFSCLOWNER, M_WAITOK); | ||||
if (nfhp != NULL) | if (nfhp != NULL) | ||||
nop = malloc(sizeof (struct nfsclopen) + | nop = malloc(sizeof (struct nfsclopen) + | ||||
fhlen - 1, M_NFSCLOPEN, M_WAITOK); | fhlen - 1, M_NFSCLOPEN, M_WAITOK); | ||||
ret = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); | ret = nfscl_getcl(vp->v_mount, cred, p, 1, &clp); | ||||
if (ret != 0) { | if (ret != 0) { | ||||
free(nowp, M_NFSCLOWNER); | free(nowp, M_NFSCLOWNER); | ||||
if (nop != NULL) | if (nop != NULL) | ||||
free(nop, M_NFSCLOPEN); | free(nop, M_NFSCLOPEN); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
/* | /* | ||||
Show All 17 Lines | if (nfhp != NULL && usedeleg) { | ||||
} | } | ||||
} | } | ||||
if (dp != NULL) { | if (dp != NULL) { | ||||
nfscl_filllockowner(p->td_proc, own, F_POSIX); | nfscl_filllockowner(p->td_proc, own, F_POSIX); | ||||
ohp = &dp->nfsdl_owner; | ohp = &dp->nfsdl_owner; | ||||
} else { | } else { | ||||
/* For NFSv4.1 and this option, use a single open_owner. */ | /* For NFSv4.1 and this option, use a single open_owner. */ | ||||
if (NFSHASONEOPENOWN(VFSTONFS(vnode_mount(vp)))) | if (NFSHASONEOPENOWN(VFSTONFS(vp->v_mount))) | ||||
nfscl_filllockowner(NULL, own, F_POSIX); | nfscl_filllockowner(NULL, own, F_POSIX); | ||||
else | else | ||||
nfscl_filllockowner(p->td_proc, own, F_POSIX); | nfscl_filllockowner(p->td_proc, own, F_POSIX); | ||||
ohp = &clp->nfsc_owner; | ohp = &clp->nfsc_owner; | ||||
} | } | ||||
/* Now, search for an openowner */ | /* Now, search for an openowner */ | ||||
LIST_FOREACH(owp, ohp, nfsow_list) { | LIST_FOREACH(owp, ohp, nfsow_list) { | ||||
if (!NFSBCMP(owp->nfsow_owner, own, NFSV4CL_LOCKNAMELEN)) | if (!NFSBCMP(owp->nfsow_owner, own, NFSV4CL_LOCKNAMELEN)) | ||||
Show All 26 Lines | nfscl_open(vnode_t vp, u_int8_t *nfhp, int fhlen, u_int32_t amode, int usedeleg, | ||||
/* | /* | ||||
* Serialize modifications to the open owner for multiple threads | * Serialize modifications to the open owner for multiple threads | ||||
* within the same process using a read/write sleep lock. | * within the same process using a read/write sleep lock. | ||||
* For NFSv4.1 and a single OpenOwner, allow concurrent open operations | * For NFSv4.1 and a single OpenOwner, allow concurrent open operations | ||||
* by acquiring a shared lock. The close operations still use an | * by acquiring a shared lock. The close operations still use an | ||||
* exclusive lock for this case. | * exclusive lock for this case. | ||||
*/ | */ | ||||
if (lockit != 0) { | if (lockit != 0) { | ||||
if (NFSHASONEOPENOWN(VFSTONFS(vnode_mount(vp)))) { | if (NFSHASONEOPENOWN(VFSTONFS(vp->v_mount))) { | ||||
/* | /* | ||||
* Get a shared lock on the OpenOwner, but first | * Get a shared lock on the OpenOwner, but first | ||||
* wait for any pending exclusive lock, so that the | * wait for any pending exclusive lock, so that the | ||||
* exclusive locker gets priority. | * exclusive locker gets priority. | ||||
*/ | */ | ||||
nfsv4_lock(&owp->nfsow_rwlock, 0, NULL, | nfsv4_lock(&owp->nfsow_rwlock, 0, NULL, | ||||
NFSCLSTATEMUTEXPTR, NULL); | NFSCLSTATEMUTEXPTR, NULL); | ||||
nfsv4_getref(&owp->nfsow_rwlock, NULL, | nfsv4_getref(&owp->nfsow_rwlock, NULL, | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | if (fords == 0) { | ||||
stateidp->seqid = 0; | stateidp->seqid = 0; | ||||
stateidp->other[0] = 0; | stateidp->other[0] = 0; | ||||
stateidp->other[1] = 0; | stateidp->other[1] = 0; | ||||
stateidp->other[2] = 0; | stateidp->other[2] = 0; | ||||
} | } | ||||
if (vnode_vtype(vp) != VREG) | if (vnode_vtype(vp) != VREG) | ||||
return (EISDIR); | return (EISDIR); | ||||
np = VTONFS(vp); | np = VTONFS(vp); | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return (EACCES); | return (EACCES); | ||||
} | } | ||||
/* | /* | ||||
Show All 32 Lines | LIST_FOREACH(dp, NFSCLDELEGHASH(clp, nfhp, fhlen), nfsdl_hash) { | ||||
} | } | ||||
} | } | ||||
if (p != NULL) { | if (p != NULL) { | ||||
/* | /* | ||||
* If p != NULL, we want to search the parentage tree | * If p != NULL, we want to search the parentage tree | ||||
* for a matching OpenOwner and use that. | * for a matching OpenOwner and use that. | ||||
*/ | */ | ||||
if (NFSHASONEOPENOWN(VFSTONFS(vnode_mount(vp)))) | if (NFSHASONEOPENOWN(VFSTONFS(vp->v_mount))) | ||||
nfscl_filllockowner(NULL, own, F_POSIX); | nfscl_filllockowner(NULL, own, F_POSIX); | ||||
else | else | ||||
nfscl_filllockowner(p->td_proc, own, F_POSIX); | nfscl_filllockowner(p->td_proc, own, F_POSIX); | ||||
lp = NULL; | lp = NULL; | ||||
error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, own, own, | error = nfscl_getopen(&clp->nfsc_owner, nfhp, fhlen, own, own, | ||||
mode, &lp, &op); | mode, &lp, &op); | ||||
if (error == 0 && lp != NULL && fords == 0) { | if (error == 0 && lp != NULL && fords == 0) { | ||||
/* Don't return a lock stateid for a DS. */ | /* Don't return a lock stateid for a DS. */ | ||||
▲ Show 20 Lines • Show All 440 Lines • ▼ Show 20 Lines | if (len == NFS64BITSSET) { | ||||
if (nlop->nfslo_end <= nlop->nfslo_first) | if (nlop->nfslo_end <= nlop->nfslo_first) | ||||
error = NFSERR_INVAL; | error = NFSERR_INVAL; | ||||
} | } | ||||
if (!error) { | if (!error) { | ||||
if (recovery) | if (recovery) | ||||
clp = rclp; | clp = rclp; | ||||
else | else | ||||
error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); | error = nfscl_getcl(vp->v_mount, cred, p, 1, &clp); | ||||
} | } | ||||
if (error) { | if (error) { | ||||
free(nlp, M_NFSCLLOCKOWNER); | free(nlp, M_NFSCLLOCKOWNER); | ||||
free(otherlop, M_NFSCLLOCK); | free(otherlop, M_NFSCLLOCK); | ||||
free(nlop, M_NFSCLLOCK); | free(nlop, M_NFSCLLOCK); | ||||
return (error); | return (error); | ||||
} | } | ||||
op = NULL; | op = NULL; | ||||
if (recovery) { | if (recovery) { | ||||
ownp = rownp; | ownp = rownp; | ||||
openownp = ropenownp; | openownp = ropenownp; | ||||
} else { | } else { | ||||
nfscl_filllockowner(id, own, flags); | nfscl_filllockowner(id, own, flags); | ||||
ownp = own; | ownp = own; | ||||
if (NFSHASONEOPENOWN(VFSTONFS(vnode_mount(vp)))) | if (NFSHASONEOPENOWN(VFSTONFS(vp->v_mount))) | ||||
nfscl_filllockowner(NULL, openown, F_POSIX); | nfscl_filllockowner(NULL, openown, F_POSIX); | ||||
else | else | ||||
nfscl_filllockowner(p->td_proc, openown, F_POSIX); | nfscl_filllockowner(p->td_proc, openown, F_POSIX); | ||||
openownp = openown; | openownp = openown; | ||||
} | } | ||||
if (!recovery) { | if (!recovery) { | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | nfscl_checkwritelocked(vnode_t vp, struct flock *fl, | ||||
if (fl->l_len != 0) { | if (fl->l_len != 0) { | ||||
end = off + fl->l_len; | end = off + fl->l_len; | ||||
if (end < off) | if (end < off) | ||||
return (1); | return (1); | ||||
} else { | } else { | ||||
end = NFS64BITSSET; | end = NFS64BITSSET; | ||||
} | } | ||||
error = nfscl_getcl(vnode_mount(vp), cred, p, 1, &clp); | error = nfscl_getcl(vp->v_mount, cred, p, 1, &clp); | ||||
if (error) | if (error) | ||||
return (1); | return (1); | ||||
nfscl_filllockowner(id, own, flags); | nfscl_filllockowner(id, own, flags); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
* First check the delegation locks. | * First check the delegation locks. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 1,598 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
nfscl_dupopen(vnode_t vp, int dupopens) | nfscl_dupopen(vnode_t vp, int dupopens) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfsclowner *owp, *owp2; | struct nfsclowner *owp, *owp2; | ||||
struct nfsclopen *op, *op2; | struct nfsclopen *op, *op2; | ||||
struct nfsfh *nfhp; | struct nfsfh *nfhp; | ||||
clp = VFSTONFS(vnode_mount(vp))->nm_clp; | clp = VFSTONFS(vp->v_mount)->nm_clp; | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
printf("nfscl dupopen NULL clp\n"); | printf("nfscl dupopen NULL clp\n"); | ||||
return; | return; | ||||
} | } | ||||
nfhp = VTONFS(vp)->n_fhp; | nfhp = VTONFS(vp)->n_fhp; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
* First, search for duplicate owners. | * First, search for duplicate owners. | ||||
* These should never happen! | * These should never happen! | ||||
*/ | */ | ||||
LIST_FOREACH(owp2, &clp->nfsc_owner, nfsow_list) { | LIST_FOREACH(owp2, &clp->nfsc_owner, nfsow_list) { | ||||
LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { | LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { | ||||
if (owp != owp2 && | if (owp != owp2 && | ||||
!NFSBCMP(owp->nfsow_owner, owp2->nfsow_owner, | !NFSBCMP(owp->nfsow_owner, owp2->nfsow_owner, | ||||
NFSV4CL_LOCKNAMELEN)) { | NFSV4CL_LOCKNAMELEN)) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
printf("DUP OWNER\n"); | printf("DUP OWNER\n"); | ||||
nfscl_dumpstate(VFSTONFS(vnode_mount(vp)), 1, 1, 0, 0); | nfscl_dumpstate(VFSTONFS(vp->v_mount), 1, 1, 0, 0); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Now, search for duplicate stateids. | * Now, search for duplicate stateids. | ||||
* These shouldn't happen, either. | * These shouldn't happen, either. | ||||
*/ | */ | ||||
LIST_FOREACH(owp2, &clp->nfsc_owner, nfsow_list) { | LIST_FOREACH(owp2, &clp->nfsc_owner, nfsow_list) { | ||||
LIST_FOREACH(op2, &owp2->nfsow_open, nfso_list) { | LIST_FOREACH(op2, &owp2->nfsow_open, nfso_list) { | ||||
LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { | LIST_FOREACH(owp, &clp->nfsc_owner, nfsow_list) { | ||||
LIST_FOREACH(op, &owp->nfsow_open, nfso_list) { | LIST_FOREACH(op, &owp->nfsow_open, nfso_list) { | ||||
if (op != op2 && | if (op != op2 && | ||||
(op->nfso_stateid.other[0] != 0 || | (op->nfso_stateid.other[0] != 0 || | ||||
op->nfso_stateid.other[1] != 0 || | op->nfso_stateid.other[1] != 0 || | ||||
op->nfso_stateid.other[2] != 0) && | op->nfso_stateid.other[2] != 0) && | ||||
op->nfso_stateid.other[0] == op2->nfso_stateid.other[0] && | op->nfso_stateid.other[0] == op2->nfso_stateid.other[0] && | ||||
op->nfso_stateid.other[1] == op2->nfso_stateid.other[1] && | op->nfso_stateid.other[1] == op2->nfso_stateid.other[1] && | ||||
op->nfso_stateid.other[2] == op2->nfso_stateid.other[2]) { | op->nfso_stateid.other[2] == op2->nfso_stateid.other[2]) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
printf("DUP STATEID\n"); | printf("DUP STATEID\n"); | ||||
nfscl_dumpstate(VFSTONFS(vnode_mount(vp)), 1, 1, 0, | nfscl_dumpstate(VFSTONFS(vp->v_mount), 1, 1, 0, 0); | ||||
0); | |||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
Show All 17 Lines | if (nfhp->nfh_len == op2->nfso_fhlen && | ||||
if (!NFSBCMP(op->nfso_own->nfsow_owner, | if (!NFSBCMP(op->nfso_own->nfsow_owner, | ||||
op2->nfso_own->nfsow_owner, NFSV4CL_LOCKNAMELEN)) { | op2->nfso_own->nfsow_owner, NFSV4CL_LOCKNAMELEN)) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
printf("BADDUP OPEN\n"); | printf("BADDUP OPEN\n"); | ||||
} else { | } else { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
printf("DUP OPEN\n"); | printf("DUP OPEN\n"); | ||||
} | } | ||||
nfscl_dumpstate(VFSTONFS(vnode_mount(vp)), 1, 1, | nfscl_dumpstate(VFSTONFS(vp->v_mount), 1, 1, 0, | ||||
0, 0); | 0); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
Show All 16 Lines | |||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfsclowner *owp; | struct nfsclowner *owp; | ||||
struct nfsclopen *op; | struct nfsclopen *op; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsfh *nfhp; | struct nfsfh *nfhp; | ||||
int error, notdecr; | int error, notdecr; | ||||
error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, &clp); | error = nfscl_getcl(vp->v_mount, NULL, NULL, 1, &clp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
*clpp = clp; | *clpp = clp; | ||||
nfhp = VTONFS(vp)->n_fhp; | nfhp = VTONFS(vp)->n_fhp; | ||||
notdecr = 1; | notdecr = 1; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | nfscl_doclose(vnode_t vp, struct nfsclclient **clpp, NFSPROC_T *p) | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfsclowner *owp, *nowp; | struct nfsclowner *owp, *nowp; | ||||
struct nfsclopen *op; | struct nfsclopen *op; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsfh *nfhp; | struct nfsfh *nfhp; | ||||
struct nfsclrecalllayout *recallp; | struct nfsclrecalllayout *recallp; | ||||
int error; | int error; | ||||
error = nfscl_getcl(vnode_mount(vp), NULL, NULL, 1, &clp); | error = nfscl_getcl(vp->v_mount, NULL, NULL, 1, &clp); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
*clpp = clp; | *clpp = clp; | ||||
nfhp = VTONFS(vp)->n_fhp; | nfhp = VTONFS(vp)->n_fhp; | ||||
recallp = malloc(sizeof(*recallp), M_NFSLAYRECALL, M_WAITOK); | recallp = malloc(sizeof(*recallp), M_NFSLAYRECALL, M_WAITOK); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
Show All 26 Lines | while (op != NULL) { | ||||
nfhp->nfh_len)) { | nfhp->nfh_len)) { | ||||
/* Found an open, close it. */ | /* Found an open, close it. */ | ||||
#ifdef DIAGNOSTIC | #ifdef DIAGNOSTIC | ||||
KASSERT((op->nfso_opencnt == 0), | KASSERT((op->nfso_opencnt == 0), | ||||
("nfscl: bad open cnt on server (%d)", | ("nfscl: bad open cnt on server (%d)", | ||||
op->nfso_opencnt)); | op->nfso_opencnt)); | ||||
#endif | #endif | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
nfsrpc_doclose(VFSTONFS(vnode_mount(vp)), op, | nfsrpc_doclose(VFSTONFS(vp->v_mount), op, p); | ||||
p); | |||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
goto lookformore; | goto lookformore; | ||||
} | } | ||||
op = LIST_NEXT(op, nfso_list); | op = LIST_NEXT(op, nfso_list); | ||||
} | } | ||||
} | } | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 1,110 Lines • ▼ Show 20 Lines | |||||
nfscl_mustflush(vnode_t vp) | nfscl_mustflush(vnode_t vp) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np; | struct nfsnode *np; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
np = VTONFS(vp); | np = VTONFS(vp); | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return (1); | return (1); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return (1); | return (1); | ||||
} | } | ||||
Show All 17 Lines | |||||
nfscl_nodeleg(vnode_t vp, int writedeleg) | nfscl_nodeleg(vnode_t vp, int writedeleg) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np; | struct nfsnode *np; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
np = VTONFS(vp); | np = VTONFS(vp); | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return (1); | return (1); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return (1); | return (1); | ||||
} | } | ||||
Show All 19 Lines | nfscl_removedeleg(vnode_t vp, NFSPROC_T *p, nfsv4stateid_t *stp) | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsclowner *owp; | struct nfsclowner *owp; | ||||
struct nfscllockowner *lp; | struct nfscllockowner *lp; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
struct nfsnode *np; | struct nfsnode *np; | ||||
int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; | int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
np = VTONFS(vp); | np = VTONFS(vp); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
* Loop around waiting for: | * Loop around waiting for: | ||||
* - outstanding I/O operations on delegations to complete | * - outstanding I/O operations on delegations to complete | ||||
* - for a delegation on vp that has state, lock the client and | * - for a delegation on vp that has state, lock the client and | ||||
* do a recall | * do a recall | ||||
* - return delegation with no state | * - return delegation with no state | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | nfscl_renamedeleg(vnode_t fvp, nfsv4stateid_t *fstp, int *gotfdp, vnode_t tvp, | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsclowner *owp; | struct nfsclowner *owp; | ||||
struct nfscllockowner *lp; | struct nfscllockowner *lp; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
struct ucred *cred; | struct ucred *cred; | ||||
struct nfsnode *np; | struct nfsnode *np; | ||||
int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; | int igotlock = 0, triedrecall = 0, needsrecall, retcnt = 0, islept; | ||||
nmp = VFSTONFS(vnode_mount(fvp)); | nmp = VFSTONFS(fvp->v_mount); | ||||
*gotfdp = 0; | *gotfdp = 0; | ||||
*gottdp = 0; | *gottdp = 0; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
/* | /* | ||||
* Loop around waiting for: | * Loop around waiting for: | ||||
* - outstanding I/O operations on delegations to complete | * - outstanding I/O operations on delegations to complete | ||||
* - for a delegation on fvp that has state, lock the client and | * - for a delegation on fvp that has state, lock the client and | ||||
* do a recall | * do a recall | ||||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
nfscl_reclaimnode(vnode_t vp) | nfscl_reclaimnode(vnode_t vp) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np = VTONFS(vp); | struct nfsnode *np = VTONFS(vp); | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return; | return; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return; | return; | ||||
} | } | ||||
Show All 10 Lines | |||||
void | void | ||||
nfscl_newnode(vnode_t vp) | nfscl_newnode(vnode_t vp) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np = VTONFS(vp); | struct nfsnode *np = VTONFS(vp); | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return; | return; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return; | return; | ||||
} | } | ||||
Show All 10 Lines | |||||
void | void | ||||
nfscl_delegmodtime(vnode_t vp) | nfscl_delegmodtime(vnode_t vp) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np = VTONFS(vp); | struct nfsnode *np = VTONFS(vp); | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return; | return; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return; | return; | ||||
} | } | ||||
Show All 12 Lines | |||||
void | void | ||||
nfscl_deleggetmodtime(vnode_t vp, struct timespec *mtime) | nfscl_deleggetmodtime(vnode_t vp, struct timespec *mtime) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscldeleg *dp; | struct nfscldeleg *dp; | ||||
struct nfsnode *np = VTONFS(vp); | struct nfsnode *np = VTONFS(vp); | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
nmp = VFSTONFS(vnode_mount(vp)); | nmp = VFSTONFS(vp->v_mount); | ||||
if (!NFSHASNFSV4(nmp)) | if (!NFSHASNFSV4(nmp)) | ||||
return; | return; | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nfscl_findcl(nmp); | clp = nfscl_findcl(nmp); | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static void | static void | ||||
nfscl_retoncloselayout(vnode_t vp, struct nfsclclient *clp, uint8_t *fhp, | nfscl_retoncloselayout(vnode_t vp, struct nfsclclient *clp, uint8_t *fhp, | ||||
int fhlen, struct nfsclrecalllayout **recallpp) | int fhlen, struct nfsclrecalllayout **recallpp) | ||||
{ | { | ||||
struct nfscllayout *lyp; | struct nfscllayout *lyp; | ||||
uint32_t iomode; | uint32_t iomode; | ||||
if (vp->v_type != VREG || !NFSHASPNFS(VFSTONFS(vnode_mount(vp))) || | if (vp->v_type != VREG || !NFSHASPNFS(VFSTONFS(vp->v_mount)) || | ||||
nfscl_enablecallb == 0 || nfs_numnfscbd == 0 || | nfscl_enablecallb == 0 || nfs_numnfscbd == 0 || | ||||
(VTONFS(vp)->n_flag & NNOLAYOUT) != 0) | (VTONFS(vp)->n_flag & NNOLAYOUT) != 0) | ||||
return; | return; | ||||
lyp = nfscl_findlayout(clp, fhp, fhlen); | lyp = nfscl_findlayout(clp, fhp, fhlen); | ||||
if (lyp != NULL && (lyp->nfsly_flags & (NFSLY_RETONCLOSE | | if (lyp != NULL && (lyp->nfsly_flags & (NFSLY_RETONCLOSE | | ||||
NFSLY_RECALL)) == NFSLY_RETONCLOSE) { | NFSLY_RECALL)) == NFSLY_RETONCLOSE) { | ||||
iomode = 0; | iomode = 0; | ||||
if (!LIST_EMPTY(&lyp->nfsly_flayread)) | if (!LIST_EMPTY(&lyp->nfsly_flayread)) | ||||
▲ Show 20 Lines • Show All 457 Lines • ▼ Show 20 Lines | |||||
nfscl_layoutcommit(vnode_t vp, NFSPROC_T *p) | nfscl_layoutcommit(vnode_t vp, NFSPROC_T *p) | ||||
{ | { | ||||
struct nfsclclient *clp; | struct nfsclclient *clp; | ||||
struct nfscllayout *lyp; | struct nfscllayout *lyp; | ||||
struct nfsnode *np = VTONFS(vp); | struct nfsnode *np = VTONFS(vp); | ||||
mount_t mp; | mount_t mp; | ||||
struct nfsmount *nmp; | struct nfsmount *nmp; | ||||
mp = vnode_mount(vp); | mp = vp->v_mount; | ||||
nmp = VFSTONFS(mp); | nmp = VFSTONFS(mp); | ||||
if (NFSHASNOLAYOUTCOMMIT(nmp)) | if (NFSHASNOLAYOUTCOMMIT(nmp)) | ||||
return (0); | return (0); | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
clp = nmp->nm_clp; | clp = nmp->nm_clp; | ||||
if (clp == NULL) { | if (clp == NULL) { | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
return (EPERM); | return (EPERM); | ||||
Show All 25 Lines |