diff options
| author | Allan Stephens <allan.stephens@windriver.com> | 2012-04-17 17:57:52 -0400 |
|---|---|---|
| committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2012-04-18 09:36:02 -0400 |
| commit | e11aa059715e2bacd4e62d57be5557dda697af8e (patch) | |
| tree | 49e4c11d6a037bbd683c9b30e80c016d0dcb80cc /net | |
| parent | 3f8375fee30cbf7fb0bd67f044e3406daa16fa3e (diff) | |
tipc: Factor out name publication code to a separate function
This is done so that it can be reused with differing publication
lists, instead of being hard coded to the cluster publicaton list.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net')
| -rw-r--r-- | net/tipc/name_distr.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c index 870a001131c6..3be0eb9509df 100644 --- a/net/tipc/name_distr.c +++ b/net/tipc/name_distr.c | |||
| @@ -176,6 +176,39 @@ void tipc_named_withdraw(struct publication *publ) | |||
| 176 | named_cluster_distribute(buf); | 176 | named_cluster_distribute(buf); |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /* | ||
| 180 | * named_distribute - prepare name info for bulk distribution to another node | ||
| 181 | */ | ||
| 182 | static void named_distribute(struct list_head *message_list, u32 node, | ||
| 183 | struct publ_list *pls, u32 max_item_buf) | ||
| 184 | { | ||
| 185 | struct publication *publ; | ||
| 186 | struct sk_buff *buf = NULL; | ||
| 187 | struct distr_item *item = NULL; | ||
| 188 | u32 left = 0; | ||
| 189 | u32 rest = pls->size * ITEM_SIZE; | ||
| 190 | |||
| 191 | list_for_each_entry(publ, &pls->list, local_list) { | ||
| 192 | if (!buf) { | ||
| 193 | left = (rest <= max_item_buf) ? rest : max_item_buf; | ||
| 194 | rest -= left; | ||
| 195 | buf = named_prepare_buf(PUBLICATION, left, node); | ||
| 196 | if (!buf) { | ||
| 197 | warn("Bulk publication failure\n"); | ||
| 198 | return; | ||
| 199 | } | ||
| 200 | item = (struct distr_item *)msg_data(buf_msg(buf)); | ||
| 201 | } | ||
| 202 | publ_to_item(item, publ); | ||
| 203 | item++; | ||
| 204 | left -= ITEM_SIZE; | ||
| 205 | if (!left) { | ||
| 206 | list_add_tail((struct list_head *)buf, message_list); | ||
| 207 | buf = NULL; | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 179 | /** | 212 | /** |
| 180 | * tipc_named_node_up - tell specified node about all publications by this node | 213 | * tipc_named_node_up - tell specified node about all publications by this node |
| 181 | */ | 214 | */ |
| @@ -184,13 +217,8 @@ void tipc_named_node_up(unsigned long nodearg) | |||
| 184 | { | 217 | { |
| 185 | struct tipc_node *n_ptr; | 218 | struct tipc_node *n_ptr; |
| 186 | struct tipc_link *l_ptr; | 219 | struct tipc_link *l_ptr; |
| 187 | struct publication *publ; | ||
| 188 | struct distr_item *item = NULL; | ||
| 189 | struct sk_buff *buf = NULL; | ||
| 190 | struct list_head message_list; | 220 | struct list_head message_list; |
| 191 | u32 node = (u32)nodearg; | 221 | u32 node = (u32)nodearg; |
| 192 | u32 left = 0; | ||
| 193 | u32 rest; | ||
| 194 | u32 max_item_buf = 0; | 222 | u32 max_item_buf = 0; |
| 195 | 223 | ||
| 196 | /* compute maximum amount of publication data to send per message */ | 224 | /* compute maximum amount of publication data to send per message */ |
| @@ -214,28 +242,7 @@ void tipc_named_node_up(unsigned long nodearg) | |||
| 214 | INIT_LIST_HEAD(&message_list); | 242 | INIT_LIST_HEAD(&message_list); |
| 215 | 243 | ||
| 216 | read_lock_bh(&tipc_nametbl_lock); | 244 | read_lock_bh(&tipc_nametbl_lock); |
| 217 | rest = publ_cluster.size * ITEM_SIZE; | 245 | named_distribute(&message_list, node, &publ_cluster, max_item_buf); |
| 218 | |||
| 219 | list_for_each_entry(publ, &publ_cluster.list, local_list) { | ||
| 220 | if (!buf) { | ||
| 221 | left = (rest <= max_item_buf) ? rest : max_item_buf; | ||
| 222 | rest -= left; | ||
| 223 | buf = named_prepare_buf(PUBLICATION, left, node); | ||
| 224 | if (!buf) { | ||
| 225 | warn("Bulk publication distribution failure\n"); | ||
| 226 | goto exit; | ||
| 227 | } | ||
| 228 | item = (struct distr_item *)msg_data(buf_msg(buf)); | ||
| 229 | } | ||
| 230 | publ_to_item(item, publ); | ||
| 231 | item++; | ||
| 232 | left -= ITEM_SIZE; | ||
| 233 | if (!left) { | ||
| 234 | list_add_tail((struct list_head *)buf, &message_list); | ||
| 235 | buf = NULL; | ||
| 236 | } | ||
| 237 | } | ||
| 238 | exit: | ||
| 239 | read_unlock_bh(&tipc_nametbl_lock); | 246 | read_unlock_bh(&tipc_nametbl_lock); |
| 240 | 247 | ||
| 241 | tipc_link_send_names(&message_list, (u32)node); | 248 | tipc_link_send_names(&message_list, (u32)node); |
