Lines Matching refs:iod

50 #define	SMB_IOD_EVLOCKPTR(iod)	(&((iod)->iod_evlock))
51 #define SMB_IOD_EVLOCK(iod) smb_sl_lock(&((iod)->iod_evlock))
52 #define SMB_IOD_EVUNLOCK(iod) smb_sl_unlock(&((iod)->iod_evlock))
54 #define SMB_IOD_RQLOCKPTR(iod) (&((iod)->iod_rqlock))
55 #define SMB_IOD_RQLOCK(iod) smb_sl_lock(&((iod)->iod_rqlock))
56 #define SMB_IOD_RQUNLOCK(iod) smb_sl_unlock(&((iod)->iod_rqlock))
58 #define smb_iod_wakeup(iod) wakeup(&(iod)->iod_flags)
65 static int smb_iod_sendall(struct smbiod *iod);
66 static int smb_iod_disconnect(struct smbiod *iod);
81 smb_iod_invrq(struct smbiod *iod)
88 SMB_IOD_RQLOCK(iod);
89 TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
93 SMB_IOD_RQUNLOCK(iod);
97 smb_iod_closetran(struct smbiod *iod)
99 struct smb_vc *vcp = iod->iod_vc;
100 struct thread *td = iod->iod_td;
110 smb_iod_dead(struct smbiod *iod)
112 iod->iod_state = SMBIOD_ST_DEAD;
113 smb_iod_closetran(iod);
114 smb_iod_invrq(iod);
118 smb_iod_connect(struct smbiod *iod)
120 struct smb_vc *vcp = iod->iod_vc;
121 struct thread *td = iod->iod_td;
124 SMBIODEBUG("%d\n", iod->iod_state);
125 switch(iod->iod_state) {
150 SMB_TRAN_SETPARAM(vcp, SMBTP_SELECTID, &iod->iod_flags);
151 iod->iod_state = SMBIOD_ST_TRANACTIVE;
154 error = (int)smb_smb_negotiate(vcp, &iod->iod_scred);
158 error = (int)smb_smb_ssnsetup(vcp, &iod->iod_scred);
161 iod->iod_state = SMBIOD_ST_VCACTIVE;
163 smb_iod_invrq(iod);
167 smb_iod_dead(iod);
172 smb_iod_disconnect(struct smbiod *iod)
174 struct smb_vc *vcp = iod->iod_vc;
177 if (iod->iod_state == SMBIOD_ST_VCACTIVE) {
178 smb_smb_ssnclose(vcp, &iod->iod_scred);
179 iod->iod_state = SMBIOD_ST_TRANACTIVE;
182 smb_iod_closetran(iod);
183 iod->iod_state = SMBIOD_ST_NOTCONN;
188 smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp)
192 if (iod->iod_state != SMBIOD_ST_VCACTIVE) {
193 if (iod->iod_state != SMBIOD_ST_DEAD)
195 iod->iod_state = SMBIOD_ST_RECONNECT;
196 error = smb_iod_connect(iod);
204 error = smb_smb_treeconnect(ssp, &iod->iod_scred);
213 smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp)
215 struct thread *td = iod->iod_td;
216 struct smb_vc *vcp = iod->iod_vc;
221 SMBIODEBUG("iod_state = %d\n", iod->iod_state);
222 switch (iod->iod_state) {
227 iod->iod_state = SMBIOD_ST_RECONNECT;
236 if (vcp->vc_maxmux != 0 && iod->iod_muxcnt >= vcp->vc_maxmux)
260 iod->iod_lastrqsent = rqp->sr_timesent;
283 smb_iod_recvall(struct smbiod *iod)
285 struct smb_vc *vcp = iod->iod_vc;
286 struct thread *td = iod->iod_td;
293 switch (iod->iod_state) {
307 smb_iod_dead(iod);
332 SMB_IOD_RQLOCK(iod);
333 TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
352 SMB_IOD_RQUNLOCK(iod);
362 SMB_IOD_RQLOCK(iod);
363 TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
368 SMB_IOD_RQUNLOCK(iod);
373 smb_iod_request(struct smbiod *iod, int event, void *ident)
382 SMB_IOD_EVLOCK(iod);
383 STAILQ_INSERT_TAIL(&iod->iod_evlist, evp, ev_link);
385 SMB_IOD_EVUNLOCK(iod);
386 smb_iod_wakeup(iod);
389 smb_iod_wakeup(iod);
390 msleep(evp, SMB_IOD_EVLOCKPTR(iod), PWAIT | PDROP, "90evw", 0);
404 struct smbiod *iod = vcp->vc_iod;
409 rqp->sr_cred->scr_td->td_proc == iod->iod_p) {
411 SMB_IOD_RQLOCK(iod);
412 TAILQ_INSERT_HEAD(&iod->iod_rqlist, rqp, sr_link);
413 SMB_IOD_RQUNLOCK(iod);
415 if (smb_iod_sendrq(iod, rqp) != 0) {
416 smb_iod_dead(iod);
424 tsleep(&iod->iod_flags, PWAIT, "90sndw", hz);
431 switch (iod->iod_state) {
443 SMB_IOD_RQLOCK(iod);
449 if (iod->iod_muxcnt < vcp->vc_maxmux)
451 iod->iod_muxwant++;
452 msleep(&iod->iod_muxwant, SMB_IOD_RQLOCKPTR(iod),
455 iod->iod_muxcnt++;
456 TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link);
457 SMB_IOD_RQUNLOCK(iod);
458 smb_iod_wakeup(iod);
466 struct smbiod *iod = vcp->vc_iod;
470 SMB_IOD_RQLOCK(iod);
471 TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link);
472 SMB_IOD_RQUNLOCK(iod);
475 SMB_IOD_RQLOCK(iod);
478 msleep(rqp, SMB_IOD_RQLOCKPTR(iod), PWAIT, "90xrm", 0);
480 TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link);
481 iod->iod_muxcnt--;
482 if (iod->iod_muxwant) {
483 iod->iod_muxwant--;
484 wakeup(&iod->iod_muxwant);
486 SMB_IOD_RQUNLOCK(iod);
493 struct smbiod *iod = rqp->sr_vc->vc_iod;
499 smb_iod_sendall(iod);
500 smb_iod_recvall(iod);
503 tsleep(&iod->iod_flags, PWAIT, "90irq", hz);
520 SMB_IOD_RQLOCK(iod);
521 TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link);
522 TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link);
523 SMB_IOD_RQUNLOCK(iod);
531 smb_iod_sendall(struct smbiod *iod)
533 struct smb_vc *vcp = iod->iod_vc;
542 SMB_IOD_RQLOCK(iod);
543 TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
547 SMB_IOD_RQUNLOCK(iod);
548 herror = smb_iod_sendrq(iod, rqp);
549 SMB_IOD_RQLOCK(iod);
571 SMB_IOD_RQUNLOCK(iod);
573 smb_iod_dead(iod);
581 smb_iod_main(struct smbiod *iod)
583 /* struct smb_vc *vcp = iod->iod_vc;*/
595 SMB_IOD_EVLOCK(iod);
596 evp = STAILQ_FIRST(&iod->iod_evlist);
598 SMB_IOD_EVUNLOCK(iod);
601 STAILQ_REMOVE_HEAD(&iod->iod_evlist, ev_link);
603 SMB_IOD_EVUNLOCK(iod);
606 iod->iod_state = SMBIOD_ST_RECONNECT;
607 evp->ev_error = smb_iod_connect(iod);
610 evp->ev_error = smb_iod_disconnect(iod);
613 evp->ev_error = smb_iod_treeconnect(iod, evp->ev_ident);
616 iod->iod_flags |= SMBIOD_SHUTDOWN;
622 SMB_IOD_EVLOCK(iod);
624 SMB_IOD_EVUNLOCK(iod);
629 if (iod->iod_state == SMBIOD_ST_VCACTIVE) {
631 timespecsub(&tsnow, &iod->iod_pingtimo);
632 if (timespeccmp(&tsnow, &iod->iod_lastrqsent, >)) {
633 smb_smb_echo(vcp, &iod->iod_scred);
637 smb_iod_sendall(iod);
638 smb_iod_recvall(iod);
645 struct smbiod *iod = arg;
653 iod->iod_td = curthread;
654 smb_makescred(&iod->iod_scred, iod->iod_td, NULL);
655 while ((iod->iod_flags & SMBIOD_SHUTDOWN) == 0) {
656 smb_iod_main(iod);
657 SMBIODEBUG("going to sleep for %d ticks\n", iod->iod_sleeptimo);
658 if (iod->iod_flags & SMBIOD_SHUTDOWN)
660 tsleep(&iod->iod_flags, PWAIT, "90idle", iod->iod_sleeptimo);
663 /* We can now safely destroy the mutexes and free the iod structure. */
664 smb_sl_destroy(&iod->iod_rqlock);
665 smb_sl_destroy(&iod->iod_evlock);
666 free(iod, M_SMBIOD);
674 struct smbiod *iod;
677 iod = smb_zmalloc(sizeof(*iod), M_SMBIOD, M_WAITOK);
678 iod->iod_id = smb_iod_next++;
679 iod->iod_state = SMBIOD_ST_NOTCONN;
680 iod->iod_vc = vcp;
681 iod->iod_sleeptimo = hz * SMBIOD_SLEEP_TIMO;
682 iod->iod_pingtimo.tv_sec = SMBIOD_PING_TIMO;
683 getnanotime(&iod->iod_lastrqsent);
684 vcp->vc_iod = iod;
685 smb_sl_init(&iod->iod_rqlock, "90rql");
686 TAILQ_INIT(&iod->iod_rqlist);
687 smb_sl_init(&iod->iod_evlock, "90evl");
688 STAILQ_INIT(&iod->iod_evlist);
689 error = kproc_create(smb_iod_thread, iod, &iod->iod_p,
690 RFNOWAIT, 0, "smbiod%d", iod->iod_id);
694 smb_sl_destroy(&iod->iod_rqlock);
695 smb_sl_destroy(&iod->iod_evlock);
696 free(iod, M_SMBIOD);
703 smb_iod_destroy(struct smbiod *iod)
705 smb_iod_request(iod, SMBIOD_EV_SHUTDOWN | SMBIOD_EV_SYNC, NULL);