[PATCH] Fix copying of pgdat array on each node for ia64 memory hotplug

I found a bug in memory hot-add code for ia64.

IA64's code has copies of pgdat's array on each node to reduce memory
access over crossing node. This array is used by NODE_DATA() macro. When
new node is hot-added, this pgdat's array should be updated and copied on
new node too.

However, I used for_each_online_node() in scatter_node_data() to copy
it. This meant its array is not copied on new node.
Because initialization of structures for new node was halfway,
so online_node_map couldn't be set at this time.

To copy arrays on new node, I changed it to check value of pgdat_list[]
which is source array of copies. I tested this patch with my Memory Hotadd
emulation on Tiger4. This patch is for 2.6.17-git20.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Yasunori Goto and committed by Linus Torvalds dd8041f1 31304c90

+13 -3
+13 -3
arch/ia64/mm/discontig.c
··· 313 pg_data_t **dst; 314 int node; 315 316 - for_each_online_node(node) { 317 - dst = LOCAL_DATA_ADDR(pgdat_list[node])->pg_data_ptrs; 318 - memcpy(dst, pgdat_list, sizeof(pgdat_list)); 319 } 320 } 321
··· 313 pg_data_t **dst; 314 int node; 315 316 + /* 317 + * for_each_online_node() can't be used at here. 318 + * node_online_map is not set for hot-added nodes at this time, 319 + * because we are halfway through initialization of the new node's 320 + * structures. If for_each_online_node() is used, a new node's 321 + * pg_data_ptrs will be not initialized. Insted of using it, 322 + * pgdat_list[] is checked. 323 + */ 324 + for_each_node(node) { 325 + if (pgdat_list[node]) { 326 + dst = LOCAL_DATA_ADDR(pgdat_list[node])->pg_data_ptrs; 327 + memcpy(dst, pgdat_list, sizeof(pgdat_list)); 328 + } 329 } 330 } 331