Skip to content

Commit a830452

Browse files
ying-xuedavem330
authored andcommitted
tipc: remove bearer_lock from tipc_bearer struct
After the earlier commits ("tipc: remove 'links' list from tipc_bearer struct") and ("tipc: introduce new spinlock to protect struct link_req"), there is no longer any need to protect struct link_req or or any link list by use of bearer_lock. Furthermore, we have eliminated the need for using bearer_lock during downcalls (send) from the link to the bearer, since we have ensured that bearers always have a longer life cycle that their associated links, and always contain valid data. So, the only need now for a lock protecting bearers is for guaranteeing consistency of the bearer list itself. For this, it is sufficient, at least for the time being, to continue applying 'net_lock´ in write mode. By removing bearer_lock we also pre-empt introduction of issue b) descibed in the previous commit "tipc: remove 'links' list from tipc_bearer struct": "b) When the outer protection from net_lock is gone, taking bearer_lock and node_lock in opposite order of method 1) and 2) will become an obvious deadlock hazard". Therefore, we now eliminate the bearer_lock spinlock. Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7d33939 commit a830452

3 files changed

Lines changed: 4 additions & 18 deletions

File tree

‎net/tipc/bcast.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,6 @@ void tipc_bclink_init(void)
785785
bcl->owner = &bclink->node;
786786
bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
787787
tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
788-
spin_lock_init(&bcbearer->bearer.lock);
789788
bcl->b_ptr = &bcbearer->bearer;
790789
bcl->state = WORKING_WORKING;
791790
strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);

‎net/tipc/bearer.c‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ int tipc_enable_bearer(const char *name, u32 disc_domain, u32 priority)
327327
b_ptr->net_plane = bearer_id + 'A';
328328
b_ptr->active = 1;
329329
b_ptr->priority = priority;
330-
spin_lock_init(&b_ptr->lock);
331330

332331
res = tipc_disc_create(b_ptr, &b_ptr->bcast_addr, disc_domain);
333332
if (res) {
@@ -351,9 +350,7 @@ static int tipc_reset_bearer(struct tipc_bearer *b_ptr)
351350
{
352351
read_lock_bh(&tipc_net_lock);
353352
pr_info("Resetting bearer <%s>\n", b_ptr->name);
354-
spin_lock_bh(&b_ptr->lock);
355353
tipc_link_reset_list(b_ptr->identity);
356-
spin_unlock_bh(&b_ptr->lock);
357354
read_unlock_bh(&tipc_net_lock);
358355
return 0;
359356
}
@@ -365,19 +362,12 @@ static int tipc_reset_bearer(struct tipc_bearer *b_ptr)
365362
*/
366363
static void bearer_disable(struct tipc_bearer *b_ptr, bool shutting_down)
367364
{
368-
struct tipc_link_req *temp_req;
369-
370365
pr_info("Disabling bearer <%s>\n", b_ptr->name);
371-
spin_lock_bh(&b_ptr->lock);
372366
b_ptr->media->disable_media(b_ptr);
373-
tipc_link_delete_list(b_ptr->identity, shutting_down);
374-
temp_req = b_ptr->link_req;
375-
b_ptr->link_req = NULL;
376-
spin_unlock_bh(&b_ptr->lock);
377-
378-
if (temp_req)
379-
tipc_disc_delete(temp_req);
380367

368+
tipc_link_delete_list(b_ptr->identity, shutting_down);
369+
if (b_ptr->link_req)
370+
tipc_disc_delete(b_ptr->link_req);
381371
memset(b_ptr, 0, sizeof(struct tipc_bearer));
382372
}
383373

‎net/tipc/bearer.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ struct tipc_media {
107107

108108
/**
109109
* struct tipc_bearer - Generic TIPC bearer structure
110-
* @dev: ptr to associated network device
111-
* @usr_handle: pointer to additional media-specific information about bearer
110+
* @media_ptr: pointer to additional media-specific information about bearer
112111
* @mtu: max packet size bearer can support
113-
* @lock: spinlock for controlling access to bearer
114112
* @addr: media-specific address associated with bearer
115113
* @name: bearer name (format = media:interface)
116114
* @media: ptr to media structure associated with bearer
@@ -133,7 +131,6 @@ struct tipc_bearer {
133131
u32 mtu; /* initalized by media */
134132
struct tipc_media_addr addr; /* initalized by media */
135133
char name[TIPC_MAX_BEARER_NAME];
136-
spinlock_t lock;
137134
struct tipc_media *media;
138135
struct tipc_media_addr bcast_addr;
139136
u32 priority;

0 commit comments

Comments
 (0)