diff options
author | Ying Xue <ying.xue@windriver.com> | 2017-03-28 06:28:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-03-28 21:03:32 -0400 |
commit | 139bb36f754adbf6d3c836db09d6459e25167b38 (patch) | |
tree | 67aaf23ea8b620ffeba8fd79273d480811b8cf5c /net/tipc | |
parent | 589a1a2e63163bdd59f983d6cd89cec5f9457823 (diff) |
tipc: advance the time of deleting subscription from subscriber->subscrp_list
After a subscription object is created, it's inserted into its
subscriber subscrp_list list under subscriber lock protection,
similarly, before it's destroyed, it should be first removed from
its subscriber->subscrp_list. Since the subscription list is
accessed with subscriber lock, all the subscriptions are valid
during the lock duration. Hence in tipc_subscrb_subscrp_delete(), we
remove subscription get/put and the extra subscriber unlock/lock.
After this change, the subscriptions refcount cleanup is very simple
and does not access any lock.
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/subscr.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 271cd66e4b3b..0649bc29c6bb 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -145,6 +145,7 @@ static void tipc_subscrp_timeout(unsigned long data) | |||
145 | 145 | ||
146 | spin_lock_bh(&subscriber->lock); | 146 | spin_lock_bh(&subscriber->lock); |
147 | tipc_nametbl_unsubscribe(sub); | 147 | tipc_nametbl_unsubscribe(sub); |
148 | list_del(&sub->subscrp_list); | ||
148 | spin_unlock_bh(&subscriber->lock); | 149 | spin_unlock_bh(&subscriber->lock); |
149 | 150 | ||
150 | /* Notify subscriber of timeout */ | 151 | /* Notify subscriber of timeout */ |
@@ -177,10 +178,7 @@ static void tipc_subscrp_kref_release(struct kref *kref) | |||
177 | struct tipc_net *tn = net_generic(sub->net, tipc_net_id); | 178 | struct tipc_net *tn = net_generic(sub->net, tipc_net_id); |
178 | struct tipc_subscriber *subscriber = sub->subscriber; | 179 | struct tipc_subscriber *subscriber = sub->subscriber; |
179 | 180 | ||
180 | spin_lock_bh(&subscriber->lock); | ||
181 | list_del(&sub->subscrp_list); | ||
182 | atomic_dec(&tn->subscription_count); | 181 | atomic_dec(&tn->subscription_count); |
183 | spin_unlock_bh(&subscriber->lock); | ||
184 | kfree(sub); | 182 | kfree(sub); |
185 | tipc_subscrb_put(subscriber); | 183 | tipc_subscrb_put(subscriber); |
186 | } | 184 | } |
@@ -210,11 +208,8 @@ static void tipc_subscrb_subscrp_delete(struct tipc_subscriber *subscriber, | |||
210 | continue; | 208 | continue; |
211 | 209 | ||
212 | tipc_nametbl_unsubscribe(sub); | 210 | tipc_nametbl_unsubscribe(sub); |
213 | tipc_subscrp_get(sub); | 211 | list_del(&sub->subscrp_list); |
214 | spin_unlock_bh(&subscriber->lock); | ||
215 | tipc_subscrp_delete(sub); | 212 | tipc_subscrp_delete(sub); |
216 | tipc_subscrp_put(sub); | ||
217 | spin_lock_bh(&subscriber->lock); | ||
218 | 213 | ||
219 | if (s) | 214 | if (s) |
220 | break; | 215 | break; |