Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: rename functions defined in subscr.c

When a topology server accepts a connection request from its client,
it allocates a connection instance and a tipc_subscriber structure
object. The former is used to communicate with client, and the latter
is often treated as a subscriber which manages all subscription events
requested from a same client. When a topology server receives a request
of subscribing name services from a client through the connection, it
creates a tipc_subscription structure instance which is seen as a
subscription recording what name services are subscribed. In order to
manage all subscriptions from a same client, topology server links
them into the subscrp_list of the subscriber. So subscriber and
subscription completely represents different meanings respectively,
but function names associated with them make us so confused that we
are unable to easily tell which function is against subscriber and
which is to subscription. So we want to eliminate the confusion by
renaming them.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ying Xue and committed by
David S. Miller
57f1d186 29a1ff65

+75 -97
+2 -2
net/tipc/core.c
··· 68 68 if (err) 69 69 goto out_nametbl; 70 70 71 - err = tipc_subscr_start(net); 71 + err = tipc_topsrv_start(net); 72 72 if (err) 73 73 goto out_subscr; 74 74 return 0; ··· 83 83 84 84 static void __net_exit tipc_exit_net(struct net *net) 85 85 { 86 - tipc_subscr_stop(net); 86 + tipc_topsrv_stop(net); 87 87 tipc_net_stop(net); 88 88 tipc_nametbl_stop(net); 89 89 tipc_sk_rht_destroy(net);
+12 -22
net/tipc/name_table.c
··· 330 330 331 331 /* Any subscriptions waiting for notification? */ 332 332 list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { 333 - tipc_subscr_report_overlap(s, 334 - publ->lower, 335 - publ->upper, 336 - TIPC_PUBLISHED, 337 - publ->ref, 338 - publ->node, 339 - created_subseq); 333 + tipc_subscrp_report_overlap(s, publ->lower, publ->upper, 334 + TIPC_PUBLISHED, publ->ref, 335 + publ->node, created_subseq); 340 336 } 341 337 return publ; 342 338 } ··· 400 404 401 405 /* Notify any waiting subscriptions */ 402 406 list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { 403 - tipc_subscr_report_overlap(s, 404 - publ->lower, 405 - publ->upper, 406 - TIPC_WITHDRAWN, 407 - publ->ref, 408 - publ->node, 409 - removed_subseq); 407 + tipc_subscrp_report_overlap(s, publ->lower, publ->upper, 408 + TIPC_WITHDRAWN, publ->ref, 409 + publ->node, removed_subseq); 410 410 } 411 411 412 412 return publ; ··· 424 432 return; 425 433 426 434 while (sseq != &nseq->sseqs[nseq->first_free]) { 427 - if (tipc_subscr_overlap(s, sseq->lower, sseq->upper)) { 435 + if (tipc_subscrp_check_overlap(s, sseq->lower, sseq->upper)) { 428 436 struct publication *crs; 429 437 struct name_info *info = sseq->info; 430 438 int must_report = 1; 431 439 432 440 list_for_each_entry(crs, &info->zone_list, zone_list) { 433 - tipc_subscr_report_overlap(s, 434 - sseq->lower, 435 - sseq->upper, 436 - TIPC_PUBLISHED, 437 - crs->ref, 438 - crs->node, 439 - must_report); 441 + tipc_subscrp_report_overlap(s, sseq->lower, 442 + sseq->upper, 443 + TIPC_PUBLISHED, 444 + crs->ref, crs->node, 445 + must_report); 440 446 must_report = 0; 441 447 } 442 448 }
+52 -64
net/tipc/subscr.c
··· 42 42 * struct tipc_subscriber - TIPC network topology subscriber 43 43 * @conid: connection identifier to server connecting to subscriber 44 44 * @lock: control access to subscriber 45 - * @subscription_list: list of subscription objects for this subscriber 45 + * @subscrp_list: list of subscription objects for this subscriber 46 46 */ 47 47 struct tipc_subscriber { 48 48 int conid; 49 49 spinlock_t lock; 50 - struct list_head subscription_list; 50 + struct list_head subscrp_list; 51 51 }; 52 52 53 53 /** ··· 62 62 return swap ? swab32(in) : in; 63 63 } 64 64 65 - static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower, 66 - u32 found_upper, u32 event, u32 port_ref, 67 - u32 node) 65 + static void tipc_subscrp_send_event(struct tipc_subscription *sub, 66 + u32 found_lower, u32 found_upper, 67 + u32 event, u32 port_ref, u32 node) 68 68 { 69 69 struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 70 70 struct tipc_subscriber *subscriber = sub->subscriber; ··· 82 82 } 83 83 84 84 /** 85 - * tipc_subscr_overlap - test for subscription overlap with the given values 85 + * tipc_subscrp_check_overlap - test for subscription overlap with the 86 + * given values 86 87 * 87 88 * Returns 1 if there is overlap, otherwise 0. 88 89 */ 89 - int tipc_subscr_overlap(struct tipc_subscription *sub, u32 found_lower, 90 - u32 found_upper) 90 + int tipc_subscrp_check_overlap(struct tipc_subscription *sub, u32 found_lower, 91 + u32 found_upper) 91 92 { 92 93 if (found_lower < sub->seq.lower) 93 94 found_lower = sub->seq.lower; ··· 99 98 return 1; 100 99 } 101 100 102 - /** 103 - * tipc_subscr_report_overlap - issue event if there is subscription overlap 104 - * 105 - * Protected by nameseq.lock in name_table.c 106 - */ 107 - void tipc_subscr_report_overlap(struct tipc_subscription *sub, u32 found_lower, 108 - u32 found_upper, u32 event, u32 port_ref, 109 - u32 node, int must) 101 + void tipc_subscrp_report_overlap(struct tipc_subscription *sub, u32 found_lower, 102 + u32 found_upper, u32 event, u32 port_ref, 103 + u32 node, int must) 110 104 { 111 - if (!tipc_subscr_overlap(sub, found_lower, found_upper)) 105 + if (!tipc_subscrp_check_overlap(sub, found_lower, found_upper)) 112 106 return; 113 107 if (!must && !(sub->filter & TIPC_SUB_PORTS)) 114 108 return; 115 109 116 - subscr_send_event(sub, found_lower, found_upper, event, port_ref, node); 110 + tipc_subscrp_send_event(sub, found_lower, found_upper, event, port_ref, 111 + node); 117 112 } 118 113 119 - static void subscr_timeout(unsigned long data) 114 + static void tipc_subscrp_timeout(unsigned long data) 120 115 { 121 116 struct tipc_subscription *sub = (struct tipc_subscription *)data; 122 117 struct tipc_subscriber *subscriber = sub->subscriber; ··· 131 134 tipc_nametbl_unsubscribe(sub); 132 135 133 136 /* Unlink subscription from subscriber */ 134 - list_del(&sub->subscription_list); 137 + list_del(&sub->subscrp_list); 135 138 136 139 spin_unlock_bh(&subscriber->lock); 137 140 138 141 /* Notify subscriber of timeout */ 139 - subscr_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, 140 - TIPC_SUBSCR_TIMEOUT, 0, 0); 142 + tipc_subscrp_send_event(sub, sub->evt.s.seq.lower, sub->evt.s.seq.upper, 143 + TIPC_SUBSCR_TIMEOUT, 0, 0); 141 144 142 145 /* Now destroy subscription */ 143 146 kfree(sub); 144 147 atomic_dec(&tn->subscription_count); 145 148 } 146 149 147 - /** 148 - * subscr_del - delete a subscription within a subscription list 149 - * 150 - * Called with subscriber lock held. 151 - */ 152 - static void subscr_del(struct tipc_subscription *sub) 150 + static void tipc_subscrp_delete(struct tipc_subscription *sub) 153 151 { 154 152 struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 155 153 156 154 tipc_nametbl_unsubscribe(sub); 157 - list_del(&sub->subscription_list); 155 + list_del(&sub->subscrp_list); 158 156 kfree(sub); 159 157 atomic_dec(&tn->subscription_count); 160 158 } 161 159 162 - static void subscr_release(struct tipc_subscriber *subscriber) 160 + static void tipc_subscrb_delete(struct tipc_subscriber *subscriber) 163 161 { 164 162 struct tipc_subscription *sub; 165 163 struct tipc_subscription *sub_temp; ··· 162 170 spin_lock_bh(&subscriber->lock); 163 171 164 172 /* Destroy any existing subscriptions for subscriber */ 165 - list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, 166 - subscription_list) { 173 + list_for_each_entry_safe(sub, sub_temp, &subscriber->subscrp_list, 174 + subscrp_list) { 167 175 if (sub->timeout != TIPC_WAIT_FOREVER) { 168 176 spin_unlock_bh(&subscriber->lock); 169 177 del_timer_sync(&sub->timer); 170 178 spin_lock_bh(&subscriber->lock); 171 179 } 172 - subscr_del(sub); 180 + tipc_subscrp_delete(sub); 173 181 } 174 182 spin_unlock_bh(&subscriber->lock); 175 183 ··· 178 186 } 179 187 180 188 /** 181 - * subscr_cancel - handle subscription cancellation request 189 + * tipc_subscrp_cancel - handle subscription cancellation request 182 190 * 183 191 * Called with subscriber lock held. Routine must temporarily release lock 184 192 * to enable the subscription timeout routine to finish without deadlocking; ··· 186 194 * 187 195 * Note that fields of 's' use subscriber's endianness! 188 196 */ 189 - static void subscr_cancel(struct tipc_subscr *s, 190 - struct tipc_subscriber *subscriber) 197 + static void tipc_subscrp_cancel(struct tipc_subscr *s, 198 + struct tipc_subscriber *subscriber) 191 199 { 192 200 struct tipc_subscription *sub; 193 201 struct tipc_subscription *sub_temp; 194 202 int found = 0; 195 203 196 204 /* Find first matching subscription, exit if not found */ 197 - list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, 198 - subscription_list) { 205 + list_for_each_entry_safe(sub, sub_temp, &subscriber->subscrp_list, 206 + subscrp_list) { 199 207 if (!memcmp(s, &sub->evt.s, sizeof(struct tipc_subscr))) { 200 208 found = 1; 201 209 break; ··· 211 219 del_timer_sync(&sub->timer); 212 220 spin_lock_bh(&subscriber->lock); 213 221 } 214 - subscr_del(sub); 222 + tipc_subscrp_delete(sub); 215 223 } 216 224 217 - /** 218 - * subscr_subscribe - create subscription for subscriber 219 - * 220 - * Called with subscriber lock held. 221 - */ 222 - static int subscr_subscribe(struct net *net, struct tipc_subscr *s, 223 - struct tipc_subscriber *subscriber, 224 - struct tipc_subscription **sub_p) 225 + static int tipc_subscrp_create(struct net *net, struct tipc_subscr *s, 226 + struct tipc_subscriber *subscriber, 227 + struct tipc_subscription **sub_p) 225 228 { 226 229 struct tipc_net *tn = net_generic(net, tipc_net_id); 227 230 struct tipc_subscription *sub; ··· 228 241 /* Detect & process a subscription cancellation request */ 229 242 if (s->filter & htohl(TIPC_SUB_CANCEL, swap)) { 230 243 s->filter &= ~htohl(TIPC_SUB_CANCEL, swap); 231 - subscr_cancel(s, subscriber); 244 + tipc_subscrp_cancel(s, subscriber); 232 245 return 0; 233 246 } 234 247 ··· 260 273 kfree(sub); 261 274 return -EINVAL; 262 275 } 263 - list_add(&sub->subscription_list, &subscriber->subscription_list); 276 + list_add(&sub->subscrp_list, &subscriber->subscrp_list); 264 277 sub->subscriber = subscriber; 265 278 sub->swap = swap; 266 - memcpy(&sub->evt.s, s, sizeof(struct tipc_subscr)); 279 + memcpy(&sub->evt.s, s, sizeof(*s)); 267 280 atomic_inc(&tn->subscription_count); 268 281 if (sub->timeout != TIPC_WAIT_FOREVER) { 269 - setup_timer(&sub->timer, subscr_timeout, (unsigned long)sub); 282 + setup_timer(&sub->timer, tipc_subscrp_timeout, 283 + (unsigned long)sub); 270 284 mod_timer(&sub->timer, jiffies + sub->timeout); 271 285 } 272 286 *sub_p = sub; ··· 275 287 } 276 288 277 289 /* Handle one termination request for the subscriber */ 278 - static void subscr_conn_shutdown_event(int conid, void *usr_data) 290 + static void tipc_subscrb_shutdown_cb(int conid, void *usr_data) 279 291 { 280 - subscr_release((struct tipc_subscriber *)usr_data); 292 + tipc_subscrb_delete((struct tipc_subscriber *)usr_data); 281 293 } 282 294 283 295 /* Handle one request to create a new subscription for the subscriber */ 284 - static void subscr_conn_msg_event(struct net *net, int conid, 285 - struct sockaddr_tipc *addr, void *usr_data, 286 - void *buf, size_t len) 296 + static void tipc_subscrb_rcv_cb(struct net *net, int conid, 297 + struct sockaddr_tipc *addr, void *usr_data, 298 + void *buf, size_t len) 287 299 { 288 300 struct tipc_subscriber *subscriber = usr_data; 289 301 struct tipc_subscription *sub = NULL; 290 302 struct tipc_net *tn = net_generic(net, tipc_net_id); 291 303 292 304 spin_lock_bh(&subscriber->lock); 293 - subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber, &sub); 305 + tipc_subscrp_create(net, (struct tipc_subscr *)buf, subscriber, &sub); 294 306 if (sub) 295 307 tipc_nametbl_subscribe(sub); 296 308 else ··· 299 311 } 300 312 301 313 /* Handle one request to establish a new subscriber */ 302 - static void *subscr_named_msg_event(int conid) 314 + static void *tipc_subscrb_connect_cb(int conid) 303 315 { 304 316 struct tipc_subscriber *subscriber; 305 317 ··· 309 321 pr_warn("Subscriber rejected, no memory\n"); 310 322 return NULL; 311 323 } 312 - INIT_LIST_HEAD(&subscriber->subscription_list); 324 + INIT_LIST_HEAD(&subscriber->subscrp_list); 313 325 subscriber->conid = conid; 314 326 spin_lock_init(&subscriber->lock); 315 327 316 328 return (void *)subscriber; 317 329 } 318 330 319 - int tipc_subscr_start(struct net *net) 331 + int tipc_topsrv_start(struct net *net) 320 332 { 321 333 struct tipc_net *tn = net_generic(net, tipc_net_id); 322 334 const char name[] = "topology_server"; ··· 343 355 topsrv->imp = TIPC_CRITICAL_IMPORTANCE; 344 356 topsrv->type = SOCK_SEQPACKET; 345 357 topsrv->max_rcvbuf_size = sizeof(struct tipc_subscr); 346 - topsrv->tipc_conn_recvmsg = subscr_conn_msg_event; 347 - topsrv->tipc_conn_new = subscr_named_msg_event; 348 - topsrv->tipc_conn_shutdown = subscr_conn_shutdown_event; 358 + topsrv->tipc_conn_recvmsg = tipc_subscrb_rcv_cb; 359 + topsrv->tipc_conn_new = tipc_subscrb_connect_cb; 360 + topsrv->tipc_conn_shutdown = tipc_subscrb_shutdown_cb; 349 361 350 362 strncpy(topsrv->name, name, strlen(name) + 1); 351 363 tn->topsrv = topsrv; ··· 354 366 return tipc_server_start(topsrv); 355 367 } 356 368 357 - void tipc_subscr_stop(struct net *net) 369 + void tipc_topsrv_stop(struct net *net) 358 370 { 359 371 struct tipc_net *tn = net_generic(net, tipc_net_id); 360 372 struct tipc_server *topsrv = tn->topsrv;
+9 -9
net/tipc/subscr.h
··· 54 54 * @filter: event filtering to be done for subscription 55 55 * @timer: timer governing subscription duration (optional) 56 56 * @nameseq_list: adjacent subscriptions in name sequence's subscription list 57 - * @subscription_list: adjacent subscriptions in subscriber's subscription list 57 + * @subscrp_list: adjacent subscriptions in subscriber's subscription list 58 58 * @server_ref: object reference of server port associated with subscription 59 59 * @swap: indicates if subscriber uses opposite endianness in its messages 60 60 * @evt: template for events generated by subscription ··· 67 67 u32 filter; 68 68 struct timer_list timer; 69 69 struct list_head nameseq_list; 70 - struct list_head subscription_list; 70 + struct list_head subscrp_list; 71 71 int swap; 72 72 struct tipc_event evt; 73 73 }; 74 74 75 - int tipc_subscr_overlap(struct tipc_subscription *sub, u32 found_lower, 76 - u32 found_upper); 77 - void tipc_subscr_report_overlap(struct tipc_subscription *sub, u32 found_lower, 78 - u32 found_upper, u32 event, u32 port_ref, 79 - u32 node, int must); 80 - int tipc_subscr_start(struct net *net); 81 - void tipc_subscr_stop(struct net *net); 75 + int tipc_subscrp_check_overlap(struct tipc_subscription *sub, u32 found_lower, 76 + u32 found_upper); 77 + void tipc_subscrp_report_overlap(struct tipc_subscription *sub, 78 + u32 found_lower, u32 found_upper, u32 event, 79 + u32 port_ref, u32 node, int must); 80 + int tipc_topsrv_start(struct net *net); 81 + void tipc_topsrv_stop(struct net *net); 82 82 83 83 #endif