Commit 07681215 authored by Nathan Fontenot's avatar Nathan Fontenot Committed by Greg Kroah-Hartman

Driver core: Add section count to memory_block struct

Add a section count property to the memory_block struct to track the number
of memory sections that have been added/removed from a memory block. This
allows us to know when the last memory section of a memory block has been
removed so we can remove the memory block.
Signed-off-by: default avatarNathan Fontenot <nfont@austin.ibm.com>
Reviewed-by: default avatarRobin Holt <holt@sgi.com>
Reviewed-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2938ffbd
...@@ -490,6 +490,7 @@ static int add_memory_block(int nid, struct mem_section *section, ...@@ -490,6 +490,7 @@ static int add_memory_block(int nid, struct mem_section *section,
mem->phys_index = __section_nr(section); mem->phys_index = __section_nr(section);
mem->state = state; mem->state = state;
mem->section_count++;
mutex_init(&mem->state_mutex); mutex_init(&mem->state_mutex);
start_pfn = section_nr_to_pfn(mem->phys_index); start_pfn = section_nr_to_pfn(mem->phys_index);
mem->phys_device = arch_get_memory_phys_device(start_pfn); mem->phys_device = arch_get_memory_phys_device(start_pfn);
...@@ -519,12 +520,16 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section, ...@@ -519,12 +520,16 @@ int remove_memory_block(unsigned long node_id, struct mem_section *section,
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
mem = find_memory_block(section); mem = find_memory_block(section);
unregister_mem_sect_under_nodes(mem);
mem_remove_simple_file(mem, phys_index); mem->section_count--;
mem_remove_simple_file(mem, state); if (mem->section_count == 0) {
mem_remove_simple_file(mem, phys_device); unregister_mem_sect_under_nodes(mem);
mem_remove_simple_file(mem, removable); mem_remove_simple_file(mem, phys_index);
unregister_memory(mem, section); mem_remove_simple_file(mem, state);
mem_remove_simple_file(mem, phys_device);
mem_remove_simple_file(mem, removable);
unregister_memory(mem, section);
}
mutex_unlock(&mem_sysfs_mutex); mutex_unlock(&mem_sysfs_mutex);
return 0; return 0;
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
struct memory_block { struct memory_block {
unsigned long phys_index; unsigned long phys_index;
unsigned long state; unsigned long state;
int section_count;
/* /*
* This serializes all state change requests. It isn't * This serializes all state change requests. It isn't
* held during creation because the control files are * held during creation because the control files are
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment