Lines Matching refs:req

1653 	struct nfsreq *req;
1700 ((req = TAILQ_FIRST(&nmp->nm_resendq)))) {
1701 if (req->r_resendtime)
1703 while (req && !(nmp->nm_state & NFSSTA_FORCE) && req->r_resendtime && (now.tv_sec < req->r_resendtime))
1704 req = TAILQ_NEXT(req, r_rchain);
1705 if (!req)
1707 TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain);
1708 req->r_rchain.tqe_next = NFSREQNOLIST;
1710 lck_mtx_lock(&req->r_mtx);
1711 if (req->r_error || req->r_nmrep.nmc_mhead) {
1712 dofinish = req->r_callback.rcb_func && !(req->r_flags & R_WAITSENT);
1713 req->r_flags &= ~R_RESENDQ;
1714 wakeup(req);
1715 lck_mtx_unlock(&req->r_mtx);
1717 nfs_asyncio_finish(req);
1721 if ((req->r_flags & R_RESTART) || nfs_request_using_gss(req)) {
1722 req->r_flags &= ~R_RESTART;
1723 req->r_resendtime = 0;
1724 lck_mtx_unlock(&req->r_mtx);
1726 nfs_reqdequeue(req);
1727 if (nfs_request_using_gss(req)) {
1728 nfs_gss_clnt_rpcdone(req);
1729 error = nfs_gss_clnt_args_restore(req);
1731 req->r_xid = 0;
1734 nfs_request_using_gss(req) ? " gss" : "", req->r_procnum, req->r_xid,
1735 req->r_flags, req->r_rtt));
1736 error = !req->r_nmp ? ENXIO : 0; /* unmounted? */
1738 error = nfs_sigintr(nmp, req, req->r_thread, 0);
1740 error = nfs_request_add_header(req);
1742 error = nfs_request_send(req, 0);
1743 lck_mtx_lock(&req->r_mtx);
1744 if (req->r_flags & R_RESENDQ)
1745 req->r_flags &= ~R_RESENDQ;
1747 req->r_error = error;
1748 wakeup(req);
1749 dofinish = error && req->r_callback.rcb_func && !(req->r_flags & R_WAITSENT);
1750 lck_mtx_unlock(&req->r_mtx);
1752 nfs_asyncio_finish(req);
1758 req->r_procnum, req->r_xid, req->r_flags, req->r_rtt));
1759 error = !req->r_nmp ? ENXIO : 0; /* unmounted? */
1761 error = nfs_sigintr(nmp, req, req->r_thread, 0);
1763 req->r_flags |= R_SENDING;
1764 lck_mtx_unlock(&req->r_mtx);
1765 error = nfs_send(req, 0);
1766 lck_mtx_lock(&req->r_mtx);
1768 if (req->r_flags & R_RESENDQ)
1769 req->r_flags &= ~R_RESENDQ;
1770 wakeup(req);
1771 lck_mtx_unlock(&req->r_mtx);
1776 req->r_error = error;
1777 if (req->r_flags & R_RESENDQ)
1778 req->r_flags &= ~R_RESENDQ;
1779 wakeup(req);
1780 dofinish = req->r_callback.rcb_func && !(req->r_flags & R_WAITSENT);
1781 lck_mtx_unlock(&req->r_mtx);
1783 nfs_asyncio_finish(req);
2770 nfs_send(struct nfsreq *req, int wait)
2782 error = nfs_sndlock(req);
2784 lck_mtx_lock(&req->r_mtx);
2785 req->r_error = error;
2786 req->r_flags &= ~R_SENDING;
2787 lck_mtx_unlock(&req->r_mtx);
2791 error = nfs_sigintr(req->r_nmp, req, NULL, 0);
2793 nfs_sndunlock(req);
2794 lck_mtx_lock(&req->r_mtx);
2795 req->r_error = error;
2796 req->r_flags &= ~R_SENDING;
2797 lck_mtx_unlock(&req->r_mtx);
2800 nmp = req->r_nmp;
2807 if (((req->r_flags & R_SETUP) && !(nmp->nm_sockflags & NMSOCK_SETUP)) ||
2808 ((req->r_flags & R_RECOVER) && !(nmp->nm_sockflags & NMSOCK_READY))) {
2810 nfs_sndunlock(req);
2811 lck_mtx_lock(&req->r_mtx);
2812 req->r_error = error;
2813 req->r_flags &= ~R_SENDING;
2814 lck_mtx_unlock(&req->r_mtx);
2822 !((nmp->nm_sockflags & NMSOCK_SETUP) && (req->r_flags & R_SETUP))) {
2823 if (NMFLAG(nmp, INTR) && !(req->r_flags & R_NOINTR))
2826 nfs_sndunlock(req);
2828 lck_mtx_lock(&req->r_mtx);
2829 req->r_flags &= ~R_SENDING;
2830 req->r_flags |= R_MUSTRESEND;
2831 req->r_rtt = 0;
2832 lck_mtx_unlock(&req->r_mtx);
2835 NFS_SOCK_DBG(("nfs_send: 0x%llx wait reconnect\n", req->r_xid));
2836 lck_mtx_lock(&req->r_mtx);
2837 req->r_flags &= ~R_MUSTRESEND;
2838 req->r_rtt = 0;
2839 lck_mtx_unlock(&req->r_mtx);
2853 req->r_flags |= R_SOFTTERM;
2854 req->r_error = error = ETIMEDOUT;
2860 if ((error = nfs_sigintr(req->r_nmp, req, req->r_thread, 1)))
2862 msleep(req, &nmp->nm_lock, slpflag|PSOCK, "nfsconnectwait", &ts);
2867 lck_mtx_lock(&req->r_mtx);
2868 req->r_error = error;
2869 req->r_flags &= ~R_SENDING;
2870 lck_mtx_unlock(&req->r_mtx);
2880 nfs_sndunlock(req);
2881 lck_mtx_lock(&req->r_mtx);
2882 req->r_flags &= ~R_SENDING;
2883 req->r_flags |= R_MUSTRESEND;
2884 req->r_rtt = 0;
2885 lck_mtx_unlock(&req->r_mtx);
2889 lck_mtx_lock(&req->r_mtx);
2890 rexmit = (req->r_flags & R_SENT);
2894 if (!(req->r_flags & R_CWND) && (nmp->nm_sent >= nmp->nm_cwnd)) {
2896 slpflag = (NMFLAG(nmp, INTR) && req->r_thread) ? PCATCH : 0;
2898 nfs_sndunlock(req);
2899 req->r_flags &= ~R_SENDING;
2900 req->r_flags |= R_MUSTRESEND;
2901 lck_mtx_unlock(&req->r_mtx);
2903 req->r_rtt = 0;
2908 if ((error = nfs_sigintr(req->r_nmp, req, req->r_thread, 1)))
2910 TAILQ_INSERT_TAIL(&nmp->nm_cwndq, req, r_cchain);
2911 msleep(req, &nmp->nm_lock, slpflag | (PZERO - 1), "nfswaitcwnd", &ts);
2913 if ((req->r_cchain.tqe_next != NFSREQNOLIST)) {
2914 TAILQ_REMOVE(&nmp->nm_cwndq, req, r_cchain);
2915 req->r_cchain.tqe_next = NFSREQNOLIST;
2927 req->r_flags |= R_CWND;
2934 req->r_flags &= ~R_TIMING;
2942 req->r_flags &= ~R_MUSTRESEND;
2943 lck_mtx_unlock(&req->r_mtx);
2945 error = mbuf_copym(req->r_mhead, 0, MBUF_COPYALL,
2950 nfs_sndunlock(req);
2951 lck_mtx_lock(&req->r_mtx);
2952 req->r_flags &= ~R_SENDING;
2953 req->r_flags |= R_MUSTRESEND;
2954 req->r_rtt = 0;
2955 lck_mtx_unlock(&req->r_mtx);
2966 if (error || (sentlen != req->r_mreqlen))
2968 req->r_xid, (int)sentlen, (int)req->r_mreqlen, error));
2970 if (!error && (sentlen != req->r_mreqlen))
2972 needrecon = ((sotype == SOCK_STREAM) && sentlen && (sentlen != req->r_mreqlen));
2974 lck_mtx_lock(&req->r_mtx);
2975 req->r_flags &= ~R_SENDING;
2976 req->r_rtt = 0;
2977 if (rexmit && (++req->r_rexmit > NFS_MAXREXMIT))
2978 req->r_rexmit = NFS_MAXREXMIT;
2982 req->r_flags &= ~R_RESENDERR;
2985 req->r_flags |= R_SENT;
2986 if (req->r_flags & R_WAITSENT) {
2987 req->r_flags &= ~R_WAITSENT;
2988 wakeup(req);
2990 nfs_sndunlock(req);
2991 lck_mtx_unlock(&req->r_mtx);
2996 req->r_flags |= R_MUSTRESEND;
2998 req->r_flags |= R_RESENDERR;
3000 req->r_error = error;
3001 lck_mtx_unlock(&req->r_mtx);
3047 NFS_SOCK_DBG(("nfs_send: 0x%llx need reconnect %d\n", req->r_xid, error));
3051 nfs_sndunlock(req);
3063 !req->r_nmp ? "<unmounted>" :
3064 vfs_statfs(req->r_nmp->nm_mountp)->f_mntfromname);
3070 error2 = nfs_sigintr(req->r_nmp, req, req->r_thread, 0);
3227 struct nfsreq *req;
3247 TAILQ_FOREACH(req, &nfs_reqq, r_chain) {
3248 if (req->r_nmrep.nmc_mhead || (rxid != R_XID32(req->r_xid)))
3251 lck_mtx_lock(&req->r_mtx);
3252 if (req->r_nmrep.nmc_mhead || (rxid != R_XID32(req->r_xid))) {
3253 lck_mtx_unlock(&req->r_mtx);
3257 req->r_nmrep = nmrep;
3264 FSDBG(530, R_XID32(req->r_xid), req, nmp->nm_sent, nmp->nm_cwnd);
3272 if (req->r_flags & R_CWND) {
3274 req->r_flags &= ~R_CWND;
3288 if (req->r_flags & R_TIMING) {
3297 if (proct[req->r_procnum] == 0)
3298 panic("nfs_request_match_reply: proct[%d] is zero", req->r_procnum);
3299 t1 = req->r_rtt + 1;
3300 t1 -= (NFS_SRTT(req) >> 3);
3301 NFS_SRTT(req) += t1;
3304 t1 -= (NFS_SDRTT(req) >> 2);
3305 NFS_SDRTT(req) += t1;
3310 wakeup(req);
3311 asyncioq = (req->r_callback.rcb_func != NULL);
3312 if (nfs_request_using_gss(req))
3313 nfs_gss_clnt_rpcdone(req);
3314 lck_mtx_unlock(&req->r_mtx);
3318 nfs_asyncio_finish(req);
3322 if (!req) {
3335 nfs_wait_reply(struct nfsreq *req)
3340 if (req->r_nmp && NMFLAG(req->r_nmp, INTR) && req->r_thread && !(req->r_flags & R_NOINTR))
3345 lck_mtx_lock(&req->r_mtx);
3346 while (!req->r_nmrep.nmc_mhead) {
3347 if ((error = nfs_sigintr(req->r_nmp, req, first ? NULL : req->r_thread, 0)))
3349 if (((error = req->r_error)) || req->r_nmrep.nmc_mhead)
3352 if (req->r_flags & R_MUSTRESEND) {
3354 req->r_procnum, req->r_xid, req->r_flags, req->r_rtt));
3355 req->r_flags |= R_SENDING;
3356 lck_mtx_unlock(&req->r_mtx);
3357 if (nfs_request_using_gss(req)) {
3364 lck_mtx_lock(&req->r_mtx);
3365 req->r_flags &= ~R_SENDING;
3366 lck_mtx_unlock(&req->r_mtx);
3369 error = nfs_send(req, 1);
3370 lck_mtx_lock(&req->r_mtx);
3372 req->r_procnum, req->r_xid, req->r_flags, req->r_rtt, error));
3375 if (((error = req->r_error)) || req->r_nmrep.nmc_mhead)
3379 if (nfs_noremotehang(req->r_thread))
3381 msleep(req, &req->r_mtx, slpflag | (PZERO - 1), "nfswaitreply", &ts);
3384 lck_mtx_unlock(&req->r_mtx);
3424 struct nfsreq *req, *newreq = NULL;
3427 req = *reqp;
3428 if (!req) {
3436 req = newreq;
3439 bzero(req, sizeof(*req));
3440 if (req == newreq)
3441 req->r_flags = R_ALLOCATED;
3465 lck_mtx_init(&req->r_mtx, nfs_request_grp, LCK_ATTR_NULL);
3466 req->r_nmp = nmp;
3467 req->r_np = np;
3468 req->r_thread = thd;
3470 req->r_flags |= R_NOINTR;
3473 req->r_cred = cred;
3475 req->r_procnum = procnum;
3477 req->r_flags |= R_TIMING;
3478 req->r_nmrep.nmc_mhead = NULL;
3479 SLIST_INIT(&req->r_gss_seqlist);
3480 req->r_achain.tqe_next = NFSREQNOLIST;
3481 req->r_rchain.tqe_next = NFSREQNOLIST;
3482 req->r_cchain.tqe_next = NFSREQNOLIST;
3485 if (!req->r_cred)
3486 req->r_auth = RPCAUTH_NONE;
3487 else if (req->r_np && (req->r_np->n_auth != RPCAUTH_INVALID))
3488 req->r_auth = req->r_np->n_auth;
3490 req->r_auth = nmp->nm_auth;
3495 req->r_mrest = nmrest->nmc_mhead;
3498 req->r_flags |= R_INITTED;
3499 req->r_refs = 1;
3501 *reqp = req;
3509 nfs_request_destroy(struct nfsreq *req)
3511 struct nfsmount *nmp = req->r_np ? NFSTONMP(req->r_np) : req->r_nmp;
3516 if (!req || !(req->r_flags & R_INITTED))
3518 req->r_flags &= ~R_INITTED;
3519 if (req->r_lflags & RL_QUEUED)
3520 nfs_reqdequeue(req);
3521 if (req->r_achain.tqe_next != NFSREQNOLIST) {
3524 if (nmp && (req->r_achain.tqe_next != NFSREQNOLIST)) {
3525 TAILQ_REMOVE(&nmp->nm_iodq, req, r_achain);
3526 req->r_achain.tqe_next = NFSREQNOLIST;
3530 lck_mtx_lock(&req->r_mtx);
3533 if (req->r_flags & R_CWND) {
3535 req->r_flags &= ~R_CWND;
3545 if (req->r_rchain.tqe_next != NFSREQNOLIST) {
3546 TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain);
3547 req->r_rchain.tqe_next = NFSREQNOLIST;
3548 if (req->r_flags & R_RESENDQ)
3549 req->r_flags &= ~R_RESENDQ;
3551 if (req->r_cchain.tqe_next != NFSREQNOLIST) {
3552 TAILQ_REMOVE(&nmp->nm_cwndq, req, r_cchain);
3553 req->r_cchain.tqe_next = NFSREQNOLIST;
3555 if (req->r_flags & R_JBTPRINTFMSG) {
3556 req->r_flags &= ~R_JBTPRINTFMSG;
3562 while (req->r_flags & R_RESENDQ)
3563 msleep(req, &req->r_mtx, (PZERO - 1), "nfsresendqwait", &ts);
3564 lck_mtx_unlock(&req->r_mtx);
3566 nfs_up(nmp, req->r_thread, clearjbtimeo, NULL);
3567 if (req->r_mhead)
3568 mbuf_freem(req->r_mhead);
3569 else if (req->r_mrest)
3570 mbuf_freem(req->r_mrest);
3571 if (req->r_nmrep.nmc_mhead)
3572 mbuf_freem(req->r_nmrep.nmc_mhead);
3573 if (IS_VALID_CRED(req->r_cred))
3574 kauth_cred_unref(&req->r_cred);
3575 if (nfs_request_using_gss(req))
3576 nfs_gss_clnt_rpcdone(req);
3577 SLIST_FOREACH_SAFE(gsp, &req->r_gss_seqlist, gss_seqnext, ngsp)
3579 if (req->r_gss_ctx)
3580 nfs_gss_clnt_ctx_unref(req);
3581 if (req->r_wrongsec)
3582 FREE(req->r_wrongsec, M_TEMP);
3584 lck_mtx_destroy(&req->r_mtx, nfs_request_grp);
3585 if (req->r_flags & R_ALLOCATED)
3586 FREE_ZONE(req, sizeof(*req), M_NFSREQ);
3590 nfs_request_ref(struct nfsreq *req, int locked)
3593 lck_mtx_lock(&req->r_mtx);
3594 if (req->r_refs <= 0)
3596 req->r_refs++;
3598 lck_mtx_unlock(&req->r_mtx);
3602 nfs_request_rele(struct nfsreq *req)
3606 lck_mtx_lock(&req->r_mtx);
3607 if (req->r_refs <= 0)
3609 req->r_refs--;
3610 destroy = (req->r_refs == 0);
3611 lck_mtx_unlock(&req->r_mtx);
3613 nfs_request_destroy(req);
3621 nfs_request_add_header(struct nfsreq *req)
3628 if ((m = req->r_mhead)) {
3629 while (m && (m != req->r_mrest))
3631 req->r_mhead = NULL;
3634 nmp = req->r_np ? NFSTONMP(req->r_np) : req->r_nmp;
3638 error = nfsm_rpchead(req, req->r_mrest, &req->r_xid, &req->r_mhead);
3642 req->r_mreqlen = mbuf_pkthdr_len(req->r_mhead);
3643 nmp = req->r_np ? NFSTONMP(req->r_np) : req->r_nmp;
3648 req->r_retry = nmp->nm_retry;
3650 req->r_retry = NFS_MAXREXMIT + 1; /* past clip limit */
3661 nfs_request_send(struct nfsreq *req, int wait)
3666 lck_mtx_lock(&req->r_mtx);
3667 req->r_flags |= R_SENDING;
3668 lck_mtx_unlock(&req->r_mtx);
3672 nmp = req->r_np ? NFSTONMP(req->r_np) : req->r_nmp;
3679 if (!req->r_start) {
3680 req->r_start = now.tv_sec;
3681 req->r_lastmsg = now.tv_sec -
3693 TAILQ_INSERT_TAIL(&nfs_reqq, req, r_chain);
3694 req->r_lflags |= RL_QUEUED;
3703 return (nfs_send(req, wait));
3710 nfs_request_wait(struct nfsreq *req)
3712 req->r_error = nfs_wait_reply(req);
3721 struct nfsreq *req,
3736 error = req->r_error;
3742 nfs_reqdequeue(req);
3744 mrep = req->r_nmrep.nmc_mhead;
3746 nmp = req->r_np ? NFSTONMP(req->r_np) : req->r_nmp;
3748 if ((req->r_flags & R_CWND) && nmp) {
3752 req->r_flags &= ~R_CWND;
3754 FSDBG(273, R_XID32(req->r_xid), req, nmp->nm_sent, nmp->nm_cwnd);
3766 if (nfs_request_using_gss(req)) {
3772 nfs_gss_clnt_rpcdone(req);
3780 req->r_error = 0;
3783 error = nfs_gss_clnt_args_restore(req); // remove any trailer mbufs
3784 req->r_nmrep.nmc_mhead = NULL;
3785 req->r_flags |= R_RESTART;
3787 req->r_xid = 0; // get a new XID
3800 if ((req->r_flags & R_TPRINTFMSG) ||
3803 nfs_up(nmp, req->r_thread, NFSSTA_TIMEO, "is alive again");
3805 nfs_up(nmp, req->r_thread, NFSSTA_TIMEO, NULL);
3814 nmrep = req->r_nmrep;
3835 error = nfs_gss_clnt_args_restore(req);
3840 error = nfs_gss_clnt_ctx_renew(req);
3845 req->r_nmrep.nmc_mhead = NULL;
3846 req->r_xid = 0; // get a new XID
3847 req->r_flags |= R_RESTART;
3861 switch (req->r_auth) {
3872 error = nfs_gss_clnt_verf_get(req, &nmrep,
3880 if (req->r_procnum == NFSPROC_NULL) {
3895 int delay, slpflag = (NMFLAG(nmp, INTR) && !(req->r_flags & R_NOINTR)) ? PCATCH : 0;
3898 req->r_nmrep.nmc_mhead = NULL;
3899 if ((req->r_delay >= 30) && !(nmp->nm_state & NFSSTA_MOUNTED)) {
3903 nfs_softterm(req);
3904 error = req->r_error;
3907 req->r_delay = !req->r_delay ? NFS_TRYLATERDEL : (req->r_delay * 2);
3908 if (req->r_delay > 30)
3909 req->r_delay = 30;
3910 if (nmp->nm_tprintf_initial_delay && (req->r_delay >= nmp->nm_tprintf_initial_delay)) {
3911 if (!(req->r_flags & R_JBTPRINTFMSG)) {
3912 req->r_flags |= R_JBTPRINTFMSG;
3917 nfs_down(req->r_nmp, req->r_thread, 0, NFSSTA_JUKEBOXTIMEO,
3920 if (NMFLAG(nmp, SOFT) && (req->r_delay == 30) && !(req->r_flags & R_NOINTR)) {
3923 nfs_softterm(req);
3924 error = req->r_error;
3927 delay = req->r_delay;
3928 if (req->r_callback.rcb_func) {
3931 req->r_resendtime = now.tv_sec + delay;
3934 if ((error = nfs_sigintr(req->r_nmp, req, req->r_thread, 0)))
3940 req->r_xid = 0; // get a new XID
3941 req->r_flags |= R_RESTART;
3942 req->r_start = 0;
3943 FSDBG(273, R_XID32(req->r_xid), nmp, req, NFSERR_TRYLATER);
3947 if (req->r_flags & R_JBTPRINTFMSG) {
3948 req->r_flags &= ~R_JBTPRINTFMSG;
3953 nfs_up(nmp, req->r_thread, clearjbtimeo, "resource available again");
3969 nfs4_secinfo_rpc(nmp, &req->r_secinfo, req->r_cred, srvflavors, &srvcount);
3971 if (!req->r_wrongsec) {
3973 MALLOC(req->r_wrongsec, uint32_t*, NX_MAX_SEC_FLAVORS*sizeof(uint32_t), M_TEMP, M_WAITOK);
3974 if (!req->r_wrongsec) {
3981 req->r_wrongsec[i] = nmp->nm_sec.flavors[i];
3984 req->r_wrongsec[i] = srvflavors[i];
3986 req->r_wrongsec[i++] = RPCAUTH_KRB5P;
3987 req->r_wrongsec[i++] = RPCAUTH_KRB5I;
3988 req->r_wrongsec[i++] = RPCAUTH_KRB5;
3989 req->r_wrongsec[i++] = RPCAUTH_SYS;
3990 req->r_wrongsec[i++] = RPCAUTH_NONE;
3993 req->r_wrongsec[i] = RPCAUTH_INVALID;
3998 if (req->r_wrongsec[i] == req->r_auth)
3999 req->r_wrongsec[i] = RPCAUTH_INVALID;
4003 if (req->r_wrongsec[i] != RPCAUTH_INVALID) {
4004 if (((req->r_wrongsec[i] == RPCAUTH_KRB5P) ||
4005 (req->r_wrongsec[i] == RPCAUTH_KRB5I) ||
4006 (req->r_wrongsec[i] == RPCAUTH_KRB5)) && (req->r_gss_ctx &&
4007 (req->r_gss_ctx->gss_clnt_service == RPCSEC_GSS_SVC_SYS))) {
4009 req->r_wrongsec[i] = RPCAUTH_INVALID;
4016 if (req->r_wrongsec[i] == srvflavors[j])
4021 req->r_wrongsec[i] = RPCAUTH_INVALID;
4030 req->r_auth = req->r_wrongsec[i];
4031 req->r_xid = 0; // get a new XID
4032 req->r_flags |= R_RESTART;
4033 req->r_start = 0;
4034 FSDBG(273, R_XID32(req->r_xid), nmp, req, NFSERR_WRONGSEC);
4037 if ((nmp->nm_vers >= NFS_VER4) && req->r_wrongsec) {
4042 if (req->r_np)
4043 req->r_np->n_auth = req->r_auth;
4051 req->r_nmrep.nmc_mhead = NULL;
4060 if ((*status == ESTALE) && req->r_np) {
4061 cache_purge(NFSTOV(req->r_np));
4063 if (vnode_ismonitored(NFSTOV(req->r_np)))
4064 nfs_vnode_notify(req->r_np, (VNODE_EVENT_ATTRIB|VNODE_EVENT_DELETE));
4070 req->r_nmrep.nmc_mhead = NULL;
4091 if (req->r_flags & R_JBTPRINTFMSG) {
4092 req->r_flags &= ~R_JBTPRINTFMSG;
4098 nfs_up(nmp, req->r_thread, clearjbtimeo, NULL);
4100 FSDBG(273, R_XID32(req->r_xid), nmp, req,
4109 nfs_request_using_gss(struct nfsreq *req)
4111 if (!req->r_gss_ctx)
4113 switch (req->r_auth) {
4157 struct nfsreq rq, *req = &rq;
4160 if ((error = nfs_request_create(np, mp, nmrest, procnum, thd, cred, &req)))
4162 req->r_flags |= (flags & R_OPTMASK);
4164 req->r_secinfo = *si;
4166 FSDBG_TOP(273, R_XID32(req->r_xid), np, procnum, 0);
4168 req->r_error = 0;
4169 req->r_flags &= ~R_RESTART;
4170 if ((error = nfs_request_add_header(req)))
4173 *xidp = req->r_xid;
4174 if ((error = nfs_request_send(req, 1)))
4176 nfs_request_wait(req);
4177 if ((error = nfs_request_finish(req, nmrepp, status)))
4179 } while (req->r_flags & R_RESTART);
4181 FSDBG_BOT(273, R_XID32(req->r_xid), np, procnum, error);
4182 nfs_request_rele(req);
4204 struct nfsreq rq, *req = &rq;
4207 if ((error = nfs_request_create(NULL, mp, nmrest, NFSPROC_NULL, thd, cred, &req)))
4209 req->r_flags |= (flags & R_OPTMASK);
4213 nfs_request_rele(req);
4216 nfs_gss_clnt_ctx_ref(req, cp);
4218 FSDBG_TOP(273, R_XID32(req->r_xid), NULL, NFSPROC_NULL, 0);
4220 req->r_error = 0;
4221 req->r_flags &= ~R_RESTART;
4222 if ((error = nfs_request_add_header(req)))
4225 if ((error = nfs_request_send(req, 1)))
4227 nfs_request_wait(req);
4228 if ((error = nfs_request_finish(req, nmrepp, status)))
4230 } while (req->r_flags & R_RESTART);
4232 FSDBG_BOT(273, R_XID32(req->r_xid), NULL, NFSPROC_NULL, error);
4233 nfs_request_rele(req);
4253 struct nfsreq *req;
4258 req = *reqp;
4259 FSDBG(274, (req ? R_XID32(req->r_xid) : 0), np, procnum, error);
4262 req->r_flags |= (flags & R_OPTMASK);
4263 req->r_flags |= R_ASYNC;
4265 req->r_secinfo = *si;
4267 req->r_callback = *cb;
4268 error = nfs_request_add_header(req);
4270 req->r_flags |= R_WAITSENT;
4271 if (req->r_callback.rcb_func)
4272 nfs_request_ref(req, 0);
4273 error = nfs_request_send(req, 1);
4274 lck_mtx_lock(&req->r_mtx);
4275 if (!error && !(req->r_flags & R_SENT) && req->r_callback.rcb_func) {
4277 int slpflag = (req->r_nmp && NMFLAG(req->r_nmp, INTR) && req->r_thread && !(req->r_flags & R_NOINTR)) ? PCATCH : 0;
4279 while (!(req->r_flags & R_SENT)) {
4280 if ((req->r_flags & R_RESENDQ) && ((nmp = req->r_nmp))) {
4282 if ((nmp->nm_state & NFSSTA_RECOVER) && (req->r_rchain.tqe_next != NFSREQNOLIST)) {
4288 TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain);
4289 req->r_rchain.tqe_next = NFSREQNOLIST;
4290 if (req->r_flags & R_RESENDQ)
4291 req->r_flags &= ~R_RESENDQ;
4293 req->r_flags |= R_SENDING;
4294 lck_mtx_unlock(&req->r_mtx);
4295 error = nfs_send(req, 1);
4296 lck_mtx_lock(&req->r_mtx);
4303 if ((error = nfs_sigintr(req->r_nmp, req, req->r_thread, 0)))
4305 msleep(req, &req->r_mtx, slpflag | (PZERO - 1), "nfswaitsent", &ts);
4309 sent = req->r_flags & R_SENT;
4310 lck_mtx_unlock(&req->r_mtx);
4311 if (error && req->r_callback.rcb_func && !sent)
4312 nfs_request_rele(req);
4314 FSDBG(274, R_XID32(req->r_xid), np, procnum, error);
4315 if (error || req->r_callback.rcb_func)
4316 nfs_request_rele(req);
4325 struct nfsreq *req,
4330 int error = 0, asyncio = req->r_callback.rcb_func ? 1 : 0;
4333 lck_mtx_lock(&req->r_mtx);
4335 req->r_flags |= R_ASYNCWAIT;
4336 while (req->r_flags & R_RESENDQ) { /* wait until the request is off the resend queue */
4338 if ((nmp = req->r_nmp)) {
4340 if ((nmp->nm_state & NFSSTA_RECOVER) && (req->r_rchain.tqe_next != NFSREQNOLIST)) {
4346 TAILQ_REMOVE(&nmp->nm_resendq, req, r_rchain);
4347 req->r_rchain.tqe_next = NFSREQNOLIST;
4348 if (req->r_flags & R_RESENDQ)
4349 req->r_flags &= ~R_RESENDQ;
4355 if ((error = nfs_sigintr(req->r_nmp, req, req->r_thread, 0)))
4357 msleep(req, &req->r_mtx, PZERO-1, "nfsresendqwait", &ts);
4359 lck_mtx_unlock(&req->r_mtx);
4362 nfs_request_wait(req);
4363 error = nfs_request_finish(req, nmrepp, status);
4366 while (!error && (req->r_flags & R_RESTART)) {
4367 if (asyncio && req->r_resendtime) { /* send later */
4368 lck_mtx_lock(&req->r_mtx);
4369 nfs_asyncio_resend(req);
4370 lck_mtx_unlock(&req->r_mtx);
4373 req->r_error = 0;
4374 req->r_flags &= ~R_RESTART;
4375 if ((error = nfs_request_add_header(req)))
4377 if ((error = nfs_request_send(req, !asyncio)))
4381 nfs_request_wait(req);
4382 if ((error = nfs_request_finish(req, nmrepp, status)))
4386 *xidp = req->r_xid;
4388 FSDBG(275, R_XID32(req->r_xid), req->r_np, req->r_procnum, error);
4389 nfs_request_rele(req);
4397 nfs_request_async_cancel(struct nfsreq *req)
4399 nfs_reqdequeue(req);
4400 FSDBG(275, R_XID32(req->r_xid), req->r_np, req->r_procnum, 0xD1ED1E);
4401 nfs_request_rele(req);
4408 nfs_softterm(struct nfsreq *req)
4410 struct nfsmount *nmp = req->r_nmp;
4411 req->r_flags |= R_SOFTTERM;
4412 req->r_error = ETIMEDOUT;
4413 if (!(req->r_flags & R_CWND) || !nmp)
4416 req->r_flags &= ~R_CWND;
4418 FSDBG(532, R_XID32(req->r_xid), req, nmp->nm_sent, nmp->nm_cwnd);
4431 * Ensure req isn't in use by the timer, then dequeue it.
4434 nfs_reqdequeue(struct nfsreq *req)
4437 while (req->r_lflags & RL_BUSY) {
4438 req->r_lflags |= RL_WAITING;
4439 msleep(&req->r_lflags, nfs_request_mutex, PSOCK, "reqdeq", NULL);
4441 if (req->r_lflags & RL_QUEUED) {
4442 TAILQ_REMOVE(&nfs_reqq, req, r_chain);
4443 req->r_lflags &= ~RL_QUEUED;
4453 nfs_reqbusy(struct nfsreq *req)
4455 if (req->r_lflags & RL_BUSY)
4456 panic("req locked");
4457 req->r_lflags |= RL_BUSY;
4464 nfs_reqnext(struct nfsreq *req)
4468 if (req == NULL)
4471 * We need to get and busy the next req before signalling the
4473 * grab the next req.
4475 nextreq = TAILQ_NEXT(req, r_chain);
4479 req->r_lflags &= ~RL_BUSY;
4480 if (req->r_lflags & RL_WAITING) {
4481 req->r_lflags &= ~RL_WAITING;
4482 wakeup(&req->r_lflags);
4499 struct nfsreq *req;
4506 req = TAILQ_FIRST(&nfs_reqq);
4507 if (req == NULL) { /* no requests - turn timer off */
4513 nfs_reqbusy(req);
4517 for ( ; req != NULL ; req = nfs_reqnext(req)) {
4518 nmp = req->r_nmp;
4521 if (req->r_error || req->r_nmrep.nmc_mhead)
4523 if ((error = nfs_sigintr(nmp, req, req->r_thread, 0))) {
4524 if (req->r_callback.rcb_func != NULL) {
4526 lck_mtx_lock(&req->r_mtx);
4527 req->r_error = error;
4528 finish_asyncio = !(req->r_flags & R_WAITSENT);
4529 wakeup(req);
4530 lck_mtx_unlock(&req->r_mtx);
4532 nfs_asyncio_finish(req);
4537 lck_mtx_lock(&req->r_mtx);
4540 ((req->r_rexmit > 2) || (req->r_flags & R_RESENDERR)) &&
4541 ((req->r_lastmsg + nmp->nm_tprintf_delay) < now.tv_sec)) {
4542 req->r_lastmsg = now.tv_sec;
4543 nfs_down(req->r_nmp, req->r_thread, 0, NFSSTA_TIMEO,
4545 req->r_flags |= R_TPRINTFMSG;
4552 nfs_softterm(req);
4553 finish_asyncio = ((req->r_callback.rcb_func != NULL) && !(req->r_flags & R_WAITSENT));
4554 wakeup(req);
4555 lck_mtx_unlock(&req->r_mtx);
4557 nfs_asyncio_finish(req);
4569 else if ((req->r_flags & (R_SETUP|R_RECOVER)) ||
4578 if (req->r_rtt >= 0) {
4579 req->r_rtt++;
4581 if (req->r_flags & R_RESENDERR) {
4585 if (req->r_procnum == NFSPROC_NULL && req->r_gss_ctx != NULL)
4590 timeo = NFS_RTO(nmp, proct[req->r_procnum]);
4601 if (req->r_rtt <= timeo) {
4603 lck_mtx_unlock(&req->r_mtx);
4608 req->r_procnum, proct[req->r_procnum],
4609 req->r_xid, req->r_rtt, timeo, nmp->nm_timeouts,
4610 (now.tv_sec - req->r_start)*NFS_HZ, maxtime));
4616 ((now.tv_sec - req->r_start) >= 3) &&
4626 if ((NMFLAG(nmp, SOFT) || (req->r_flags & (R_SETUP|R_RECOVER))) &&
4627 ((req->r_rexmit >= req->r_retry) || /* too many */
4628 ((now.tv_sec - req->r_start)*NFS_HZ > maxtime))) { /* too long */
4635 nfs_down(req->r_nmp, req->r_thread, 0, NFSSTA_TIMEO,
4637 req->r_lastmsg = now.tv_sec;
4638 req->r_flags |= R_TPRINTFMSG;
4642 if (req->r_flags & R_NOINTR) {
4644 lck_mtx_unlock(&req->r_mtx);
4648 req->r_procnum, req->r_xid, req->r_flags, req->r_rtt,
4649 now.tv_sec - req->r_start));
4650 nfs_softterm(req);
4651 finish_asyncio = ((req->r_callback.rcb_func != NULL) && !(req->r_flags & R_WAITSENT));
4652 wakeup(req);
4653 lck_mtx_unlock(&req->r_mtx);
4655 nfs_asyncio_finish(req);
4660 if ((nmp->nm_sotype == SOCK_STREAM) && !(req->r_flags & R_MUSTRESEND)) {
4661 if (++req->r_rexmit > NFS_MAXREXMIT)
4662 req->r_rexmit = NFS_MAXREXMIT;
4663 req->r_rtt = 0;
4664 lck_mtx_unlock(&req->r_mtx);
4672 if ((req->r_flags & R_MUSTRESEND) && (req->r_rtt == -1)) {
4673 lck_mtx_unlock(&req->r_mtx);
4677 req->r_procnum, req->r_xid, req->r_flags, req->r_rtt));
4678 req->r_flags |= R_MUSTRESEND;
4679 req->r_rtt = -1;
4680 wakeup(req);
4681 if ((req->r_flags & (R_ASYNC|R_ASYNCWAIT|R_SENDING)) == R_ASYNC)
4682 nfs_asyncio_resend(req);
4683 lck_mtx_unlock(&req->r_mtx);
4721 nfs_sigintr(struct nfsmount *nmp, struct nfsreq *req, thread_t thd, int nmplocked)
4729 if (req && (req->r_flags & R_SOFTTERM))
4731 if (req && (req->r_flags & R_NOINTR))
4791 nfs_sndlock(struct nfsreq *req)
4793 struct nfsmount *nmp = req->r_nmp;
4804 if (NMFLAG(nmp, INTR) && req->r_thread && !(req->r_flags & R_NOINTR))
4807 if ((error = nfs_sigintr(nmp, req, req->r_thread, 1)))
4810 if (nfs_noremotehang(req->r_thread))
4828 nfs_sndunlock(struct nfsreq *req)
4830 struct nfsmount *nmp = req->r_nmp;