Skip to contentSkip to conversation

md: Return proper error rather than EIO.

PATCH Applied majianpeng 2 participants 3 messages Oct 27, 2012 – Oct 29, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 4/5 md: Return proper error rather than EIO.

---
 drivers/md/raid1.c |    4 ++--
 drivers/md/raid5.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/raid1.c +2 -2
index 8034fbd..e2f3783 100644
@@ -2799,12 +2799,12 @@ static int run(struct mddev *mddev)
 	if (mddev->level != 1) {
 		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
 		       mdname(mddev), mddev->level);
-		return -EIO;
+		return -EINVAL;
 	}
 	if (mddev->reshape_position != MaxSector) {
 		printk(KERN_ERR "md/raid1:%s: reshape_position set but not supported\n",
 		       mdname(mddev));
-		return -EIO;
+		return -EINVAL;
 	}
 	/*
 	 * copy the already verified devices into our private RAID1
drivers/md/raid5.c +2 -2
index c5439dc..684ca76 100644
@@ -5088,7 +5088,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	    && mddev->new_level != 6) {
 		printk(KERN_ERR "md/raid:%s: raid level not set to 4/5/6 (%d)\n",
 		       mdname(mddev), mddev->new_level);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
 	if ((mddev->new_level == 5
 	     && !algorithm_valid_raid5(mddev->new_layout)) ||
@@ -5096,7 +5096,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	     && !algorithm_valid_raid6(mddev->new_layout))) {
 		printk(KERN_ERR "md/raid:%s: layout %d not supported\n",
 		       mdname(mddev), mddev->new_layout);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
 	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
 		printk(KERN_ERR "md/raid:%s: not enough configured devices (%d, minimum 4)\n",
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 39 lines · On Sat, 27 Oct 2012 10:28:30 +0800 majianpeng <[email protected]> wrote:
---
 drivers/md/raid1.c |    4 ++--
 drivers/md/raid5.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/raid1.c +2 -2
index 8034fbd..e2f3783 100644
@@ -2799,12 +2799,12 @@ static int run(struct mddev *mddev)
 	if (mddev->level != 1) {
 		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
 		       mdname(mddev), mddev->level);
-		return -EIO;
+		return -EINVAL;
 	}
 	if (mddev->reshape_position != MaxSector) {
 		printk(KERN_ERR "md/raid1:%s: reshape_position set but not supported\n",
 		       mdname(mddev));
-		return -EIO;
+		return -EINVAL;
 	}
 	/*
 	 * copy the already verified devices into our private RAID1
drivers/md/raid5.c +1 -1
index c5439dc..684ca76 100644
@@ -5088,7 +5088,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	    && mddev->new_level != 6) {
 		printk(KERN_ERR "md/raid:%s: raid level not set to 4/5/6 (%d)\n",
 		       mdname(mddev), mddev->new_level);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
 	if ((mddev->new_level == 5
 	     && !algorithm_valid_raid5(mddev->new_layout)) ||

drivers/md/raid5.c static struct r5conf *setup_conf(struct mddev *mddev) · line 5102

Quoted 8 lines
drivers/md/raid5.c +1 -1
@@ -5096,7 +5096,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	     && !algorithm_valid_raid6(mddev->new_layout))) {
 		printk(KERN_ERR "md/raid:%s: layout %d not supported\n",
 		       mdname(mddev), mddev->new_layout);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
 	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
 		printk(KERN_ERR "md/raid:%s: not enough configured devices (%d, minimum 4)\n",

One doesn't just randomly change error return codes.
Maybe the current ones are "wrong", but they have been that way for many years so they are effectively part of the API. So they are "right" be definition, even if they seem wrong.

NeilBrown

author
#2 lore raw
Quoted 47 lines · On Sat, 27 Oct 2012 10:28:30 +0800 majianpeng <[email protected]> wrote:
Quoted 46 lines
---
 drivers/md/raid1.c |    4 ++--
 drivers/md/raid5.c |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/md/raid1.c +2 -2
index 8034fbd..e2f3783 100644
@@ -2799,12 +2799,12 @@ static int run(struct mddev *mddev)
 	if (mddev->level != 1) {
 		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
 		       mdname(mddev), mddev->level);
-		return -EIO;
+		return -EINVAL;
 	}
 	if (mddev->reshape_position != MaxSector) {
 		printk(KERN_ERR "md/raid1:%s: reshape_position set but not supported\n",
 		       mdname(mddev));
-		return -EIO;
+		return -EINVAL;
 	}
 	/*
 	 * copy the already verified devices into our private RAID1
drivers/md/raid5.c +2 -2
index c5439dc..684ca76 100644
@@ -5088,7 +5088,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	    && mddev->new_level != 6) {
 		printk(KERN_ERR "md/raid:%s: raid level not set to 4/5/6 (%d)\n",
 		       mdname(mddev), mddev->new_level);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
 	if ((mddev->new_level == 5
 	     && !algorithm_valid_raid5(mddev->new_layout)) ||
@@ -5096,7 +5096,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	     && !algorithm_valid_raid6(mddev->new_layout))) {
 		printk(KERN_ERR "md/raid:%s: layout %d not supported\n",
 		       mdname(mddev), mddev->new_layout);
-		return ERR_PTR(-EIO);
+		return ERR_PTR(-EINVAL);
 	}
Quoted 9 lines

drivers/md/raid5.c static struct r5conf *setup_conf(struct mddev *mddev) · line 5102

Quoted 2 lines
drivers/md/raid5.c +0 -0
 	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
 		printk(KERN_ERR "md/raid:%s: not enough configured devices (%d, minimum 4)\n",

One doesn't just randomly change error return codes.
Maybe the current ones are "wrong", but they have been that way for many years so they are effectively part of the API. So they are "right" be definition, even if they seem wrong.

Yes, i agree with your point.
For func setup_conf,there was alreday EINVAL, so modify EIO to EINVAL isn't add a new return code. I think for upper caller no effect.
For func run, the caller alse had EINVAL.So modify had no effect.

Jianpeng

Quoted 2 lines

NeilBrown