All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Prepare mdadm for migrations (external meta)
@ 2011-02-10 13:55 Adam Kwolek
  2011-02-10 13:56 ` [PATCH 1/4] FIX: delta_disk can have UnSet value Adam Kwolek
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Adam Kwolek @ 2011-02-10 13:55 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

This few patches prepares mdadm for level and chunk size migration using external metadata.
1. FIX: delta_disk can have UnSet value
  A while ago I've reported problem that delta_disks can have UnSet value, so adding it
  to raid_disks can produce error in mdadm. Looking my first patch you proposed
  to address this problem by changing reshape_super() interface rather than
  set condition on function call. This patch implements your idea.

2. FIX: Get spares from external metadata
   imsm: FIX: Add spare disks information to array description
  Those 2 patches addresses problem with not initializes spares counter in mdinfo
  using external metadata.

3. FIX: Add raid5 to raid0 case to analyse_change()
  This patch adds missing of level transition in Grow.c

This series should be applied on devel-3.2 branch with my yesterday's 4 patches

BR
Adam

---

Adam Kwolek (4):
      FIX: Add raid5 to raid0 case to analyse_change()
      imsm: FIX: Add spare disks information to array description
      FIX: Get spares from external metadata
      FIX: delta_disk can have UnSet value


 Grow.c        |   36 ++++++++++++++++++++++++++++++------
 mdadm.h       |    3 ++-
 super-intel.c |   14 +++++++++++++-
 3 files changed, 45 insertions(+), 8 deletions(-)

-- 
Signature

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

* [PATCH 1/4] FIX: delta_disk can have UnSet value
  2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
@ 2011-02-10 13:56 ` Adam Kwolek
  2011-02-10 13:56 ` [PATCH 2/4] FIX: Get spares from external metadata Adam Kwolek
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Kwolek @ 2011-02-10 13:56 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

Delta_disk can be set to UnSet value.
This can a cause to pass wrong parameter to reshape_super().
To avoid such situations raid_disks and delta_disks parameters
have to be passed to reshape_super() separately.
It will be up to reshape_super() function validation
and usage of this parameters to avoid not valid values.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 Grow.c        |   15 +++++++++------
 mdadm.h       |    3 ++-
 super-intel.c |    5 ++++-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/Grow.c b/Grow.c
index 402da5e..9ae2ecd 100644
--- a/Grow.c
+++ b/Grow.c
@@ -565,7 +565,8 @@ static void wait_reshape(struct mdinfo *sra)
 
 static int reshape_super(struct supertype *st, long long size, int level,
 			 int layout, int chunksize, int raid_disks,
-			 char *backup_file, char *dev, int verbose)
+			 int delta_disks, char *backup_file, char *dev,
+			 int verbose)
 {
 	/* nothing extra to check in the native case */
 	if (!st->ss->external)
@@ -578,7 +579,8 @@ static int reshape_super(struct supertype *st, long long size, int level,
 	}
 
 	return st->ss->reshape_super(st, size, level, layout, chunksize,
-				     raid_disks, backup_file, dev, verbose);
+				     raid_disks, delta_disks, backup_file, dev,
+				     verbose);
 }
 
 static void sync_metadata(struct supertype *st)
@@ -1416,7 +1418,8 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 	if (size >= 0 && (size == 0 || size != array.size)) {
 		long long orig_size = array.size;
 
-		if (reshape_super(st, size, UnSet, UnSet, 0, 0, NULL, devname, !quiet)) {
+		if (reshape_super(st, size, UnSet, UnSet, 0, 0, UnSet, NULL,
+				  devname, !quiet)) {
 			rv = 1;
 			goto release;
 		}
@@ -1438,7 +1441,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 
 			/* restore metadata */
 			if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0,
-					  NULL, devname, !quiet) == 0)
+					  UnSet, NULL, devname, !quiet) == 0)
 				sync_metadata(st);
 			fprintf(stderr, Name ": Cannot set device size for %s: %s\n",
 				devname, strerror(err));
@@ -1575,7 +1578,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 
 		if (reshape_super(st, info.component_size, info.new_level,
 				  info.new_layout, info.new_chunk,
-				  info.array.raid_disks + info.delta_disks,
+				  info.array.raid_disks, info.delta_disks,
 				  backup_file, devname, quiet)) {
 			rv = 1;
 			goto release;
@@ -2123,7 +2126,7 @@ int reshape_container(char *container, int cfd, char *devname,
 	 */
 	if (reshape_super(st, -1, info->new_level,
 			  info->new_layout, info->new_chunk,
-			  info->array.raid_disks + info->delta_disks,
+			  info->array.raid_disks, info->delta_disks,
 			  backup_file, devname, quiet)) {
 		unfreeze(st);
 		return 1;
diff --git a/mdadm.h b/mdadm.h
index 608095f..9f20ba1 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -719,7 +719,8 @@ extern struct superswitch {
 	 */
 	int (*reshape_super)(struct supertype *st, long long size, int level,
 			     int layout, int chunksize, int raid_disks,
-			     char *backup, char *dev, int verbose); /* optional */
+			     int delta_disks, char *backup, char *dev,
+			     int verbose); /* optional */
 	int (*manage_reshape)( /* optional */
 		int afd, struct mdinfo *sra, struct reshape *reshape,
 		struct supertype *st, unsigned long blocks,
diff --git a/super-intel.c b/super-intel.c
index 4a9c230..fed831d 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -7052,7 +7052,8 @@ int imsm_takeover(struct supertype *st, struct geo_params *geo)
 
 static int imsm_reshape_super(struct supertype *st, long long size, int level,
 			      int layout, int chunksize, int raid_disks,
-			      char *backup, char *dev, int verbose)
+			      int delta_disks, char *backup, char *dev,
+			      int verbose)
 {
 	int ret_val = 1;
 	struct geo_params geo;
@@ -7068,6 +7069,8 @@ static int imsm_reshape_super(struct supertype *st, long long size, int level,
 	geo.layout = layout;
 	geo.chunksize = chunksize;
 	geo.raid_disks = raid_disks;
+	if (delta_disks != UnSet)
+		geo.raid_disks += delta_disks;
 
 	dprintf("\tfor level      : %i\n", geo.level);
 	dprintf("\tfor raid_disks : %i\n", geo.raid_disks);


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

* [PATCH 2/4] FIX: Get spares from external metadata
  2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
  2011-02-10 13:56 ` [PATCH 1/4] FIX: delta_disk can have UnSet value Adam Kwolek
@ 2011-02-10 13:56 ` Adam Kwolek
  2011-02-10 13:56 ` [PATCH 3/4] imsm: FIX: Add spare disks information to array description Adam Kwolek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Kwolek @ 2011-02-10 13:56 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

For external metadata cases, information about number of spares cannot
be get via ioctl GET_ARRAY_INFO for particular array
(as info variable is initialized by). In md this information is present
in container object not array one.
This causes need to get spare disks number from external metadata.

This information is required for reshape_array() function to decide
if spare disks number satisfy operation requirements.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 Grow.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/Grow.c b/Grow.c
index 9ae2ecd..08fc258 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1573,6 +1573,19 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
 				       force, backup_file, quiet);
 		frozen = 0;
 	} else {
+		/* get spare devices from external metadata
+		 */
+		if (st->ss->external) {
+			struct mdinfo *info2;
+
+			info2 = st->ss->container_content(st, subarray);
+			if (info2) {
+				info.array.spare_disks =
+					info2->array.spare_disks;
+				sysfs_free(info2);
+			}
+		}
+
 		/* Impose these changes on a single array.  First
 		 * check that the metadata is OK with the change. */
 


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

* [PATCH 3/4] imsm: FIX: Add spare disks information to array description
  2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
  2011-02-10 13:56 ` [PATCH 1/4] FIX: delta_disk can have UnSet value Adam Kwolek
  2011-02-10 13:56 ` [PATCH 2/4] FIX: Get spares from external metadata Adam Kwolek
@ 2011-02-10 13:56 ` Adam Kwolek
  2011-02-10 13:56 ` [PATCH 4/4] FIX: Add raid5 to raid0 case to analyse_change() Adam Kwolek
  2011-02-14  0:17 ` [PATCH 0/4] Prepare mdadm for migrations (external meta) NeilBrown
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Kwolek @ 2011-02-10 13:56 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

Spares that are specified on container can be used by any array in container.
this means that for every array in container they should be reported.
This let caller know how many spare devices (not used in any array)
are still available.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 super-intel.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/super-intel.c b/super-intel.c
index fed831d..e06a6f4 100644
--- a/super-intel.c
+++ b/super-intel.c
@@ -4731,11 +4731,19 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
 	struct mdinfo *rest = NULL;
 	unsigned int i;
 	int bbm_errors = 0;
+	struct dl *d;
+	int spare_disks = 0;
 
 	/* check for bad blocks */
 	if (imsm_bbm_log_size(super->anchor))
 		bbm_errors = 1;
 
+	/* count spare devices, not used in maps
+	 */
+	for (d = super->disks; d; d = d->next)
+		if (d->index == -1)
+			spare_disks++;
+
 	for (i = 0; i < mpb->num_raid_devs; i++) {
 		struct imsm_dev *dev;
 		struct imsm_map *map;
@@ -4852,6 +4860,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st, char *subarra
 		}
 		/* now that the disk list is up-to-date fixup recovery_start */
 		update_recovery_start(dev, this);
+		this->array.spare_disks += spare_disks;
 		rest = this;
 	}
 


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

* [PATCH 4/4] FIX: Add raid5 to raid0 case to analyse_change()
  2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
                   ` (2 preceding siblings ...)
  2011-02-10 13:56 ` [PATCH 3/4] imsm: FIX: Add spare disks information to array description Adam Kwolek
@ 2011-02-10 13:56 ` Adam Kwolek
  2011-02-14  0:17 ` [PATCH 0/4] Prepare mdadm for migrations (external meta) NeilBrown
  4 siblings, 0 replies; 6+ messages in thread
From: Adam Kwolek @ 2011-02-10 13:56 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

Transition raid5 to raid0 was not covered in analyse_change()
Missing code added.

Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
---

 Grow.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Grow.c b/Grow.c
index 08fc258..b04faf1 100644
--- a/Grow.c
+++ b/Grow.c
@@ -1056,6 +1056,14 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
 		info->array.layout = ALGORITHM_PARITY_N;
 	case 5:
 		switch (info->new_level) {
+		case 0:
+			re->level = 5;
+			info->delta_disks = 0;
+			re->before.data_disks = info->array.raid_disks - 1;
+			re->before.layout = info->array.layout;
+			re->after.data_disks = info->array.raid_disks;
+			re->after.layout = 0;
+			break;
 		case 4:
 			re->level = info->array.level;
 			re->before.data_disks = info->array.raid_disks - 1;


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

* Re: [PATCH 0/4] Prepare mdadm for migrations (external meta)
  2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
                   ` (3 preceding siblings ...)
  2011-02-10 13:56 ` [PATCH 4/4] FIX: Add raid5 to raid0 case to analyse_change() Adam Kwolek
@ 2011-02-14  0:17 ` NeilBrown
  4 siblings, 0 replies; 6+ messages in thread
From: NeilBrown @ 2011-02-14  0:17 UTC (permalink / raw)
  To: Adam Kwolek
  Cc: linux-raid, dan.j.williams, ed.ciechanowski, wojciech.neubauer

On Thu, 10 Feb 2011 14:55:53 +0100 Adam Kwolek <adam.kwolek@intel.com> wrote:

> This few patches prepares mdadm for level and chunk size migration using external metadata.
> 1. FIX: delta_disk can have UnSet value
>   A while ago I've reported problem that delta_disks can have UnSet value, so adding it
>   to raid_disks can produce error in mdadm. Looking my first patch you proposed
>   to address this problem by changing reshape_super() interface rather than
>   set condition on function call. This patch implements your idea.
> 
> 2. FIX: Get spares from external metadata
>    imsm: FIX: Add spare disks information to array description
>   Those 2 patches addresses problem with not initializes spares counter in mdinfo
>   using external metadata.
> 
> 3. FIX: Add raid5 to raid0 case to analyse_change()
>   This patch adds missing of level transition in Grow.c

I've applied all of these though I changed the last one to:


--- a/Grow.c
+++ b/Grow.c
@@ -1056,6 +1056,7 @@ char *analyse_change(struct mdinfo *info, struct reshape *re)
 		info->array.layout = ALGORITHM_PARITY_N;
 	case 5:
 		switch (info->new_level) {
+		case 0:
 		case 4:
 			re->level = info->array.level;
 			re->before.data_disks = info->array.raid_disks - 1;


as I think that is all that is required.

Thanks,

NeilBrown


> 
> This series should be applied on devel-3.2 branch with my yesterday's 4 patches
> 
> BR
> Adam
> 
> ---
> 
> Adam Kwolek (4):
>       FIX: Add raid5 to raid0 case to analyse_change()
>       imsm: FIX: Add spare disks information to array description
>       FIX: Get spares from external metadata
>       FIX: delta_disk can have UnSet value
> 
> 
>  Grow.c        |   36 ++++++++++++++++++++++++++++++------
>  mdadm.h       |    3 ++-
>  super-intel.c |   14 +++++++++++++-
>  3 files changed, 45 insertions(+), 8 deletions(-)
> 


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

end of thread, other threads:[~2011-02-14  0:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-10 13:55 [PATCH 0/4] Prepare mdadm for migrations (external meta) Adam Kwolek
2011-02-10 13:56 ` [PATCH 1/4] FIX: delta_disk can have UnSet value Adam Kwolek
2011-02-10 13:56 ` [PATCH 2/4] FIX: Get spares from external metadata Adam Kwolek
2011-02-10 13:56 ` [PATCH 3/4] imsm: FIX: Add spare disks information to array description Adam Kwolek
2011-02-10 13:56 ` [PATCH 4/4] FIX: Add raid5 to raid0 case to analyse_change() Adam Kwolek
2011-02-14  0:17 ` [PATCH 0/4] Prepare mdadm for migrations (external meta) NeilBrown

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.