Lines Matching full:stp
145 static void nfsrv_freeopenowner(struct nfsstate *stp, int cansleep,
147 static void nfsrv_freeopen(struct nfsstate *stp, vnode_t vp, int cansleep,
149 static void nfsrv_freelockowner(struct nfsstate *stp, vnode_t vp, int cansleep,
151 static void nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp,
165 struct nfslock *insert_lop, struct nfsstate *stp, struct nfslockfile *lfp);
166 static void nfsrv_updatelock(struct nfsstate *stp, struct nfslock **new_lopp,
186 static int nfsrv_delegconflict(struct nfsstate *stp, int *haslockp,
193 static void nfsrv_delaydelegtimeout(struct nfsstate *stp);
195 struct nfsstate *stp, struct nfsrvcache *op);
196 static int nfsrv_nootherstate(struct nfsstate *stp);
305 struct nfsstate *stp, *tstp; in nfsrv_setclient() local
458 LIST_FOREACH(stp, &clp->lc_open, ls_list) { in nfsrv_setclient()
459 if (!LIST_EMPTY(&stp->ls_open)) { in nfsrv_setclient()
666 struct nfsstate *stp; in nfsrv_getclient() local
815 LIST_FOREACH(stp, &clp->lc_deleg, ls_list) in nfsrv_getclient()
816 stp->ls_flags |= NFSLCK_OLDDELEG; in nfsrv_getclient()
876 LIST_FOREACH(stp, &clp->lc_stateid[i], ls_hash) { in nfsrv_getclient()
877 if ((stp->ls_flags & NFSLCK_OPEN) && in nfsrv_getclient()
878 stp->ls_uid == nd->nd_cred->cr_uid) { in nfsrv_getclient()
1102 struct nfsstate *stp, *openstp, *lckownstp; in nfsrv_dumpaclient() local
1138 LIST_FOREACH(stp, &clp->lc_open, ls_list) { in nfsrv_dumpaclient()
1140 LIST_FOREACH(openstp, &stp->ls_open, ls_list) { in nfsrv_dumpaclient()
1154 LIST_FOREACH(stp, &clp->lc_deleg, ls_list) { in nfsrv_dumpaclient()
1157 LIST_FOREACH(stp, &clp->lc_olddeleg, ls_list) { in nfsrv_dumpaclient()
1169 struct nfsstate *stp; in nfsrv_dumplocks() local
1206 stp = LIST_FIRST(&lfp->lf_open); in nfsrv_dumplocks()
1207 while (stp != LIST_END(&lfp->lf_open) && cnt < maxcnt) { in nfsrv_dumplocks()
1208 ldumpp[cnt].ndlck_flags = stp->ls_flags; in nfsrv_dumplocks()
1209 ldumpp[cnt].ndlck_stateid.seqid = stp->ls_stateid.seqid; in nfsrv_dumplocks()
1210 ldumpp[cnt].ndlck_stateid.other[0] = stp->ls_stateid.other[0]; in nfsrv_dumplocks()
1211 ldumpp[cnt].ndlck_stateid.other[1] = stp->ls_stateid.other[1]; in nfsrv_dumplocks()
1212 ldumpp[cnt].ndlck_stateid.other[2] = stp->ls_stateid.other[2]; in nfsrv_dumplocks()
1214 stp->ls_openowner->ls_ownerlen; in nfsrv_dumplocks()
1215 NFSBCOPY(stp->ls_openowner->ls_owner, in nfsrv_dumplocks()
1217 stp->ls_openowner->ls_ownerlen); in nfsrv_dumplocks()
1218 ldumpp[cnt].ndlck_clid.nclid_idlen = stp->ls_clp->lc_idlen; in nfsrv_dumplocks()
1219 NFSBCOPY(stp->ls_clp->lc_id, ldumpp[cnt].ndlck_clid.nclid_id, in nfsrv_dumplocks()
1220 stp->ls_clp->lc_idlen); in nfsrv_dumplocks()
1221 af = stp->ls_clp->lc_req.nr_nam->sa_family; in nfsrv_dumplocks()
1226 rin = (struct sockaddr_in *)stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1233 stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1238 stp = LIST_NEXT(stp, ls_file); in nfsrv_dumplocks()
1247 stp = lop->lo_stp; in nfsrv_dumplocks()
1251 ldumpp[cnt].ndlck_stateid.seqid = stp->ls_stateid.seqid; in nfsrv_dumplocks()
1252 ldumpp[cnt].ndlck_stateid.other[0] = stp->ls_stateid.other[0]; in nfsrv_dumplocks()
1253 ldumpp[cnt].ndlck_stateid.other[1] = stp->ls_stateid.other[1]; in nfsrv_dumplocks()
1254 ldumpp[cnt].ndlck_stateid.other[2] = stp->ls_stateid.other[2]; in nfsrv_dumplocks()
1255 ldumpp[cnt].ndlck_owner.nclid_idlen = stp->ls_ownerlen; in nfsrv_dumplocks()
1256 NFSBCOPY(stp->ls_owner, ldumpp[cnt].ndlck_owner.nclid_id, in nfsrv_dumplocks()
1257 stp->ls_ownerlen); in nfsrv_dumplocks()
1258 ldumpp[cnt].ndlck_clid.nclid_idlen = stp->ls_clp->lc_idlen; in nfsrv_dumplocks()
1259 NFSBCOPY(stp->ls_clp->lc_id, ldumpp[cnt].ndlck_clid.nclid_id, in nfsrv_dumplocks()
1260 stp->ls_clp->lc_idlen); in nfsrv_dumplocks()
1261 af = stp->ls_clp->lc_req.nr_nam->sa_family; in nfsrv_dumplocks()
1266 rin = (struct sockaddr_in *)stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1273 stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1285 stp = LIST_FIRST(&lfp->lf_deleg); in nfsrv_dumplocks()
1286 while (stp != LIST_END(&lfp->lf_deleg) && cnt < maxcnt) { in nfsrv_dumplocks()
1287 ldumpp[cnt].ndlck_flags = stp->ls_flags; in nfsrv_dumplocks()
1288 ldumpp[cnt].ndlck_stateid.seqid = stp->ls_stateid.seqid; in nfsrv_dumplocks()
1289 ldumpp[cnt].ndlck_stateid.other[0] = stp->ls_stateid.other[0]; in nfsrv_dumplocks()
1290 ldumpp[cnt].ndlck_stateid.other[1] = stp->ls_stateid.other[1]; in nfsrv_dumplocks()
1291 ldumpp[cnt].ndlck_stateid.other[2] = stp->ls_stateid.other[2]; in nfsrv_dumplocks()
1293 ldumpp[cnt].ndlck_clid.nclid_idlen = stp->ls_clp->lc_idlen; in nfsrv_dumplocks()
1294 NFSBCOPY(stp->ls_clp->lc_id, ldumpp[cnt].ndlck_clid.nclid_id, in nfsrv_dumplocks()
1295 stp->ls_clp->lc_idlen); in nfsrv_dumplocks()
1296 af = stp->ls_clp->lc_req.nr_nam->sa_family; in nfsrv_dumplocks()
1301 rin = (struct sockaddr_in *)stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1308 stp->ls_clp->lc_req.nr_nam; in nfsrv_dumplocks()
1313 stp = LIST_NEXT(stp, ls_file); in nfsrv_dumplocks()
1342 struct nfsstate *stp, *nstp; in nfsrv_servertimer() local
1430 stp = LIST_FIRST(&clp->lc_open); in nfsrv_servertimer()
1431 while (stp != LIST_END(&clp->lc_open)) { in nfsrv_servertimer()
1432 nstp = LIST_NEXT(stp, ls_list); in nfsrv_servertimer()
1433 if (LIST_EMPTY(&stp->ls_open)) { in nfsrv_servertimer()
1434 stp->ls_noopens++; in nfsrv_servertimer()
1435 if (stp->ls_noopens > NFSNOOPEN || in nfsrv_servertimer()
1441 stp->ls_noopens = 0; in nfsrv_servertimer()
1443 stp = nstp; in nfsrv_servertimer()
1468 struct nfsstate *stp, *nstp; in nfsrv_cleanclient() local
1471 LIST_FOREACH_SAFE(stp, &clp->lc_open, ls_list, nstp) { in nfsrv_cleanclient()
1473 nfsrv_freeopenowner(stp, 0, p); in nfsrv_cleanclient()
1475 nfsrv_freeopenowner(stp, 1, p); in nfsrv_cleanclient()
1524 struct nfsstate *stp, *nstp; in nfsrv_freedeleglist() local
1526 LIST_FOREACH_SAFE(stp, sthp, ls_list, nstp) { in nfsrv_freedeleglist()
1527 nfsrv_freedeleg(stp); in nfsrv_freedeleglist()
1536 nfsrv_freedeleg(struct nfsstate *stp) in nfsrv_freedeleg() argument
1540 LIST_REMOVE(stp, ls_hash); in nfsrv_freedeleg()
1541 LIST_REMOVE(stp, ls_list); in nfsrv_freedeleg()
1542 LIST_REMOVE(stp, ls_file); in nfsrv_freedeleg()
1543 if ((stp->ls_flags & NFSLCK_DELEGWRITE) != 0) in nfsrv_freedeleg()
1545 lfp = stp->ls_lfp; in nfsrv_freedeleg()
1552 free(stp, M_NFSDSTATE); in nfsrv_freedeleg()
1562 nfsrv_freeopenowner(struct nfsstate *stp, int cansleep, NFSPROC_T *p) in nfsrv_freeopenowner() argument
1566 LIST_REMOVE(stp, ls_list); in nfsrv_freeopenowner()
1570 nstp = LIST_FIRST(&stp->ls_open); in nfsrv_freeopenowner()
1571 while (nstp != LIST_END(&stp->ls_open)) { in nfsrv_freeopenowner()
1576 if (stp->ls_op) in nfsrv_freeopenowner()
1577 nfsrvd_derefcache(stp->ls_op); in nfsrv_freeopenowner()
1578 free(stp, M_NFSDSTATE); in nfsrv_freeopenowner()
1590 nfsrv_freeopen(struct nfsstate *stp, vnode_t vp, int cansleep, NFSPROC_T *p) in nfsrv_freeopen() argument
1595 LIST_REMOVE(stp, ls_hash); in nfsrv_freeopen()
1596 LIST_REMOVE(stp, ls_list); in nfsrv_freeopen()
1597 LIST_REMOVE(stp, ls_file); in nfsrv_freeopen()
1599 lfp = stp->ls_lfp; in nfsrv_freeopen()
1605 LIST_FOREACH_SAFE(tstp, &stp->ls_open, ls_list, nstp) in nfsrv_freeopen()
1621 nfsrv_freeallnfslocks(stp, vp, cansleep, p); in nfsrv_freeopen()
1639 free(stp, M_NFSDSTATE); in nfsrv_freeopen()
1648 nfsrv_freelockowner(struct nfsstate *stp, vnode_t vp, int cansleep, in nfsrv_freelockowner() argument
1652 LIST_REMOVE(stp, ls_hash); in nfsrv_freelockowner()
1653 LIST_REMOVE(stp, ls_list); in nfsrv_freelockowner()
1655 nfsrv_freeallnfslocks(stp, vp, cansleep, p); in nfsrv_freelockowner()
1656 if (stp->ls_op) in nfsrv_freelockowner()
1657 nfsrvd_derefcache(stp->ls_op); in nfsrv_freelockowner()
1658 free(stp, M_NFSDSTATE); in nfsrv_freelockowner()
1667 nfsrv_freeallnfslocks(struct nfsstate *stp, vnode_t vp, int cansleep, in nfsrv_freeallnfslocks() argument
1679 lop = LIST_FIRST(&stp->ls_lock); in nfsrv_freeallnfslocks()
1680 while (lop != LIST_END(&stp->ls_lock)) { in nfsrv_freeallnfslocks()
1760 struct nfsstate *stp; in nfsrv_getstate() local
1766 LIST_FOREACH(stp, hp, ls_hash) { in nfsrv_getstate()
1767 if (!NFSBCMP(stp->ls_stateid.other, stateidp->other, in nfsrv_getstate()
1775 if (stp == LIST_END(hp)) { in nfsrv_getstate()
1779 *stpp = stp; in nfsrv_getstate()
1793 struct nfsstate *stp; in nfsrv_getowner() local
1796 LIST_FOREACH(stp, hp, ls_list) { in nfsrv_getowner()
1797 if (new_stp->ls_ownerlen == stp->ls_ownerlen && in nfsrv_getowner()
1798 !NFSBCMP(new_stp->ls_owner,stp->ls_owner,stp->ls_ownerlen)) { in nfsrv_getowner()
1799 *stpp = stp; in nfsrv_getowner()
1830 struct nfsstate *stp, *lckstp = NULL; in nfsrv_lockctrl() local
1963 new_stp->ls_flags, &stp); in nfsrv_lockctrl()
1968 if (error == 0 && (stp->ls_flags & NFSLCK_OPEN) && in nfsrv_lockctrl()
1969 ((stp->ls_openowner->ls_flags & NFSLCK_NEEDSCONFIRM) || in nfsrv_lockctrl()
1970 (getlckret == 0 && stp->ls_lfp != lfp))){ in nfsrv_lockctrl()
1981 (stp->ls_flags & (NFSLCK_DELEGREAD | NFSLCK_DELEGWRITE)) && in nfsrv_lockctrl()
1982 getlckret == 0 && stp->ls_lfp != lfp) in nfsrv_lockctrl()
1993 if (error == 0 && (stp->ls_flags & in nfsrv_lockctrl()
1995 getlckret == 0 && stp->ls_lfp != lfp) { in nfsrv_lockctrl()
2010 if (stp->ls_flags & NFSLCK_OPEN) in nfsrv_lockctrl()
2012 stp->ls_openowner, new_stp->ls_op); in nfsrv_lockctrl()
2017 nfsrv_getowner(&stp->ls_open, new_stp, &lckstp); in nfsrv_lockctrl()
2038 if (stp->ls_flags & NFSLCK_OPEN) in nfsrv_lockctrl()
2042 stp, new_stp->ls_op); in nfsrv_lockctrl()
2044 lckstp = stp; in nfsrv_lockctrl()
2046 lckstp = stp; in nfsrv_lockctrl()
2059 if (!error && stp->ls_stateid.seqid!=new_stp->ls_stateid.seqid && in nfsrv_lockctrl()
2161 if (stp->ls_flags & (NFSLCK_DELEGREAD | NFSLCK_DELEGWRITE)) { in nfsrv_lockctrl()
2163 mystp = stp; in nfsrv_lockctrl()
2164 nfsrv_delaydelegtimeout(stp); in nfsrv_lockctrl()
2165 } else if (stp->ls_flags & NFSLCK_OPEN) { in nfsrv_lockctrl()
2166 mystp = stp; in nfsrv_lockctrl()
2168 mystp = stp->ls_openstp; in nfsrv_lockctrl()
2346 nfsrv_updatelock(stp, new_lopp, &other_lop, lfp); in nfsrv_lockctrl()
2347 stateidp->seqid = ++(stp->ls_stateid.seqid); in nfsrv_lockctrl()
2349 stateidp->seqid = stp->ls_stateid.seqid = 1; in nfsrv_lockctrl()
2350 stateidp->other[0] = stp->ls_stateid.other[0]; in nfsrv_lockctrl()
2351 stateidp->other[1] = stp->ls_stateid.other[1]; in nfsrv_lockctrl()
2352 stateidp->other[2] = stp->ls_stateid.other[2]; in nfsrv_lockctrl()
2503 new_stp->ls_openstp = stp; in nfsrv_lockctrl()
2509 LIST_INSERT_HEAD(&stp->ls_open, new_stp, ls_list); in nfsrv_lockctrl()
2550 struct nfsstate *stp, *nstp; in nfsrv_opencheck() local
2679 LIST_FOREACH(stp, &lfp->lf_deleg, ls_file) { in nfsrv_opencheck()
2680 if (!(stp->ls_flags & NFSLCK_OLDDELEG) && in nfsrv_opencheck()
2683 stateidp->seqid == stp->ls_stateid.seqid) && in nfsrv_opencheck()
2684 !NFSBCMP(stateidp->other, stp->ls_stateid.other, in nfsrv_opencheck()
2688 if (stp == LIST_END(&lfp->lf_deleg) || in nfsrv_opencheck()
2690 (stp->ls_flags & NFSLCK_DELEGREAD))) { in nfsrv_opencheck()
2706 LIST_FOREACH(stp, &lfp->lf_open, ls_file) { in nfsrv_opencheck()
2709 ((stp->ls_flags>>NFSLCK_SHIFT) & NFSLCK_ACCESSBITS))|| in nfsrv_opencheck()
2710 ((stp->ls_flags & NFSLCK_ACCESSBITS) & in nfsrv_opencheck()
2712 ret = nfsrv_clientconflict(stp->ls_clp,&haslock,vp,p); in nfsrv_opencheck()
2761 stp = LIST_FIRST(&lfp->lf_deleg); in nfsrv_opencheck()
2762 while (stp != LIST_END(&lfp->lf_deleg)) { in nfsrv_opencheck()
2763 nstp = LIST_NEXT(stp, ls_file); in nfsrv_opencheck()
2764 if ((readonly && stp->ls_clp != clp && in nfsrv_opencheck()
2765 (stp->ls_flags & NFSLCK_DELEGWRITE) != 0) || in nfsrv_opencheck()
2766 (!readonly && (stp->ls_clp != clp || in nfsrv_opencheck()
2767 ((stp->ls_flags & NFSLCK_DELEGREAD) != 0 && in nfsrv_opencheck()
2769 ret = nfsrv_delegconflict(stp, &haslock, p, vp); in nfsrv_opencheck()
2781 stp = nstp; in nfsrv_opencheck()
2806 struct nfsstate *stp, *nstp; in nfsrv_openctrl() local
2944 LIST_FOREACH(stp, &lfp->lf_deleg, ls_file) { in nfsrv_openctrl()
2945 if (!(stp->ls_flags & NFSLCK_OLDDELEG) && in nfsrv_openctrl()
2948 stateidp->seqid == stp->ls_stateid.seqid) && in nfsrv_openctrl()
2949 !NFSBCMP(stateidp->other, stp->ls_stateid.other, in nfsrv_openctrl()
2953 if (stp == LIST_END(&lfp->lf_deleg) || in nfsrv_openctrl()
2955 (stp->ls_flags & NFSLCK_DELEGREAD))) { in nfsrv_openctrl()
2974 nfsrv_delaydelegtimeout(stp); in nfsrv_openctrl()
2984 LIST_FOREACH(stp, &lfp->lf_open, ls_file) { in nfsrv_openctrl()
2985 if (ownerstp && stp->ls_openowner == ownerstp) in nfsrv_openctrl()
2986 openstp = stp; in nfsrv_openctrl()
2993 if (clp != stp->ls_clp) { in nfsrv_openctrl()
2994 if ((stp->ls_flags & NFSLCK_SHAREBITS) == in nfsrv_openctrl()
3001 ((stp->ls_flags>>NFSLCK_SHIFT) & NFSLCK_ACCESSBITS))|| in nfsrv_openctrl()
3002 ((stp->ls_flags & NFSLCK_ACCESSBITS) & in nfsrv_openctrl()
3004 ret = nfsrv_clientconflict(stp->ls_clp,&haslock,vp,p); in nfsrv_openctrl()
3057 stp = LIST_FIRST(&lfp->lf_deleg); in nfsrv_openctrl()
3058 while (stp != LIST_END(&lfp->lf_deleg)) { in nfsrv_openctrl()
3059 nstp = LIST_NEXT(stp, ls_file); in nfsrv_openctrl()
3060 if (stp->ls_clp != clp && (stp->ls_flags & NFSLCK_DELEGREAD)) in nfsrv_openctrl()
3062 else if (stp->ls_clp != clp || in nfsrv_openctrl()
3063 (stp->ls_flags & NFSLCK_DELEGWRITE) != 0 || in nfsrv_openctrl()
3066 if ((readonly && stp->ls_clp != clp && in nfsrv_openctrl()
3067 (stp->ls_flags & NFSLCK_DELEGWRITE) != 0) || in nfsrv_openctrl()
3068 (!readonly && (stp->ls_clp != clp || in nfsrv_openctrl()
3069 ((stp->ls_flags & NFSLCK_DELEGREAD) != 0 && in nfsrv_openctrl()
3074 ret = nfsrv_delegconflict(stp, &haslock, p, vp); in nfsrv_openctrl()
3092 stp = nstp; in nfsrv_openctrl()
3110 LIST_FOREACH(stp, &clp->lc_olddeleg, ls_list) { in nfsrv_openctrl()
3111 if (stp->ls_lfp == lfp) { in nfsrv_openctrl()
3113 if (stp->ls_clp != clp) in nfsrv_openctrl()
3115 LIST_REMOVE(stp, ls_list); in nfsrv_openctrl()
3116 LIST_REMOVE(stp, ls_hash); in nfsrv_openctrl()
3117 stp->ls_flags &= ~NFSLCK_OLDDELEG; in nfsrv_openctrl()
3118 stp->ls_stateid.seqid = delegstateidp->seqid = 1; in nfsrv_openctrl()
3119 stp->ls_stateid.other[0] = delegstateidp->other[0] = in nfsrv_openctrl()
3121 stp->ls_stateid.other[1] = delegstateidp->other[1] = in nfsrv_openctrl()
3123 stp->ls_stateid.other[2] = delegstateidp->other[2] = in nfsrv_openctrl()
3125 stp->ls_compref = nd->nd_compref; in nfsrv_openctrl()
3126 LIST_INSERT_HEAD(&clp->lc_deleg, stp, ls_list); in nfsrv_openctrl()
3128 stp->ls_stateid), stp, ls_hash); in nfsrv_openctrl()
3129 if (stp->ls_flags & NFSLCK_DELEGWRITE) in nfsrv_openctrl()
3145 if (stp->ls_flags & NFSLCK_DELEGWRITE) in nfsrv_openctrl()
3182 if (stp == LIST_END(&clp->lc_olddeleg)) in nfsrv_openctrl()
3191 LIST_FOREACH(stp, &lfp->lf_deleg, ls_file) { in nfsrv_openctrl()
3192 if (stp->ls_clp == clp) in nfsrv_openctrl()
3195 if (stp == LIST_END(&lfp->lf_deleg) && openstp == NULL) { in nfsrv_openctrl()
3297 stp = LIST_FIRST(&ownerstp->ls_open); in nfsrv_openctrl()
3298 stp->ls_flags = (new_stp->ls_flags & NFSLCK_SHAREBITS) | in nfsrv_openctrl()
3300 stp->ls_stateid.seqid = 1; in nfsrv_openctrl()
3301 stp->ls_uid = new_stp->ls_uid; in nfsrv_openctrl()
3302 if (lfp != stp->ls_lfp) { in nfsrv_openctrl()
3303 LIST_REMOVE(stp, ls_file); in nfsrv_openctrl()
3304 LIST_INSERT_HEAD(&lfp->lf_open, stp, ls_file); in nfsrv_openctrl()
3305 stp->ls_lfp = lfp; in nfsrv_openctrl()
3307 openstp = stp; in nfsrv_openctrl()
3448 struct nfsstate *stp; in nfsrv_openupdate() local
3471 new_stp->ls_flags, &stp); in nfsrv_openupdate()
3476 if (!error && (!(stp->ls_flags & NFSLCK_OPEN) || in nfsrv_openupdate()
3478 (stp->ls_openowner->ls_flags & NFSLCK_NEEDSCONFIRM)) || in nfsrv_openupdate()
3480 (!(stp->ls_openowner->ls_flags & NFSLCK_NEEDSCONFIRM))))) in nfsrv_openupdate()
3485 stp->ls_openowner, new_stp->ls_op); in nfsrv_openupdate()
3486 if (!error && stp->ls_stateid.seqid != new_stp->ls_stateid.seqid && in nfsrv_openupdate()
3508 nfsrv_nootherstate(stp)) in nfsrv_openupdate()
3509 nfsrv_freeopenowner(stp->ls_openowner, 0, p); in nfsrv_openupdate()
3517 stateidp->seqid = stp->ls_stateid.seqid + 1; in nfsrv_openupdate()
3520 stateidp->other[0] = stp->ls_stateid.other[0]; in nfsrv_openupdate()
3521 stateidp->other[1] = stp->ls_stateid.other[1]; in nfsrv_openupdate()
3522 stateidp->other[2] = stp->ls_stateid.other[2]; in nfsrv_openupdate()
3531 if (!(stp->ls_openowner->ls_flags & NFSLCK_NEEDSCONFIRM)) in nfsrv_openupdate()
3533 stp->ls_openowner->ls_flags = 0; in nfsrv_openupdate()
3534 stp->ls_stateid.seqid++; in nfsrv_openupdate()
3536 stp->ls_stateid.seqid == 0) in nfsrv_openupdate()
3537 stp->ls_stateid.seqid = 1; in nfsrv_openupdate()
3546 if ((stp->ls_flags & NFSLCK_WRITEACCESS) != 0) in nfsrv_openupdate()
3551 if (nfsrv_dolocallocks != 0 && !LIST_EMPTY(&stp->ls_open)) { in nfsrv_openupdate()
3553 nfsrv_freeopen(stp, vp, 1, p); in nfsrv_openupdate()
3555 nfsrv_freeopen(stp, NULL, 0, p); in nfsrv_openupdate()
3563 if (~(stp->ls_flags) & bits) { in nfsrv_openupdate()
3568 stp->ls_flags = (bits | NFSLCK_OPEN); in nfsrv_openupdate()
3569 stp->ls_stateid.seqid++; in nfsrv_openupdate()
3571 stp->ls_stateid.seqid == 0) in nfsrv_openupdate()
3572 stp->ls_stateid.seqid = 1; in nfsrv_openupdate()
3599 struct nfsstate *stp; in nfsrv_delegupdate() local
3636 error = nfsrv_getstate(clp, stateidp, NFSLCK_DELEGRETURN, &stp); in nfsrv_delegupdate()
3637 if (!error && stp->ls_stateid.seqid != stateidp->seqid && in nfsrv_delegupdate()
3656 if (NFSBCMP((caddr_t)&fh, (caddr_t)&stp->ls_lfp->lf_fh, in nfsrv_delegupdate()
3663 if ((stp->ls_flags & NFSLCK_DELEGWRITE) != 0) in nfsrv_delegupdate()
3668 nfsrv_freedeleg(stp); in nfsrv_delegupdate()
3687 struct nfsstate *stp, *nstp, *openstp, *ownstp; in nfsrv_releaselckown() local
3711 stp = LIST_FIRST(&openstp->ls_open); in nfsrv_releaselckown()
3712 while (stp != LIST_END(&openstp->ls_open)) { in nfsrv_releaselckown()
3713 nstp = LIST_NEXT(stp, ls_list); in nfsrv_releaselckown()
3718 if (stp->ls_ownerlen == new_stp->ls_ownerlen && in nfsrv_releaselckown()
3719 !NFSBCMP(stp->ls_owner, new_stp->ls_owner, in nfsrv_releaselckown()
3720 stp->ls_ownerlen)){ in nfsrv_releaselckown()
3721 if (LIST_EMPTY(&stp->ls_lock)) { in nfsrv_releaselckown()
3722 nfsrv_freelockowner(stp, NULL, 0, p); in nfsrv_releaselckown()
3729 stp = nstp; in nfsrv_releaselckown()
3831 struct nfsstate *stp, struct nfslockfile *lfp) in nfsrv_insertlock() argument
3835 new_lop->lo_stp = stp; in nfsrv_insertlock()
3838 if (stp != NULL) { in nfsrv_insertlock()
3858 * Insert after insert_lop, which is overloaded as stp or lfp for in nfsrv_insertlock()
3861 if (stp == NULL && (struct nfslockfile *)insert_lop == lfp) in nfsrv_insertlock()
3863 else if ((struct nfsstate *)insert_lop == stp) in nfsrv_insertlock()
3864 LIST_INSERT_HEAD(&stp->ls_lock, new_lop, lo_lckowner); in nfsrv_insertlock()
3867 if (stp != NULL) { in nfsrv_insertlock()
3881 nfsrv_updatelock(struct nfsstate *stp, struct nfslock **new_lopp, in nfsrv_updatelock() argument
3895 if (stp != NULL) { in nfsrv_updatelock()
3896 ilop = (struct nfslock *)stp; in nfsrv_updatelock()
3897 lop = LIST_FIRST(&stp->ls_lock); in nfsrv_updatelock()
3987 other_lop->lo_stp = stp; in nfsrv_updatelock()
3990 nfsrv_insertlock(other_lop, lop, stp, lfp); in nfsrv_updatelock()
4006 nfsrv_insertlock(new_lop, ilop, stp, lfp); in nfsrv_updatelock()
4017 struct nfsstate *stp, struct nfsrvcache *op) in nfsrv_checkseqid() argument
4028 if (stp->ls_op && stp->ls_op->rc_refcnt <= 0) { in nfsrv_checkseqid()
4029 printf("refcnt=%d\n", stp->ls_op->rc_refcnt); in nfsrv_checkseqid()
4037 if ((stp->ls_seq + 1) == seqid) { in nfsrv_checkseqid()
4038 if (stp->ls_op) in nfsrv_checkseqid()
4039 nfsrvd_derefcache(stp->ls_op); in nfsrv_checkseqid()
4040 stp->ls_op = op; in nfsrv_checkseqid()
4042 stp->ls_seq = seqid; in nfsrv_checkseqid()
4044 } else if (stp->ls_seq == seqid && stp->ls_op && in nfsrv_checkseqid()
4045 op->rc_xid == stp->ls_op->rc_xid && in nfsrv_checkseqid()
4047 op->rc_reqlen == stp->ls_op->rc_reqlen && in nfsrv_checkseqid()
4048 op->rc_cksum == stp->ls_op->rc_cksum) { in nfsrv_checkseqid()
4049 if (stp->ls_op->rc_flag & RC_INPROG) { in nfsrv_checkseqid()
4053 nd->nd_rp = stp->ls_op; in nfsrv_checkseqid()
4760 struct nfsstate *stp; in nfsrv_nextstateindex() local
4777 LIST_FOREACH(stp, &clp->lc_stateid[i], ls_hash) { in nfsrv_nextstateindex()
4778 if (stp->ls_stateid.other[2] > 0x80000000) { in nfsrv_nextstateindex()
4779 if (stp->ls_stateid.other[2] < max_index) in nfsrv_nextstateindex()
4780 max_index = stp->ls_stateid.other[2]; in nfsrv_nextstateindex()
4782 if (stp->ls_stateid.other[2] > min_index) in nfsrv_nextstateindex()
4783 min_index = stp->ls_stateid.other[2]; in nfsrv_nextstateindex()
4801 LIST_FOREACH(stp, &clp->lc_stateid[i], ls_hash) { in nfsrv_nextstateindex()
4802 if (stp->ls_stateid.other[2] == canuse) { in nfsrv_nextstateindex()
5268 nfsrv_delegconflict(struct nfsstate *stp, int *haslockp, NFSPROC_T *p, in nfsrv_delegconflict() argument
5271 struct nfsclient *clp = stp->ls_clp; in nfsrv_delegconflict()
5279 if (stp->ls_flags & NFSLCK_OLDDELEG) { in nfsrv_delegconflict()
5284 nfsrv_freedeleg(stp); in nfsrv_delegconflict()
5311 if ((stp->ls_flags & NFSLCK_DELEGRECALL) == 0 || (stp->ls_lastrecall < in nfsrv_delegconflict()
5313 stp->ls_delegtime >= NFSD_MONOSEC)) { in nfsrv_delegconflict()
5328 if ((stp->ls_flags & NFSLCK_DELEGRECALL) == 0) { in nfsrv_delegconflict()
5329 stp->ls_delegtime = NFSD_MONOSEC + (2 * nfsrv_lease) + in nfsrv_delegconflict()
5331 stp->ls_delegtimelimit = NFSD_MONOSEC + (6 * in nfsrv_delegconflict()
5333 stp->ls_flags |= NFSLCK_DELEGRECALL; in nfsrv_delegconflict()
5335 stp->ls_lastrecall = time_uptime + 1; in nfsrv_delegconflict()
5343 * Since nfsrv_docallback will sleep, don't use stp after in nfsrv_delegconflict()
5346 NFSBCOPY((caddr_t)&stp->ls_stateid, (caddr_t)&tstateid, in nfsrv_delegconflict()
5348 NFSBCOPY((caddr_t)&stp->ls_lfp->lf_fh, (caddr_t)&tfh, in nfsrv_delegconflict()
5369 stp->ls_delegtime >= NFSD_MONOSEC) { in nfsrv_delegconflict()
5438 nfsrv_freedeleg(stp); in nfsrv_delegconflict()
5459 struct nfsstate *stp; in nfsrv_checkremove() local
5517 LIST_FOREACH(stp, &lfp->lf_open, ls_file) { in nfsrv_checkremove()
5518 if (stp->ls_flags & NFSLCK_WRITEDENY) { in nfsrv_checkremove()
5550 struct nfsstate *stp, *nstp; in nfsrv_cleandeleg() local
5553 stp = LIST_FIRST(&lfp->lf_deleg); in nfsrv_cleandeleg()
5554 while (stp != LIST_END(&lfp->lf_deleg)) { in nfsrv_cleandeleg()
5555 nstp = LIST_NEXT(stp, ls_file); in nfsrv_cleandeleg()
5556 if (stp->ls_clp != clp) { in nfsrv_cleandeleg()
5557 ret = nfsrv_delegconflict(stp, haslockp, p, vp); in nfsrv_cleandeleg()
5566 stp = nstp; in nfsrv_cleandeleg()
5681 struct nfsstate st, *stp = &st; in nfsrv_checksetattr() local
5687 stp->ls_flags = (NFSLCK_CHECK | NFSLCK_WRITEACCESS); in nfsrv_checksetattr()
5690 stp->ls_flags = 0; in nfsrv_checksetattr()
5697 stp->ls_flags |= NFSLCK_SETATTR; in nfsrv_checksetattr()
5698 if (stp->ls_flags == 0) in nfsrv_checksetattr()
5702 stp->ls_ownerlen = 0; in nfsrv_checksetattr()
5703 stp->ls_op = NULL; in nfsrv_checksetattr()
5704 stp->ls_uid = nd->nd_cred->cr_uid; in nfsrv_checksetattr()
5705 stp->ls_stateid.seqid = stateidp->seqid; in nfsrv_checksetattr()
5706 clientid.lval[0] = stp->ls_stateid.other[0] = stateidp->other[0]; in nfsrv_checksetattr()
5707 clientid.lval[1] = stp->ls_stateid.other[1] = stateidp->other[1]; in nfsrv_checksetattr()
5708 stp->ls_stateid.other[2] = stateidp->other[2]; in nfsrv_checksetattr()
5709 error = nfsrv_lockctrl(vp, &stp, &lop, NULL, clientid, in nfsrv_checksetattr()
5727 struct nfsstate *stp; in nfsrv_checkgetattr() local
5760 LIST_FOREACH(stp, &lfp->lf_deleg, ls_file) { in nfsrv_checkgetattr()
5761 if (stp->ls_flags & NFSLCK_DELEGWRITE) in nfsrv_checkgetattr()
5764 if (stp == LIST_END(&lfp->lf_deleg)) { in nfsrv_checkgetattr()
5768 clp = stp->ls_clp; in nfsrv_checkgetattr()
5776 delegfilerev = stp->ls_filerev; in nfsrv_checkgetattr()
5787 if (nd->nd_compref == stp->ls_compref || in nfsrv_checkgetattr()
5839 struct nfsstate *stp, *nstp; in nfsrv_throwawayopens() local
5850 LIST_FOREACH_SAFE(stp, &clp->lc_open, ls_list, nstp) { in nfsrv_throwawayopens()
5851 if (LIST_EMPTY(&stp->ls_open) && in nfsrv_throwawayopens()
5852 (stp->ls_noopens > NFSNOOPEN || in nfsrv_throwawayopens()
5855 nfsrv_freeopenowner(stp, 0, p); in nfsrv_throwawayopens()
5925 nfsrv_delaydelegtimeout(struct nfsstate *stp) in nfsrv_delaydelegtimeout() argument
5928 if ((stp->ls_flags & NFSLCK_DELEGRECALL) == 0) in nfsrv_delaydelegtimeout()
5931 if ((stp->ls_delegtime + 15) > NFSD_MONOSEC && in nfsrv_delaydelegtimeout()
5932 stp->ls_delegtime < stp->ls_delegtimelimit) { in nfsrv_delaydelegtimeout()
5933 stp->ls_delegtime += nfsrv_lease; in nfsrv_delaydelegtimeout()
5934 if (stp->ls_delegtime > stp->ls_delegtimelimit) in nfsrv_delaydelegtimeout()
5935 stp->ls_delegtime = stp->ls_delegtimelimit; in nfsrv_delaydelegtimeout()
5945 nfsrv_nootherstate(struct nfsstate *stp) in nfsrv_nootherstate() argument
5949 LIST_FOREACH(tstp, &stp->ls_openowner->ls_open, ls_list) { in nfsrv_nootherstate()
5950 if (tstp != stp || !LIST_EMPTY(&tstp->ls_lock)) in nfsrv_nootherstate()
6624 struct nfsstate *stp; in nfsrv_freestateid() local
6635 LIST_FOREACH(stp, &clp->lc_deleg, ls_list) { in nfsrv_freestateid()
6636 if (!NFSBCMP(stp->ls_stateid.other, stateidp->other, in nfsrv_freestateid()
6640 if (stp != NULL) { in nfsrv_freestateid()
6641 nfsrv_freedeleg(stp); in nfsrv_freestateid()
6648 error = nfsrv_getstate(clp, stateidp, 0, &stp); in nfsrv_freestateid()
6649 if (error == 0 && ((stp->ls_flags & (NFSLCK_OPEN | NFSLCK_DELEGREAD | in nfsrv_freestateid()
6650 NFSLCK_DELEGWRITE)) != 0 || (stp->ls_flags & NFSLCK_LOCK) == 0)) in nfsrv_freestateid()
6653 if (error == 0 && !LIST_EMPTY(&stp->ls_lock)) in nfsrv_freestateid()
6656 nfsrv_freelockowner(stp, NULL, 0, p); in nfsrv_freestateid()
6669 struct nfsstate *stp; in nfsrv_teststateid() local
6679 error = nfsrv_getstate(clp, stateidp, 0, &stp); in nfsrv_teststateid()
6681 SEQ_LT(stateidp->seqid, stp->ls_stateid.seqid)) in nfsrv_teststateid()
8176 struct nfsstate *stp; in nfsrv_checkdsattr() local
8223 LIST_FOREACH(stp, &lfp->lf_deleg, ls_file) { in nfsrv_checkdsattr()
8224 if ((stp->ls_flags & NFSLCK_DELEGWRITE) != 0 && in nfsrv_checkdsattr()
8225 nfsrv_fndclid(clid, stp->ls_clp->lc_clientid, clidcnt) != 0) in nfsrv_checkdsattr()
8228 if (stp != NULL) { in nfsrv_checkdsattr()
8235 LIST_FOREACH(stp, &lfp->lf_open, ls_file) { in nfsrv_checkdsattr()
8236 KASSERT((stp->ls_flags & NFSLCK_OPEN) != 0, in nfsrv_checkdsattr()
8238 if ((stp->ls_flags & NFSLCK_WRITEACCESS) != 0 && in nfsrv_checkdsattr()
8239 nfsrv_fndclid(clid, stp->ls_clp->lc_clientid, clidcnt) != 0) in nfsrv_checkdsattr()
8243 if (stp != NULL) in nfsrv_checkdsattr()