From 8886b1fc4f9da9d057822658fd256d6391b8f396 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 6 Dec 2005 04:03:56 +0000 Subject: [PATCH] The new lockmgr() function requires spinlocks, not tokens. Take this opportunity to convert all use of tokens in SMB to spinlocks since they are only used to wrap very low level operations. Reported-by: "Adrian M. Nida" --- sys/netproto/smb/smb_conn.c | 48 +++++++--------- sys/netproto/smb/smb_conn.h | 24 ++++---- sys/netproto/smb/smb_iod.c | 112 ++++++++++++++++-------------------- sys/netproto/smb/smb_rq.c | 20 +++---- sys/netproto/smb/smb_rq.h | 7 ++- sys/netproto/smb/smb_subr.c | 8 +-- sys/netproto/smb/smb_subr.h | 17 +++--- 7 files changed, 111 insertions(+), 125 deletions(-) diff --git a/sys/netproto/smb/smb_conn.c b/sys/netproto/smb/smb_conn.c index b0a6d803ee..2997e79473 100644 --- a/sys/netproto/smb/smb_conn.c +++ b/sys/netproto/smb/smb_conn.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_conn.c,v 1.1.2.1 2001/05/22 08:32:33 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_conn.c,v 1.8 2004/06/06 19:16:14 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_conn.c,v 1.9 2005/12/06 04:03:56 dillon Exp $ */ /* @@ -257,53 +257,49 @@ smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred) void smb_co_ref(struct smb_connobj *cp, struct thread *td) { - smb_ilock ilock; - - SMB_CO_LOCK(&ilock, cp); + SMB_CO_LOCK(cp); cp->co_usecount++; - SMB_CO_UNLOCK(&ilock); + SMB_CO_UNLOCK(cp); } void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred) { struct thread *td = scred->scr_td; - smb_ilock ilock; - SMB_CO_LOCK(&ilock, cp); + SMB_CO_LOCK(cp); if (cp->co_usecount > 1) { cp->co_usecount--; - SMB_CO_UNLOCK(&ilock); + SMB_CO_UNLOCK(cp); return; } if (cp->co_usecount == 0) { SMBERROR("negative use_count for object %d", cp->co_level); - SMB_CO_UNLOCK(&ilock); + SMB_CO_UNLOCK(cp); return; } cp->co_usecount--; cp->co_flags |= SMBO_GONE; - lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &ilock, td); + lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, SMB_CO_INTERLOCK(cp), td); smb_co_gone(cp, scred); } int -smb_co_get(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct smb_cred *scred) +smb_co_get(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct smb_cred *scred) { int error; - smb_ilock iilock; if ((flags & LK_INTERLOCK) == 0) { - SMB_CO_LOCK(&iilock, cp); - ilock = &iilock; + SMB_CO_LOCK(cp); + sl = SMB_CO_INTERLOCK(cp); } cp->co_usecount++; - error = smb_co_lock(cp, ilock, flags | LK_INTERLOCK, scred->scr_td); + error = smb_co_lock(cp, sl, flags | LK_INTERLOCK, scred->scr_td); if (error) { - SMB_CO_LOCK(ilock, cp); + SMB_CO_LOCK(cp); cp->co_usecount--; - SMB_CO_UNLOCK(ilock); + SMB_CO_UNLOCK(cp); return error; } return 0; @@ -314,10 +310,9 @@ smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) { struct thread *td = scred->scr_td; int flags; - smb_ilock ilock; flags = LK_RELEASE; - SMB_CO_LOCK(&ilock, cp); + SMB_CO_LOCK(cp); if (cp->co_usecount > 1) { cp->co_usecount--; } else if (cp->co_usecount == 1) { @@ -327,7 +322,7 @@ smb_co_put(struct smb_connobj *cp, struct smb_cred *scred) } else { SMBERROR("negative usecount"); } - lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &ilock, td); + lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, SMB_CO_INTERLOCK(cp), td); if ((cp->co_flags & SMBO_GONE) == 0) return; lockmgr(&cp->co_lock, LK_DRAIN, NULL, td); @@ -341,7 +336,7 @@ smb_co_lockstatus(struct smb_connobj *cp, struct thread *td) } int -smb_co_lock(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct thread *td) +smb_co_lock(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct thread *td) { if (cp->co_flags & SMBO_GONE) return EINVAL; @@ -352,13 +347,13 @@ smb_co_lock(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct thread * SMBERROR("recursive lock for object %d\n", cp->co_level); return 0; } - return lockmgr(&cp->co_lock, flags, ilock, td); + return lockmgr(&cp->co_lock, flags, sl, td); } void -smb_co_unlock(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct thread *td) +smb_co_unlock(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct thread *td) { - lockmgr(&cp->co_lock, flags | LK_RELEASE, ilock, td); + lockmgr(&cp->co_lock, flags | LK_RELEASE, sl, td); } static void @@ -651,11 +646,10 @@ u_short smb_vc_nextmid(struct smb_vc *vcp) { u_short r; - smb_ilock ilock; - SMB_CO_LOCK(&ilock, &vcp->obj); + SMB_CO_LOCK(&vcp->obj); r = vcp->vc_mid++; - SMB_CO_UNLOCK(&ilock); + SMB_CO_UNLOCK(&vcp->obj); return r; } diff --git a/sys/netproto/smb/smb_conn.h b/sys/netproto/smb/smb_conn.h index 65ab0f974c..49044cd0c3 100644 --- a/sys/netproto/smb/smb_conn.h +++ b/sys/netproto/smb/smb_conn.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_conn.h,v 1.1.2.3 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_conn.h,v 1.5 2004/03/01 06:33:18 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_conn.h,v 1.6 2005/12/06 04:03:56 dillon Exp $ */ #ifndef _NETINET_IN_H_ #include @@ -199,8 +199,9 @@ struct smb_connobj; typedef void smb_co_gone_t (struct smb_connobj *cp, struct smb_cred *scred); typedef void smb_co_free_t (struct smb_connobj *cp); -#define SMB_CO_LOCK(ilock, cp) smb_sl_lock(ilock, &(cp)->co_interlock) -#define SMB_CO_UNLOCK(ilock) smb_sl_unlock(ilock) +#define SMB_CO_LOCK(cp) smb_sl_lock(&(cp)->co_interlock) +#define SMB_CO_UNLOCK(cp) smb_sl_unlock(&(cp)->co_interlock) +#define SMB_CO_INTERLOCK(cp) (&(cp)->co_interlock) struct smb_connobj { int co_level; /* SMBL_ */ @@ -231,8 +232,8 @@ struct smb_connobj { /* * This lock protects vc_flags */ -#define SMBC_ST_LOCK(ilock, vcp) smb_sl_lock(ilock, &(vcp)->vc_stlock) -#define SMBC_ST_UNLOCK(ilock) smb_sl_unlock(ilock) +#define SMBC_ST_LOCK(vcp) smb_sl_lock(&(vcp)->vc_stlock) +#define SMBC_ST_UNLOCK(vcp) smb_sl_unlock(&(vcp)->vc_stlock) struct smb_vc { @@ -284,9 +285,10 @@ struct smb_vc { /* * This lock protects ss_flags */ -#define SMBS_ST_LOCK(ilock, ssp) smb_sl_lock(ilock, &(ssp)->ss_stlock) -#define SMBS_ST_LOCKPTR(ssp) (&(ssp)->ss_stlock) -#define SMBS_ST_UNLOCK(ilock) smb_sl_unlock(ilock) +#define SMBS_ST_LOCK(ssp) smb_sl_lock(&(ssp)->ss_stlock) +#define SMBS_ST_LOCKPTR(ssp) (&(ssp)->ss_stlock) +#define SMBS_ST_INTERLOCK(ssp) (&(ssp)->ss_stlock) +#define SMBS_ST_UNLOCK(ssp) smb_sl_unlock(&(ssp)->ss_stlock) struct smb_share { struct smb_connobj obj; @@ -359,10 +361,10 @@ int smb_sm_lookup(struct smb_vcspec *vcspec, */ void smb_co_ref(struct smb_connobj *cp, struct thread *td); void smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred); -int smb_co_get(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct smb_cred *scred); +int smb_co_get(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct smb_cred *scred); void smb_co_put(struct smb_connobj *cp, struct smb_cred *scred); -int smb_co_lock(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct thread *td); -void smb_co_unlock(struct smb_connobj *cp, smb_ilock *ilock, int flags, struct thread *td); +int smb_co_lock(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct thread *td); +void smb_co_unlock(struct smb_connobj *cp, struct smb_slock *sl, int flags, struct thread *td); /* * session level functions diff --git a/sys/netproto/smb/smb_iod.c b/sys/netproto/smb/smb_iod.c index 8bc2218a79..5f8ff7b5df 100644 --- a/sys/netproto/smb/smb_iod.c +++ b/sys/netproto/smb/smb_iod.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_iod.c,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_iod.c,v 1.11 2005/01/06 22:31:16 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_iod.c,v 1.12 2005/12/06 04:03:56 dillon Exp $ */ #include @@ -52,13 +52,15 @@ #define SMBIOD_SLEEP_TIMO 2 #define SMBIOD_PING_TIMO 60 /* seconds */ -#define SMB_IOD_EVLOCKPTR(iod) (&((iod)->iod_evlock)) -#define SMB_IOD_EVLOCK(ilock, iod) smb_sl_lock(ilock, &((iod)->iod_evlock)) -#define SMB_IOD_EVUNLOCK(ilock) smb_sl_unlock(ilock) +#define SMB_IOD_EVLOCKPTR(iod) (&(iod)->iod_evlock) +#define SMB_IOD_EVLOCK(iod) smb_sl_lock(&(iod)->iod_evlock) +#define SMB_IOD_EVUNLOCK(iod) smb_sl_unlock(&(iod)->iod_evlock) +#define SMB_IOD_INTERLOCK(iod) (&(iod)->iod_evlock) -#define SMB_IOD_RQLOCKPTR(iod) (&((iod)->iod_rqlock)) -#define SMB_IOD_RQLOCK(ilock, iod) smb_sl_lock(ilock, &((iod)->iod_rqlock)) -#define SMB_IOD_RQUNLOCK(ilock) smb_sl_unlock(ilock) +#define SMB_IOD_RQLOCKPTR(iod) (&(iod)->iod_rqlock) +#define SMB_IOD_RQLOCK(iod) smb_sl_lock(&((iod)->iod_rqlock)) +#define SMB_IOD_RQUNLOCK(iod) smb_sl_unlock(&(iod)->iod_rqlock) +#define SMB_IOD_INTERLOCK(iod) (&(iod)->iod_rqlock) #define smb_iod_wakeup(iod) wakeup(&(iod)->iod_flags) @@ -74,26 +76,23 @@ static void smb_iod_thread(void *); static __inline void smb_iod_rqprocessed(struct smb_rq *rqp, int error) { - smb_ilock ilock; - - SMBRQ_SLOCK(&ilock, rqp); + SMBRQ_SLOCK(rqp); rqp->sr_lerror = error; rqp->sr_rpgen++; rqp->sr_state = SMBRQ_NOTIFIED; wakeup(&rqp->sr_state); - SMBRQ_SUNLOCK(&ilock); + SMBRQ_SUNLOCK(rqp); } static void smb_iod_invrq(struct smbiod *iod) { struct smb_rq *rqp; - smb_ilock ilock; /* * Invalidate all outstanding requests for this connection */ - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { #if 0 /* this makes no sense whatsoever XXX */ @@ -103,7 +102,7 @@ smb_iod_invrq(struct smbiod *iod) rqp->sr_flags |= SMBR_RESTART; smb_iod_rqprocessed(rqp, ENOTCONN); } - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); } static void @@ -191,7 +190,6 @@ static int smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp) { int error; - smb_ilock ilock; if (iod->iod_state != SMBIOD_ST_VCACTIVE) { if (iod->iod_state != SMBIOD_ST_DEAD) @@ -202,13 +200,13 @@ smb_iod_treeconnect(struct smbiod *iod, struct smb_share *ssp) return error; } SMBIODEBUG("tree reconnect\n"); - SMBS_ST_LOCK(&ilock, ssp); + SMBS_ST_LOCK(ssp); ssp->ss_flags |= SMBS_RECONNECTING; - SMBS_ST_UNLOCK(&ilock); + SMBS_ST_UNLOCK(ssp); error = smb_smb_treeconnect(ssp, &iod->iod_scred); - SMBS_ST_LOCK(&ilock, ssp); + SMBS_ST_LOCK(ssp); ssp->ss_flags &= ~SMBS_RECONNECTING; - SMBS_ST_UNLOCK(&ilock); + SMBS_ST_UNLOCK(ssp); wakeup(&ssp->ss_vcgenid); return error; } @@ -291,8 +289,6 @@ smb_iod_recvall(struct smbiod *iod) u_char *hp; u_short mid; int error; - smb_ilock ilock; - smb_ilock jlock; switch (iod->iod_state) { case SMBIOD_ST_NOTCONN: @@ -333,27 +329,27 @@ smb_iod_recvall(struct smbiod *iod) } mid = SMB_HDRMID(hp); SMBSDEBUG("mid %04x\n", (u_int)mid); - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { if (rqp->sr_mid != mid) continue; - SMBRQ_SLOCK(&jlock, rqp); + SMBRQ_SLOCK(rqp); if (rqp->sr_rp.md_top == NULL) { md_initm(&rqp->sr_rp, m); } else { if (rqp->sr_flags & SMBR_MULTIPACKET) { md_append_record(&rqp->sr_rp, m); } else { - SMBRQ_SUNLOCK(&jlock); + SMBRQ_SUNLOCK(rqp); SMBERROR("duplicate response %d (ignored)\n", mid); break; } } - SMBRQ_SUNLOCK(&jlock); + SMBRQ_SUNLOCK(rqp); smb_iod_rqprocessed(rqp, 0); break; } - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); if (rqp == NULL) { SMBERROR("drop resp with mid %d\n", (u_int)mid); /* smb_printrqlist(vcp);*/ @@ -363,13 +359,13 @@ smb_iod_recvall(struct smbiod *iod) /* * check for interrupts */ - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { if (smb_proc_intr(rqp->sr_cred->scr_td)) { smb_iod_rqprocessed(rqp, EINTR); } } - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); return 0; } @@ -378,21 +374,20 @@ smb_iod_request(struct smbiod *iod, int event, void *ident) { struct smbiod_event *evp; int error; - smb_ilock ilock; SMBIODEBUG("\n"); evp = smb_zmalloc(sizeof(*evp), M_SMBIOD, M_WAITOK); evp->ev_type = event; evp->ev_ident = ident; - SMB_IOD_EVLOCK(&ilock, iod); + SMB_IOD_EVLOCK(iod); STAILQ_INSERT_TAIL(&iod->iod_evlist, evp, ev_link); if ((event & SMBIOD_EV_SYNC) == 0) { - SMB_IOD_EVUNLOCK(&ilock); + SMB_IOD_EVUNLOCK(iod); smb_iod_wakeup(iod); return 0; } smb_iod_wakeup(iod); - smb_sleep(evp, &ilock, PDROP, "90evw", 0); + smb_sleep(evp, SMB_IOD_INTERLOCK(iod), PDROP, "90evw", 0); error = evp->ev_error; free(evp, M_SMBIOD); return error; @@ -407,15 +402,14 @@ smb_iod_addrq(struct smb_rq *rqp) { struct smb_vc *vcp = rqp->sr_vc; struct smbiod *iod = vcp->vc_iod; - smb_ilock ilock; int error; SMBIODEBUG("\n"); if (rqp->sr_cred->scr_td == iod->iod_td) { rqp->sr_flags |= SMBR_INTERNAL; - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_INSERT_HEAD(&iod->iod_rqlist, rqp, sr_link); - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); for (;;) { if (smb_iod_sendrq(iod, rqp) != 0) { smb_iod_dead(iod); @@ -445,7 +439,7 @@ smb_iod_addrq(struct smb_rq *rqp) break; } - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); for (;;) { if (vcp->vc_maxmux == 0) { SMBERROR("maxmux == 0\n"); @@ -454,11 +448,11 @@ smb_iod_addrq(struct smb_rq *rqp) if (iod->iod_muxcnt < vcp->vc_maxmux) break; iod->iod_muxwant++; - smb_sleep(&iod->iod_muxwant, &ilock, 0, "90mux", 0); + smb_sleep(&iod->iod_muxwant, SMB_IOD_INTERLOCK(iod), 0, "90mux", 0); } iod->iod_muxcnt++; TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link); - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); smb_iod_wakeup(iod); return 0; } @@ -468,19 +462,18 @@ smb_iod_removerq(struct smb_rq *rqp) { struct smb_vc *vcp = rqp->sr_vc; struct smbiod *iod = vcp->vc_iod; - smb_ilock ilock; SMBIODEBUG("\n"); if (rqp->sr_flags & SMBR_INTERNAL) { - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); return 0; } - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); while (rqp->sr_flags & SMBR_XLOCK) { rqp->sr_flags |= SMBR_XLOCKWANT; - smb_sleep(rqp, &ilock, 0, "90xrm", 0); + smb_sleep(rqp, SMB_IOD_INTERLOCK(iod), 0, "90xrm", 0); } TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); iod->iod_muxcnt--; @@ -488,7 +481,7 @@ smb_iod_removerq(struct smb_rq *rqp) iod->iod_muxwant--; wakeup(&iod->iod_muxwant); } - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); return 0; } @@ -496,7 +489,6 @@ int smb_iod_waitrq(struct smb_rq *rqp) { struct smbiod *iod = rqp->sr_vc->vc_iod; - smb_ilock ilock; int error; SMBIODEBUG("\n"); @@ -512,21 +504,21 @@ smb_iod_waitrq(struct smb_rq *rqp) return rqp->sr_lerror; } - SMBRQ_SLOCK(&ilock, rqp); + SMBRQ_SLOCK(rqp); if (rqp->sr_rpgen == rqp->sr_rplast) - smb_sleep(&rqp->sr_state, &ilock, 0, "90wrq", 0); + smb_sleep(&rqp->sr_state, SMBRQ_INTERLOCK(rqp), 0, "90wrq", 0); rqp->sr_rplast++; - SMBRQ_SUNLOCK(&ilock); + SMBRQ_SUNLOCK(rqp); error = rqp->sr_lerror; if (rqp->sr_flags & SMBR_MULTIPACKET) { /* * If request should stay in the list, then reinsert it * at the end of queue so other waiters have chance to concur */ - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_REMOVE(&iod->iod_rqlist, rqp, sr_link); TAILQ_INSERT_TAIL(&iod->iod_rqlist, rqp, sr_link); - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); } else smb_iod_removerq(rqp); return error; @@ -539,21 +531,20 @@ smb_iod_sendall(struct smbiod *iod) struct smb_vc *vcp = iod->iod_vc; struct smb_rq *rqp; struct timespec ts, tstimeout; - smb_ilock ilock; int herror; herror = 0; /* * Loop through the list of requests and send them if possible */ - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); TAILQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) { switch (rqp->sr_state) { case SMBRQ_NOTSENT: rqp->sr_flags |= SMBR_XLOCK; - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); herror = smb_iod_sendrq(iod, rqp); - SMB_IOD_RQLOCK(&ilock, iod); + SMB_IOD_RQLOCK(iod); rqp->sr_flags &= ~SMBR_XLOCK; if (rqp->sr_flags & SMBR_XLOCKWANT) { rqp->sr_flags &= ~SMBR_XLOCKWANT; @@ -575,7 +566,7 @@ smb_iod_sendall(struct smbiod *iod) if (herror) break; } - SMB_IOD_RQUNLOCK(&ilock); + SMB_IOD_RQUNLOCK(iod); if (herror == ENOTCONN) smb_iod_dead(iod); return 0; @@ -591,7 +582,6 @@ smb_iod_main(struct smbiod *iod) struct smbiod_event *evp; /* struct timespec tsnow;*/ int error; - smb_ilock ilock; SMBIODEBUG("\n"); error = 0; @@ -600,15 +590,15 @@ smb_iod_main(struct smbiod *iod) * Check all interesting events */ for (;;) { - SMB_IOD_EVLOCK(&ilock, iod); + SMB_IOD_EVLOCK(iod); evp = STAILQ_FIRST(&iod->iod_evlist); if (evp == NULL) { - SMB_IOD_EVUNLOCK(&ilock); + SMB_IOD_EVUNLOCK(iod); break; } STAILQ_REMOVE_HEAD(&iod->iod_evlist, ev_link); evp->ev_type |= SMBIOD_EV_PROCESSING; - SMB_IOD_EVUNLOCK(&ilock); + SMB_IOD_EVUNLOCK(iod); switch (evp->ev_type & SMBIOD_EV_MASK) { case SMBIOD_EV_CONNECT: iod->iod_state = SMBIOD_ST_RECONNECT; @@ -627,9 +617,9 @@ smb_iod_main(struct smbiod *iod) break; } if (evp->ev_type & SMBIOD_EV_SYNC) { - SMB_IOD_EVLOCK(&ilock, iod); + SMB_IOD_EVLOCK(iod); wakeup(evp); - SMB_IOD_EVUNLOCK(&ilock); + SMB_IOD_EVUNLOCK(iod); } else free(evp, M_SMBIOD); } diff --git a/sys/netproto/smb/smb_rq.c b/sys/netproto/smb/smb_rq.c index d98e4b6169..b5d93a58f5 100644 --- a/sys/netproto/smb/smb_rq.c +++ b/sys/netproto/smb/smb_rq.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_rq.c,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.8 2004/06/02 14:43:03 eirikn Exp $ + * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.9 2005/12/06 04:03:56 dillon Exp $ */ #include #include @@ -172,24 +172,23 @@ smb_rq_enqueue(struct smb_rq *rqp) { struct smb_share *ssp = rqp->sr_share; int error; - smb_ilock ilock; if (ssp == NULL || rqp->sr_cred == &rqp->sr_vc->vc_iod->iod_scred) { return smb_iod_addrq(rqp); } for (;;) { - SMBS_ST_LOCK(&ilock, ssp); + SMBS_ST_LOCK(ssp); if (ssp->ss_flags & SMBS_RECONNECTING) { - smb_sleep(&ssp->ss_vcgenid, &ilock, + smb_sleep(&ssp->ss_vcgenid, SMBS_ST_INTERLOCK(ssp), PDROP, "90trcn", hz); if (smb_proc_intr(rqp->sr_cred->scr_td)) return EINTR; continue; } if (smb_share_valid(ssp) || (ssp->ss_flags & SMBS_CONNECTED) == 0) { - SMBS_ST_UNLOCK(&ilock); + SMBS_ST_UNLOCK(ssp); } else { - SMBS_ST_UNLOCK(&ilock); + SMBS_ST_UNLOCK(ssp); error = smb_iod_request(rqp->sr_vc->vc_iod, SMBIOD_EV_TREECONNECT | SMBIOD_EV_SYNC, ssp); if (error) @@ -439,7 +438,6 @@ smb_t2_reply(struct smb_t2rq *t2p) u_int16_t totpcount, totdcount, pcount, poff, doff, pdisp, ddisp; u_int16_t tmp, bc, dcount; u_int8_t wc; - smb_ilock ilock; error = smb_rq_reply(rqp); if (error) @@ -448,9 +446,9 @@ smb_t2_reply(struct smb_t2rq *t2p) /* * this is an interim response, ignore it. */ - SMBRQ_SLOCK(&ilock, rqp); + SMBRQ_SLOCK(rqp); md_next_record(&rqp->sr_rp); - SMBRQ_SUNLOCK(&ilock); + SMBRQ_SUNLOCK(rqp); return 0; } /* @@ -526,9 +524,9 @@ smb_t2_reply(struct smb_t2rq *t2p) /* * We're done with this reply, look for the next one. */ - SMBRQ_SLOCK(&ilock, rqp); + SMBRQ_SLOCK(rqp); md_next_record(&rqp->sr_rp); - SMBRQ_SUNLOCK(&ilock); + SMBRQ_SUNLOCK(rqp); error = smb_rq_reply(rqp); if (error) break; diff --git a/sys/netproto/smb/smb_rq.h b/sys/netproto/smb/smb_rq.h index 245c974c5b..9972a10476 100644 --- a/sys/netproto/smb/smb_rq.h +++ b/sys/netproto/smb/smb_rq.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_rq.h,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_rq.h,v 1.3 2004/03/01 06:33:18 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_rq.h,v 1.4 2005/12/06 04:03:56 dillon Exp $ */ #ifndef _NETSMB_SMB_RQ_H_ #define _NETSMB_SMB_RQ_H_ @@ -56,8 +56,9 @@ #define SMBT2_RESTART 0x0008 #define SMBT2_NORESTART 0x0010 -#define SMBRQ_SLOCK(ilock, rqp) smb_sl_lock(ilock, &(rqp)->sr_slock) -#define SMBRQ_SUNLOCK(ilock) smb_sl_unlock(ilock) +#define SMBRQ_SLOCK(rqp) smb_sl_lock(&(rqp)->sr_slock) +#define SMBRQ_SUNLOCK(rqp) smb_sl_unlock(&(rqp)->sr_slock) +#define SMBRQ_INTERLOCK(rqp) (&(rqp)->sr_slock) #define SMBRQ_SLOCKPTR(rqp) (&(rqp)->sr_slock) diff --git a/sys/netproto/smb/smb_subr.c b/sys/netproto/smb/smb_subr.c index 24a9bb4380..6311f6934d 100644 --- a/sys/netproto/smb/smb_subr.c +++ b/sys/netproto/smb/smb_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.c,v 1.1.2.2 2001/09/03 08:55:11 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.17 2005/12/03 21:01:03 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.18 2005/12/06 04:03:56 dillon Exp $ */ #include #include @@ -412,13 +412,13 @@ kthread_exit2(void) * since we blocked, so reget or release as appropriate. */ int -smb_sleep(void *chan, struct lwkt_tokref *ilock, int slpflags, const char *wmesg, int timo) +smb_sleep(void *chan, struct smb_slock *sl, int slpflags, const char *wmesg, int timo) { int error; error = tsleep(chan, slpflags, wmesg, timo); - if ((slpflags & PDROP) && ilock) - lwkt_reltoken(ilock); + if ((slpflags & PDROP) && sl) + smb_sl_unlock(sl); return error; } diff --git a/sys/netproto/smb/smb_subr.h b/sys/netproto/smb/smb_subr.h index 3ce2b41ddc..5047f5478f 100644 --- a/sys/netproto/smb/smb_subr.h +++ b/sys/netproto/smb/smb_subr.h @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.h,v 1.1.2.1 2001/05/22 08:32:34 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.h,v 1.11 2005/02/17 14:00:09 joerg Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.h,v 1.12 2005/12/06 04:03:56 dillon Exp $ */ #ifndef _NETSMB_SMB_SUBR_H_ #define _NETSMB_SMB_SUBR_H_ @@ -77,14 +77,15 @@ void m_dumpm(struct mbuf *m); #define smb_suser(cred) suser_cred(cred, 0) #include +#include +#include #define lockdestroy(lock) -#define smb_slock lwkt_token -#define smb_ilock lwkt_tokref -#define smb_sl_init(tok, desc) lwkt_token_init(tok) -#define smb_sl_destroy(tok) -#define smb_sl_lock(ilock, tok) lwkt_gettoken(ilock, tok) -#define smb_sl_unlock(ilock) lwkt_reltoken(ilock) +#define smb_slock spinlock +#define smb_sl_init(sl, desc) spin_init(sl) +#define smb_sl_destroy(sl) +#define smb_sl_lock(sl) spin_lock(sl) +#define smb_sl_unlock(sl) spin_unlock(sl) #define SMB_STRFREE(p) do { if (p) smb_strfree(p); } while(0) @@ -173,7 +174,7 @@ int smb_put_asunistring(struct smb_rq *rqp, const char *src); int kthread_create2(void (*func)(void *), void *arg, struct proc **newpp, int flags, const char *fmt, ...); void kthread_exit2(void); -int smb_sleep(void *chan, struct lwkt_tokref *ilock, int slpflags, const char *wmesg, int timo); +int smb_sleep(void *chan, struct smb_slock *sl, int slpflags, const char *wmesg, int timo); #endif /* !_NETSMB_SMB_SUBR_H_ */ -- 2.41.0