]> err.no Git - linux-2.6/blobdiff - mm/memory_hotplug.c
[libata] Add host lock to struct ata_port
[linux-2.6] / mm / memory_hotplug.c
index f6d4af8af8a8f5a491f837d9bb9c108313ecb7f0..70df5c0d957e482f8055fc2ecc596fc173a11a61 100644 (file)
@@ -42,7 +42,6 @@ extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
                                  int nr_pages);
 static int __add_section(struct zone *zone, unsigned long phys_start_pfn)
 {
-       struct pglist_data *pgdat = zone->zone_pgdat;
        int nr_pages = PAGES_PER_SECTION;
        int ret;
 
@@ -70,12 +69,16 @@ int __add_pages(struct zone *zone, unsigned long phys_start_pfn,
        for (i = 0; i < nr_pages; i += PAGES_PER_SECTION) {
                err = __add_section(zone, phys_start_pfn + i);
 
-               if (err)
+               /* We want to keep adding the rest of the
+                * sections if the first ones already exist
+                */
+               if (err && (err != -EEXIST))
                        break;
        }
 
        return err;
 }
+EXPORT_SYMBOL_GPL(__add_pages);
 
 static void grow_zone_span(struct zone *zone,
                unsigned long start_pfn, unsigned long end_pfn)
@@ -88,8 +91,8 @@ static void grow_zone_span(struct zone *zone,
        if (start_pfn < zone->zone_start_pfn)
                zone->zone_start_pfn = start_pfn;
 
-       if (end_pfn > old_zone_end_pfn)
-               zone->spanned_pages = end_pfn - zone->zone_start_pfn;
+       zone->spanned_pages = max(old_zone_end_pfn, end_pfn) -
+                               zone->zone_start_pfn;
 
        zone_span_writeunlock(zone);
 }
@@ -103,8 +106,8 @@ static void grow_pgdat_span(struct pglist_data *pgdat,
        if (start_pfn < pgdat->node_start_pfn)
                pgdat->node_start_pfn = start_pfn;
 
-       if (end_pfn > old_pgdat_end_pfn)
-               pgdat->node_spanned_pages = end_pfn - pgdat->node_start_pfn;
+       pgdat->node_spanned_pages = max(old_pgdat_end_pfn, end_pfn) -
+                                       pgdat->node_start_pfn;
 }
 
 int online_pages(unsigned long pfn, unsigned long nr_pages)
@@ -131,6 +134,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
                onlined_pages++;
        }
        zone->present_pages += onlined_pages;
+       zone->zone_pgdat->node_present_pages += onlined_pages;
 
        setup_per_zone_pages_min();