From: Guo, M. <mi...@in...> - 2004-01-15 09:23:35
|
Hi, Jon: I found there are really too many parts to be updated in the unstable = tree. here I clean up some bug.the attached is the patch.=20 Maybe the code cleanup is the highest priority tasks, in order to not = collide with your patch, I sent the patch to you firstly.If you agree, I would like = to apply them to the current stable=20 tree,how about your opinion? Thanks Guo Min=20 The content of this email message solely contains my own personal views, and not those of my employer. =20 ----------------------------------- Index: buf.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/buf.c,v retrieving revision 1.3 diff -u -r1.3 buf.c --- buf.c 4 Dec 2003 02:22:20 -0000 1.3 +++ buf.c 15 Jan 2004 09:11:22 -0000 @@ -85,16 +85,16 @@ UB(crs)->pool =3D pool; buf_set_next(crs,0); if (pool){ - spin_lock_bh(buf_lock); + spin_lock_bh(&buf_lock); buf_set_next(crs,*pool); *pool =3D crs; - spin_unlock_bh(buf_lock); + spin_unlock_bh(&buf_lock); } } if (pool){ - spin_lock_bh(buf_lock); + spin_lock_bh(&buf_lock); *pool =3D buf_next(crs); - spin_unlock_bh(buf_lock); + spin_unlock_bh(&buf_lock); } buf_set_next(crs, 0); return crs; Index: dbg.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/dbg.c,v retrieving revision 1.1 diff -u -r1.1 dbg.c --- dbg.c 4 Dec 2003 02:22:20 -0000 1.1 +++ dbg.c 15 Jan 2004 09:11:22 -0000 @@ -135,6 +135,7 @@ spin_lock_bh(&print_lock); if (b->tee[0]) { err("Init on TEE buffer\n"); + spin_unlock_bh(&print_lock); return; } memset(raw, 0, sz); @@ -161,7 +162,7 @@ if (buf->tee[0]) { targets[0] =3D buf->tee[0]; targets[1] =3D buf->tee[1]; - kfree(buf); + //kfree(buf); } else { targets[0] =3D buf; targets[1] =3D 0; =20 Index: handler.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/handler.c,v retrieving revision 1.4 diff -u -r1.4 handler.c --- handler.c 4 Dec 2003 02:22:20 -0000 1.4 +++ handler.c 15 Jan 2004 09:11:23 -0000 @@ -187,6 +187,7 @@ struct queue_item *item; =20 spin_lock_bh(&qitem_lock); +=09 item =3D (struct queue_item *) __get_queue_item(); item->handler =3D routine; item->data =3D eventInfo; @@ -197,8 +198,10 @@ signal_queue_head =3D item; } signal_queue_tail =3D item; +=09 spin_unlock_bh(&qitem_lock); - tasklet_schedule(&tipc_tasklet); +=09 return 0; } =20 Index: link.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/link.c,v retrieving revision 1.2 diff -u -r1.2 link.c --- link.c 11 Dec 2003 19:44:47 -0000 1.2 +++ link.c 15 Jan 2004 09:11:24 -0000 @@ -1406,19 +1406,19 @@ head =3D = link_insert_deferred_queue(this,head); if (likely(msg_is_dest(msg,tipc_own_addr))){ if (likely(msg_isdata(msg))) { - = spin_unlock_bh(this->owner->lock); + = spin_unlock_bh(&this->owner->lock); port_recv_msg(buf); continue; } link_recv_non_data_msg(this, buf); continue; } - spin_unlock_bh(this->owner->lock); + spin_unlock_bh(&this->owner->lock); net_route_msg(buf); continue; } link_handle_non_seq_msg(this, buf); - spin_unlock_bh(this->owner->lock); + spin_unlock_bh(&this->owner->lock); continue; } =20 @@ -1431,7 +1431,7 @@ else buf_discard(buf); =20 - spin_unlock_bh(this->owner->lock); + spin_unlock_bh(&this->owner->lock); continue; } } Index: link.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/link.h,v retrieving revision 1.1 diff -u -r1.1 link.h --- link.h 4 Dec 2003 02:22:20 -0000 1.1 +++ link.h 15 Jan 2004 09:11:24 -0000 @@ -270,11 +270,11 @@ struct node *node =3D node_find(addr); if (likely(node)){ struct link* l; - spin_lock_bh(node->lock); + spin_lock_bh(&node->lock); l =3D node->links[bearer_id]; if (likely(l)) return l; - spin_unlock_bh(node->lock); + spin_unlock_bh(&node->lock); } return 0; } =20 Index: port.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/port.c,v retrieving revision 1.1 diff -u -r1.1 port.c --- port.c 4 Dec 2003 02:22:20 -0000 1.1 +++ port.c 15 Jan 2004 09:11:25 -0000 @@ -751,13 +751,13 @@ port_dispatcher_sigh(buf); return 1; } - spin_lock_bh(queue_lock); + spin_lock_bh(&queue_lock); if (msg_queue_head) buf_set_next(msg_queue_tail, buf); else msg_queue_head =3D buf; msg_queue_tail =3D buf; - spin_lock_bh(queue_lock); + spin_lock_bh(&queue_lock); k_signal((Handler)port_dispatcher_sigh, 0); return 1; } @@ -1272,10 +1272,10 @@ { struct port* p =3D ports; struct sk_buff* b; - spin_lock_bh(queue_lock); + spin_lock_bh(&queue_lock); b =3D msg_queue_head; msg_queue_head =3D 0; - spin_unlock_bh(queue_lock); + spin_unlock_bh(&queue_lock); while (b) { struct sk_buff *next =3D buf_next(b); buf_discard(b); Index: reg.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/reg.c,v retrieving revision 1.1 diff -u -r1.1 reg.c --- reg.c 4 Dec 2003 02:22:20 -0000 1.1 +++ reg.c 15 Jan 2004 09:11:25 -0000 @@ -182,7 +182,7 @@ return TIPC_FAILURE; if (p->reg_ref =3D=3D 0) return TIPC_OK; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); user =3D &users[ref]; p->reg_ref =3D ref; p->prev =3D 0; @@ -190,7 +190,7 @@ if (p->next) p->next->prev =3D p; user->ports =3D p; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); return TIPC_OK; } =20 @@ -203,7 +203,7 @@ return TIPC_FAILURE; if (p->reg_ref =3D=3D 0) return TIPC_OK; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); user =3D &users[p->reg_ref]; if (p->prev) p->prev->next =3D p->next; @@ -211,7 +211,7 @@ user->ports =3D p->next; if (p->next) p->next->prev =3D p->prev; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); return TIPC_OK; } =20 @@ -225,7 +225,7 @@ return TIPC_FAILURE; if (s->reg.ref =3D=3D 0) return TIPC_OK; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); user =3D &users[s->reg.ref]; s->reg.ref =3D ref; s->reg.prev =3D 0; @@ -233,7 +233,7 @@ if (s->reg.next) s->reg.next->reg.prev =3D s; user->subs =3D s; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); return TIPC_OK; } =20 @@ -246,7 +246,7 @@ return TIPC_FAILURE; if (s->reg.ref =3D=3D 0) return TIPC_OK; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); user =3D &users[s->reg.ref]; if (s->reg.prev) s->reg.prev->reg.next =3D s->reg.next; @@ -254,21 +254,21 @@ user->subs =3D s->reg.next; if (s->next) s->reg.next->reg.prev =3D s->reg.prev; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); return TIPC_OK; } =20 static void reg_init(void) { uint i =3D 1; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); users =3D (struct tipc_user*)k_malloc(sizeof(struct = tipc_user)); memset(users, 0, sizeof (users)); for (i =3D 1; i <=3D MAX_USERID; i++) { users[i].next =3D i - 1; } next_free_user =3D MAX_USERID; - spin_lock_bh(reg_lock); + spin_unlock_bh(®_lock); } =20 =20 @@ -290,10 +290,10 @@ { struct tipc_user *user =3D (struct tipc_user *) u; tipc_started_event cb; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); cb =3D user->callback; user->callback =3D 0; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); if (!cb) return; user->callback(user->usr_handle); @@ -343,7 +343,7 @@ struct name_subscr* s =3D 0; struct user_port* p =3D 0; struct tipc_user *user; - spin_lock_bh(reg_lock); + spin_lock_bh(®_lock); user =3D &users[userid]; =20 if (!user->next){ s =3D user->subs; @@ -352,7 +352,7 @@ user->ports =3D 0; user->next =3D next_free_user; next_free_user =3D userid; - spin_unlock_bh(reg_lock); + spin_unlock_bh(®_lock); } while (s) { tipc_unsubscribe(s->publ.s.ref); =20 Index: socket.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/socket.c,v retrieving revision 1.2 diff -u -r1.2 socket.c --- socket.c 4 Dec 2003 03:02:57 -0000 1.2 +++ socket.c 15 Jan 2004 09:11:25 -0000 @@ -277,9 +277,9 @@ struct sk_buff *buf; if (!tsk) return 0; - spin_lock_bh(tsk); + sock_lock(tsk); if (!sock->sk) { - spin_unlock_bh(tsk); + sock_unlock(tsk); return 0; } sock->sk =3D NULL; @@ -304,7 +304,7 @@ } =20 res =3D tipc_deleteport(tsk->p->ref); - spin_unlock_bh(tsk); + sock_unlock(tsk); kfree(tsk); reset_protinfo(sk); sk_free(sk); @@ -323,7 +323,7 @@ return -EFAULT; if (i_sock_lock(tsk)) return -ERESTARTSYS; - if (addr->addrtype !=3D TIPC_ADDR_NAMESEQ) + if (addr->addrtype =3D=3D TIPC_ADDR_NAMESEQ) res =3D tipc_publish_nameseq(tsk->p->ref, tsk->bind_scope, &addr->addr.nameseq); @@ -333,7 +333,7 @@ tsk->bind_scope, &addr->addr.nameseq); } - spin_unlock_bh(tsk); + sock_unlock(tsk); return res ? -EINVAL : 0; } =20 @@ -350,7 +350,7 @@ res =3D tipc_connect2port(tsk->p->ref, &addr->addr.id); if (res =3D=3D TIPC_OK) sk->state =3D SS_CONNECTED; - spin_unlock_bh(tsk); + sock_unlock(tsk); return res ? -EFAULT : 0; } =20 @@ -407,6 +407,7 @@ tipc_ref_t new_ref =3D new_tsk->p->ref; id.ref =3D msg_origport(buf_msg(buf)); id.node =3D msg_orignode(buf_msg(buf)); + user_lock(&tsk->p->lock); tipc_connect2port(new_ref, &id); tipc_setportimportance(new_ref,msg_importance(msg)); tsk->queue_head =3D buf_next(buf); @@ -421,7 +422,7 @@ user_unlock(&tsk->p->lock); } exit: - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -448,7 +449,7 @@ } else res =3D -EFAULT; *uaddr_len =3D sizeof (*addr); - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -462,7 +463,7 @@ return -ERESTARTSYS; sock->state =3D SS_UNCONNECTED; res =3D tipc_disconnect(tsk->p->ref); - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -492,7 +493,7 @@ for (; section < scount; size +=3D sseq[section].size, section++) { } if (unlikely(size > TIPC_MAX_DATA_SIZE)) { - spin_unlock_bh(tsk); + sock_unlock(tsk); return -EINVAL; } =20 @@ -509,7 +510,7 @@ =20 if (unlikely(tsk->pollmask & CONNECTION_ABORTED)) { user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); buf_discard(buf); return -ECONNABORTED; } @@ -534,7 +535,7 @@ =20 if (likely(res =3D=3D TIPC_OK)) { exit: - spin_unlock_bh(tsk); + sock_unlock(tsk); return size; } =20 @@ -560,7 +561,7 @@ } error_locked: error_non_locked: - spin_unlock_bh(tsk); + sock_unlock(tsk); buf_discard(buf); return res; } @@ -618,13 +619,13 @@ if (unlikely (wait_event_interruptible(tsk->waitqueue, tsk->queue_head))) { return -ERESTARTSYS; - spin_unlock_bh(tsk); + sock_unlock(tsk); } buf =3D tsk->queue_head; =20 if (unlikely(tsk->pollmask & MSG_ERROR)) { user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); return -1; } =20 @@ -689,7 +690,7 @@ } =20 recvmsg_exit: - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -811,7 +812,7 @@ } } user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -881,7 +882,7 @@ } } user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); return !!res; } =20 @@ -926,12 +927,12 @@ s->usr_next =3D tsk->sub_list; tsk->sub_list =3D s; user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); put_user(s->s.ref, &((struct tipc_subscr *) arg)->ref); return 0; } user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); return -EINVAL; =20 } @@ -964,7 +965,7 @@ } user_unlock(&tsk->p->lock); } - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; } =20 @@ -1013,7 +1014,7 @@ tsk->pollmask |=3D tsk->ev_head->ev.event; =20 user_unlock(&tsk->p->lock); - spin_unlock_bh(tsk); + sock_unlock(tsk); return res; =20 } Index: tipc_buf.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/tipc/source/unstable/net/tipc/tipc_buf.h,v retrieving revision 1.3 diff -u -r1.3 tipc_buf.h --- tipc_buf.h 4 Dec 2003 02:22:20 -0000 1.3 +++ tipc_buf.h 15 Jan 2004 09:11:25 -0000 @@ -169,12 +169,12 @@ static inline void buf_discard(struct sk_buff *skb) { if (likely(UB(skb)->pool)) { - spin_lock_bh(buf_lock); + spin_lock_bh(&buf_lock); skb->nh.raw =3D skb->data =3D UB(skb)->data =3D skb->head + BUF_HEADROOM; buf_set_next(skb, *(UB(skb)->pool)); *(UB(skb)->pool) =3D skb; - spin_unlock_bh(buf_lock); + spin_unlock_bh(&buf_lock); return; } kfree_skb(skb); @@ -184,17 +184,17 @@ { struct sk_buff *skb; if (likely(size <=3D SMALL_POOL_MSG_SIZE)) { - spin_lock_bh(buf_lock); + spin_lock_bh(&buf_lock); skb =3D small_pool; if (likely(skb)) { small_pool =3D buf_next(skb); - spin_unlock_bh(buf_lock); + spin_unlock_bh(&buf_lock); return skb; } - spin_unlock_bh(buf_lock); + spin_unlock_bh(&buf_lock); return acquire_bufs(SMALL_POOL_MSG_SIZE, 40, &small_pool); } else if (size <=3D MEDIUM_POOL_MSG_SIZE) { - spin_lock_bh(buf_lock); + spin_lock_bh(&buf_lock); skb =3D big_pool; if (skb) { big_pool =3D buf_next(skb); <<tipc_unstable_spinlock.diff>>=20 |