|
From: Erik H. <eri...@er...> - 2013-10-24 11:34:43
|
On Mon, Sep 30, 2013 at 04:38:13PM +0800, Ying Xue wrote: > The 'blocked' flag in struct tipc_bearer is currently protected by > a big spinlock aggregated into tipc_bearer. We want to reduce all > dependencies to this lock, as part of our effort to make the locking > policy simpler and more manageable. > > Furthermore, the functions tipc_disc_recv_msg() and disc_send_msg() > access the flag without taking this lock at all, implying a risk that > they may occasionally obtain a wrong value and drop sending/receiving > of discovery messages. Since discovery messages are timer driven and > best-effort, the latter problem is not fatal, but it is clearly avoidable. > > By converting the type of the flag from int to atomic_t we eliminate > both the spinlock dependency and the current race condition. > > We also make two small code changes: > > 1) The functions tipc_continue() and bearer_blocked() now become > one-liners doing a single access to the flag. So we just remove > those redundant functions. > > 2) The initialization of the flag is moved from the enable_media() > functions in ib_media.c and eth_media.c respecively, to the generic > tipc_enable_bearer() function, so that it is done in one place only. > > Signed-off-by: Ying Xue <yin...@wi...> Also, recent findings (off-list discussion) that we disobey the locking rules of del_timer_sync by holding the same spinlock in the timer handler as when we delete the timer, leading to deadlocks during bearer disable.. Acked-by: Erik Hugne <eri...@er...> |