linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andre Noll <maan@systemlinux.org>
To: neilb@suse.de
Cc: raziebe@gmail.com, linux-raid@vger.kernel.org,
	Andre Noll <maan@systemlinux.org>
Subject: [PATCH 4/6] md: raid0: Make raid0_run() return a proper error code.
Date: Fri, 15 May 2009 15:18:16 +0200	[thread overview]
Message-ID: <1242393498-7528-5-git-send-email-maan@systemlinux.org> (raw)
In-Reply-To: <1242393498-7528-1-git-send-email-maan@systemlinux.org>

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>
---
 drivers/md/raid0.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 4b207ab..7f89843 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -105,12 +105,12 @@ static int create_strip_zones (mddev_t *mddev)
 	conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
 				conf->nr_strip_zones, GFP_KERNEL);
 	if (!conf->strip_zone)
-		return 1;
+		return -ENOMEM;
 	conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
 				conf->nr_strip_zones*mddev->raid_disks,
 				GFP_KERNEL);
 	if (!conf->devlist)
-		return 1;
+		return -ENOMEM;
 
 	/* The first zone must contain all devices, so here we check that
 	 * there is a proper alignment of slots to devices and find them all
@@ -209,8 +209,8 @@ static int create_strip_zones (mddev_t *mddev)
 
 	printk(KERN_INFO "raid0: done.\n");
 	return 0;
- abort:
-	return 1;
+abort:
+	return -EINVAL;
 }
 
 /**
@@ -256,6 +256,7 @@ static sector_t raid0_size(mddev_t *mddev, sector_t sectors, int raid_disks)
 static int raid0_run(mddev_t *mddev)
 {
 	raid0_conf_t *conf;
+	int ret;
 
 	if (mddev->chunk_size == 0) {
 		printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
@@ -271,12 +272,13 @@ static int raid0_run(mddev_t *mddev)
 
 	conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
 	if (!conf)
-		goto out;
+		return -ENOMEM;
 	mddev->private = (void *)conf;
  
 	conf->strip_zone = NULL;
 	conf->devlist = NULL;
-	if (create_strip_zones (mddev)) 
+	ret = create_strip_zones(mddev);
+	if (ret < 0)
 		goto out_free_conf;
 
 	/* calculate array device size */
@@ -308,8 +310,7 @@ out_free_conf:
 	kfree(conf->devlist);
 	kfree(conf);
 	mddev->private = NULL;
-out:
-	return -ENOMEM;
+	return ret;
 }
 
 static int raid0_stop (mddev_t *mddev)
-- 
1.5.4.3


  parent reply	other threads:[~2009-05-15 13:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 13:18 [PATCH 0/6] md: Remove the hash tables from raid0 V2 -- Introduction Andre Noll
2009-05-15 13:18 ` [PATCH 1/6] md: raid0: Replace hash table lookup by looping over all strip_zones Andre Noll
2009-05-15 13:18 ` [PATCH 2/6] md: raid0: Remove hash table Andre Noll
2009-05-15 13:18 ` [PATCH 3/6] md: raid0: Remove hash spacing and sector shift Andre Noll
2009-05-15 13:18 ` Andre Noll [this message]
2009-05-15 13:18 ` [PATCH 5/6] md: raid0: Allocate all buffers for the raid0 configuration in one function Andre Noll
2009-05-15 13:18 ` [PATCH 6/6] md: raid0: Fix a memory leak when stopping a raid0 array Andre Noll
2009-05-16 11:53 ` [PATCH 0/6] md: Remove the hash tables from raid0 V2 -- Introduction Neil Brown
  -- strict thread matches above, loose matches on Subject: below --
2009-05-14  9:30 [PATCH 0/6] md: Remove the hash tables from raid0 Andre Noll
2009-05-14  9:31 ` [PATCH 4/6] md: raid0: Make raid0_run() return a proper error code Andre Noll

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242393498-7528-5-git-send-email-maan@systemlinux.org \
    --to=maan@systemlinux.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=raziebe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).