Skip to content

Commit 8348500

Browse files
Jon Maloydavem330
authored andcommitted
tipc: add option to suppress PUBLISH events for pre-existing publications
Currently, when a user is subscribing for binding table publications, he will receive a PUBLISH event for all already existing matching items in the binding table. However, a group socket making a subscriptions doesn't need this initial status update from the binding table, because it has already scanned it during the join operation. Worse, the multiplicatory effect of issuing mutual events for dozens or hundreds group members within a short time frame put a heavy load on the topology server, with the end result that scale out operations on a big group tend to take much longer than needed. We now add a new filter option, TIPC_SUB_NO_STATUS, for topology server subscriptions, so that this initial avalanche of events is suppressed. This change, along with the previous commit, significantly improves the range and speed of group scale out operations. We keep the new option internal for the tipc driver, at least for now. Acked-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d12d2e1 commit 8348500

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

net/tipc/group.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ struct tipc_group *tipc_group_create(struct net *net, u32 portid,
177177
grp->scope = mreq->scope;
178178
grp->loopback = mreq->flags & TIPC_GROUP_LOOPBACK;
179179
grp->events = mreq->flags & TIPC_GROUP_MEMBER_EVTS;
180-
if (tipc_topsrv_kern_subscr(net, portid, type, 0, ~0, &grp->subid))
180+
if (tipc_topsrv_kern_subscr(net, portid, type,
181+
TIPC_SUB_PORTS | TIPC_SUB_NO_STATUS,
182+
0, ~0, &grp->subid))
181183
return grp;
182184
kfree(grp);
183185
return NULL;

net/tipc/name_table.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,13 @@ static struct publication *tipc_nameseq_remove_publ(struct net *net,
405405
}
406406

407407
/**
408-
* tipc_nameseq_subscribe - attach a subscription, and issue
409-
* the prescribed number of events if there is any sub-
408+
* tipc_nameseq_subscribe - attach a subscription, and optionally
409+
* issue the prescribed number of events if there is any sub-
410410
* sequence overlapping with the requested sequence
411411
*/
412412
static void tipc_nameseq_subscribe(struct name_seq *nseq,
413-
struct tipc_subscription *s)
413+
struct tipc_subscription *s,
414+
bool status)
414415
{
415416
struct sub_seq *sseq = nseq->sseqs;
416417
struct tipc_name_seq ns;
@@ -420,7 +421,7 @@ static void tipc_nameseq_subscribe(struct name_seq *nseq,
420421
tipc_subscrp_get(s);
421422
list_add(&s->nameseq_list, &nseq->subscriptions);
422423

423-
if (!sseq)
424+
if (!status || !sseq)
424425
return;
425426

426427
while (sseq != &nseq->sseqs[nseq->first_free]) {
@@ -811,7 +812,7 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
811812
/**
812813
* tipc_nametbl_subscribe - add a subscription object to the name table
813814
*/
814-
void tipc_nametbl_subscribe(struct tipc_subscription *s)
815+
void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status)
815816
{
816817
struct tipc_net *tn = net_generic(s->net, tipc_net_id);
817818
u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap);
@@ -825,7 +826,7 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s)
825826
seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
826827
if (seq) {
827828
spin_lock_bh(&seq->lock);
828-
tipc_nameseq_subscribe(seq, s);
829+
tipc_nameseq_subscribe(seq, s, status);
829830
spin_unlock_bh(&seq->lock);
830831
} else {
831832
tipc_subscrp_convert_seq(&s->evt.s.seq, s->swap, &ns);

net/tipc/name_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ struct publication *tipc_nametbl_insert_publ(struct net *net, u32 type,
121121
struct publication *tipc_nametbl_remove_publ(struct net *net, u32 type,
122122
u32 lower, u32 node, u32 ref,
123123
u32 key);
124-
void tipc_nametbl_subscribe(struct tipc_subscription *s);
124+
void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status);
125125
void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
126126
int tipc_nametbl_init(struct net *net);
127127
void tipc_nametbl_stop(struct net *net);

net/tipc/server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void tipc_conn_terminate(struct tipc_server *s, int conid)
490490
}
491491

492492
bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type,
493-
u32 lower, u32 upper, int *conid)
493+
u32 filter, u32 lower, u32 upper, int *conid)
494494
{
495495
struct tipc_subscriber *scbr;
496496
struct tipc_subscr sub;
@@ -501,7 +501,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type,
501501
sub.seq.lower = lower;
502502
sub.seq.upper = upper;
503503
sub.timeout = TIPC_WAIT_FOREVER;
504-
sub.filter = TIPC_SUB_PORTS;
504+
sub.filter = filter;
505505
*(u32 *)&sub.usr_handle = port;
506506

507507
con = tipc_alloc_conn(tipc_topsrv(net));

net/tipc/server.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <net/net_namespace.h>
4242

4343
#define TIPC_SERVER_NAME_LEN 32
44+
#define TIPC_SUB_NO_STATUS 0x80
4445

4546
/**
4647
* struct tipc_server - TIPC server structure
@@ -84,7 +85,7 @@ int tipc_conn_sendmsg(struct tipc_server *s, int conid,
8485
struct sockaddr_tipc *addr, void *data, size_t len);
8586

8687
bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type,
87-
u32 lower, u32 upper, int *conid);
88+
u32 filter, u32 lower, u32 upper, int *conid);
8889
void tipc_topsrv_kern_unsubscr(struct net *net, int conid);
8990

9091
/**

net/tipc/subscr.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ static struct tipc_subscription *tipc_subscrp_create(struct net *net,
286286
}
287287

288288
static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s,
289-
struct tipc_subscriber *subscriber, int swap)
289+
struct tipc_subscriber *subscriber, int swap,
290+
bool status)
290291
{
291292
struct tipc_net *tn = net_generic(net, tipc_net_id);
292293
struct tipc_subscription *sub = NULL;
@@ -299,7 +300,7 @@ static void tipc_subscrp_subscribe(struct net *net, struct tipc_subscr *s,
299300
spin_lock_bh(&subscriber->lock);
300301
list_add(&sub->subscrp_list, &subscriber->subscrp_list);
301302
sub->subscriber = subscriber;
302-
tipc_nametbl_subscribe(sub);
303+
tipc_nametbl_subscribe(sub, status);
303304
tipc_subscrb_get(subscriber);
304305
spin_unlock_bh(&subscriber->lock);
305306

@@ -323,6 +324,7 @@ static void tipc_subscrb_rcv_cb(struct net *net, int conid,
323324
{
324325
struct tipc_subscriber *subscriber = usr_data;
325326
struct tipc_subscr *s = (struct tipc_subscr *)buf;
327+
bool status;
326328
int swap;
327329

328330
/* Determine subscriber's endianness */
@@ -334,8 +336,8 @@ static void tipc_subscrb_rcv_cb(struct net *net, int conid,
334336
s->filter &= ~htohl(TIPC_SUB_CANCEL, swap);
335337
return tipc_subscrp_cancel(s, subscriber);
336338
}
337-
338-
tipc_subscrp_subscribe(net, s, subscriber, swap);
339+
status = !(s->filter & htohl(TIPC_SUB_NO_STATUS, swap));
340+
tipc_subscrp_subscribe(net, s, subscriber, swap, status);
339341
}
340342

341343
/* Handle one request to establish a new subscriber */

0 commit comments

Comments
 (0)