aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid0.c
diff options
context:
space:
mode:
authorAndre Noll <maan@systemlinux.org>2009-06-16 02:47:21 -0400
committerNeilBrown <neilb@suse.de>2009-06-16 02:47:21 -0400
commit5568a6035d9fca2cd8f1ef7005e215eae4e65fab (patch)
treed4433e2449d51e38b841660b8b1017822828044c /drivers/md/raid0.c
parent8f79cfcdb65472f1504ade2f53e5f2bfdaeb95da (diff)
md: raid0: Make raid0_run() return a proper error code.
Currently raid0_run() always returns -ENOMEM on errors. This is incorrect as running the array might fail for other reasons, for example because not all component devices were available. This patch changes create_strip_zones() so that it returns a proper error code (either -ENOMEM or -EINVAL) rather than 1 on errors and makes raid0_run(), its single caller, return that value instead of -ENOMEM. Signed-off-by: Andre Noll <maan@systemlinux.org> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid0.c')
-rw-r--r--drivers/md/raid0.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index edffc4940b49..e5648b660e75 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -105,12 +105,12 @@ static int create_strip_zones (mddev_t *mddev)
105 conf->strip_zone = kzalloc(sizeof(struct strip_zone)* 105 conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
106 conf->nr_strip_zones, GFP_KERNEL); 106 conf->nr_strip_zones, GFP_KERNEL);
107 if (!conf->strip_zone) 107 if (!conf->strip_zone)
108 return 1; 108 return -ENOMEM;
109 conf->devlist = kzalloc(sizeof(mdk_rdev_t*)* 109 conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
110 conf->nr_strip_zones*mddev->raid_disks, 110 conf->nr_strip_zones*mddev->raid_disks,
111 GFP_KERNEL); 111 GFP_KERNEL);
112 if (!conf->devlist) 112 if (!conf->devlist)
113 return 1; 113 return -ENOMEM;
114 114
115 /* The first zone must contain all devices, so here we check that 115 /* The first zone must contain all devices, so here we check that
116 * there is a proper alignment of slots to devices and find them all 116 * there is a proper alignment of slots to devices and find them all
@@ -207,8 +207,8 @@ static int create_strip_zones (mddev_t *mddev)
207 207
208 printk(KERN_INFO "raid0: done.\n"); 208 printk(KERN_INFO "raid0: done.\n");
209 return 0; 209 return 0;
210 abort: 210abort:
211 return 1; 211 return -EINVAL;
212} 212}
213 213
214/** 214/**
@@ -254,6 +254,7 @@ static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
254static int raid0_run(mddev_t *mddev) 254static int raid0_run(mddev_t *mddev)
255{ 255{
256 raid0_conf_t *conf; 256 raid0_conf_t *conf;
257 int ret;
257 258
258 if (mddev->chunk_size == 0) { 259 if (mddev->chunk_size == 0) {
259 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); 260 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
@@ -269,12 +270,13 @@ static int raid0_run(mddev_t *mddev)
269 270
270 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL); 271 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
271 if (!conf) 272 if (!conf)
272 goto out; 273 return -ENOMEM;
273 mddev->private = (void *)conf; 274 mddev->private = (void *)conf;
274 275
275 conf->strip_zone = NULL; 276 conf->strip_zone = NULL;
276 conf->devlist = NULL; 277 conf->devlist = NULL;
277 if (create_strip_zones (mddev)) 278 ret = create_strip_zones(mddev);
279 if (ret < 0)
278 goto out_free_conf; 280 goto out_free_conf;
279 281
280 /* calculate array device size */ 282 /* calculate array device size */
@@ -306,8 +308,7 @@ out_free_conf:
306 kfree(conf->devlist); 308 kfree(conf->devlist);
307 kfree(conf); 309 kfree(conf);
308 mddev->private = NULL; 310 mddev->private = NULL;
309out: 311 return ret;
310 return -ENOMEM;
311} 312}
312 313
313static int raid0_stop (mddev_t *mddev) 314static int raid0_stop (mddev_t *mddev)