All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2 of 2] DM RAID: Restructure conditional
@ 2012-06-26  8:59 Jonathan Brassow
  2012-06-26 14:57 ` [PATCH 2 of 2 - v2] " Jonathan Brassow
  2012-07-24 19:14 ` [PATCH 2 of 2 - v3] " Jonathan Brassow
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Brassow @ 2012-06-26  8:59 UTC (permalink / raw)
  To: dm-devel

dm-raid:  For code clarity, change 'if' conditional to 'switch' conditional

In preparation for RAID10 addition to dm-raid, we change an 'if' conditional
to a 'switch' conditional to make it easier to see what is being checked for
each RAID type.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
--- linux-upstream.orig/drivers/md/dm-raid.c
+++ linux-upstream/drivers/md/dm-raid.c
@@ -422,13 +422,26 @@ static int parse_raid_params(struct raid
 
 		if (!strcasecmp(key, "rebuild")) {
 			rebuild_cnt++;
-			if (((rs->raid_type->level != 1) &&
-			     (rebuild_cnt > rs->raid_type->parity_devs)) ||
-			    ((rs->raid_type->level == 1) &&
-			     (rebuild_cnt > (rs->md.raid_disks - 1)))) {
-				rs->ti->error = "Too many rebuild devices specified for given RAID type";
-				return -EINVAL;
+			rs->ti->error = NULL;
+
+			switch (rs->raid_type->level) {
+			case 1:
+				if (rebuild_cnt >= rs->md.raid_disks)
+					rs->ti->error = "Too many rebuild devices specified";
+				break;
+			case 4:
+			case 5:
+			case 6:
+				if (rebuild_cnt > rs->raid_type->parity_devs)
+					rs->ti->error = "Too many rebuild devices specified for given RAID type";
+				break;
+			default:
+				DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name);
+				rs->ti->error = "Rebuild not supported for this RAID type";
 			}
+			if (rs->ti->error)
+				return -EINVAL;
+
 			if (value > rs->md.raid_disks) {
 				rs->ti->error = "Invalid rebuild index given";
 				return -EINVAL;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2 of 2 - v2] DM RAID: Restructure conditional
  2012-06-26  8:59 [PATCH 2 of 2] DM RAID: Restructure conditional Jonathan Brassow
@ 2012-06-26 14:57 ` Jonathan Brassow
  2012-07-24 19:14 ` [PATCH 2 of 2 - v3] " Jonathan Brassow
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Brassow @ 2012-06-26 14:57 UTC (permalink / raw)
  To: dm-devel

Version 2 in response to minor conflicts found with existing patches in linux-next

 brassow

dm-raid:  For code clarity, change 'if' conditional to 'switch' conditional

In preparation for RAID10 addition to dm-raid, we change an 'if' conditional
to a 'switch' conditional to make it easier to see what is being checked for
each RAID type.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
--- linux-upstream.orig/drivers/md/dm-raid.c
+++ linux-upstream/drivers/md/dm-raid.c
@@ -423,13 +423,26 @@ static int parse_raid_params(struct raid
 
 		if (!strcasecmp(key, "rebuild")) {
 			rebuild_cnt++;
-			if (((rs->raid_type->level != 1) &&
-			     (rebuild_cnt > rs->raid_type->parity_devs)) ||
-			    ((rs->raid_type->level == 1) &&
-			     (rebuild_cnt > (rs->md.raid_disks - 1)))) {
-				rs->ti->error = "Too many rebuild devices specified for given RAID type";
-				return -EINVAL;
+			rs->ti->error = NULL;
+
+			switch (rs->raid_type->level) {
+			case 1:
+				if (rebuild_cnt >= rs->md.raid_disks)
+					rs->ti->error = "Too many rebuild devices specified";
+				break;
+			case 4:
+			case 5:
+			case 6:
+				if (rebuild_cnt > rs->raid_type->parity_devs)
+					rs->ti->error = "Too many rebuild devices specified for given RAID type";
+				break;
+			default:
+				DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name);
+				rs->ti->error = "Rebuild not supported for this RAID type";
 			}
+			if (rs->ti->error)
+				return -EINVAL;
+
 			if (value > rs->md.raid_disks) {
 				rs->ti->error = "Invalid rebuild index given";
 				return -EINVAL;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2 of 2 - v3] DM RAID: Restructure conditional
  2012-06-26  8:59 [PATCH 2 of 2] DM RAID: Restructure conditional Jonathan Brassow
  2012-06-26 14:57 ` [PATCH 2 of 2 - v2] " Jonathan Brassow
@ 2012-07-24 19:14 ` Jonathan Brassow
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Brassow @ 2012-07-24 19:14 UTC (permalink / raw)
  To: dm-devel; +Cc: agk

Minor update to this patch so that we don't ever set 'ti->error' to
NULL...

 brassow

dm-raid:  For code clarity, change 'if' conditional to 'switch' conditional

In preparation for RAID10 addition to dm-raid, we change an 'if' conditional
to a 'switch' conditional to make it easier to see what is being checked for
each RAID type.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
--- linux-upstream.orig/drivers/md/dm-raid.c
+++ linux-upstream/drivers/md/dm-raid.c
@@ -423,11 +423,24 @@ static int parse_raid_params(struct raid
 
 		if (!strcasecmp(key, "rebuild")) {
 			rebuild_cnt++;
-			if (((rs->raid_type->level != 1) &&
-			     (rebuild_cnt > rs->raid_type->parity_devs)) ||
-			    ((rs->raid_type->level == 1) &&
-			     (rebuild_cnt > (rs->md.raid_disks - 1)))) {
-				rs->ti->error = "Too many rebuild devices specified for given RAID type";
+			switch (rs->raid_type->level) {
+			case 1:
+				if (rebuild_cnt >= rs->md.raid_disks) {
+					rs->ti->error = "Too many rebuild devices specified";
+					return -EINVAL;
+				}
+				break;
+			case 4:
+			case 5:
+			case 6:
+				if (rebuild_cnt > rs->raid_type->parity_devs) {
+					rs->ti->error = "Too many rebuild devices specified for given RAID type";
+					return -EINVAL;
+				}
+				break;
+			default:
+				DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name);
+				rs->ti->error = "Rebuild not supported for this RAID type";
 				return -EINVAL;
 			}
 			if (value > rs->md.raid_disks) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-24 19:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-26  8:59 [PATCH 2 of 2] DM RAID: Restructure conditional Jonathan Brassow
2012-06-26 14:57 ` [PATCH 2 of 2 - v2] " Jonathan Brassow
2012-07-24 19:14 ` [PATCH 2 of 2 - v3] " Jonathan Brassow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.