patch-2.1.54 linux/drivers/block/raid0.c

Next file: linux/drivers/block/rd.c
Previous file: linux/drivers/block/hd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.53/linux/drivers/block/raid0.c linux/drivers/block/raid0.c
@@ -20,13 +20,13 @@
 #include <linux/module.h>
 #include <linux/md.h>
 #include <linux/raid0.h>
-#include <linux/malloc.h>
+#include <linux/vmalloc.h>
 
 #define MAJOR_NR MD_MAJOR
 #define MD_DRIVER
 #define MD_PERSONALITY
 
-static void create_strip_zones (int minor, struct md_dev *mddev)
+static int create_strip_zones (int minor, struct md_dev *mddev)
 {
   int i, j, c=0;
   int current_offset=0;
@@ -50,8 +50,8 @@
     c=0;
   }
 
-  data->strip_zone=kmalloc (sizeof(struct strip_zone)*data->nr_strip_zones,
-			      GFP_KERNEL);
+  if ((data->strip_zone=vmalloc(sizeof(struct strip_zone)*data->nr_strip_zones)) == NULL)
+    return 1;
 
   data->smallest=NULL;
   
@@ -81,6 +81,7 @@
 					   data->strip_zone[i-1].size) : 0;
     current_offset=smallest_by_zone->size;
   }
+  return 0;
 }
 
 static int raid0_run (int minor, struct md_dev *mddev)
@@ -90,17 +91,26 @@
 
   MOD_INC_USE_COUNT;
 
-  mddev->private=kmalloc (sizeof (struct raid0_data), GFP_KERNEL);
+  if ((mddev->private=vmalloc (sizeof (struct raid0_data))) == NULL) return 1;
   data=(struct raid0_data *) mddev->private;
   
-  create_strip_zones (minor, mddev);
+  if (create_strip_zones (minor, mddev)) 
+  {
+  	vfree(data);
+  	return 1;
+  }
 
   nb_zone=data->nr_zones=
     md_size[minor]/data->smallest->size +
     (md_size[minor]%data->smallest->size ? 1 : 0);
-  
-  data->hash_table=kmalloc (sizeof (struct raid0_hash)*nb_zone, GFP_KERNEL);
 
+  printk ("raid0 : Allocating %d bytes for hash.\n",sizeof(struct raid0_hash)*nb_zone);
+  if ((data->hash_table=vmalloc (sizeof (struct raid0_hash)*nb_zone)) == NULL)
+  {
+    vfree(data->strip_zone);
+    vfree(data);
+    return 1;
+  }
   size=data->strip_zone[cur].size;
 
   i=0;
@@ -142,9 +152,9 @@
 {
   struct raid0_data *data=(struct raid0_data *) mddev->private;
 
-  kfree (data->hash_table);
-  kfree (data->strip_zone);
-  kfree (data);
+  vfree (data->hash_table);
+  vfree (data->strip_zone);
+  vfree (data);
 
   MOD_DEC_USE_COUNT;
   return 0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov