[PATCH 0/4] Prepare mdadm for migrations (external meta)

[PATCH 0/4] Prepare mdadm for migrations (external meta)

am 10.02.2011 14:55:53 von adam.kwolek

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
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH 1/4] FIX: delta_disk can have UnSet value

am 10.02.2011 14:56:18 von adam.kwolek

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
---

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);

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH 2/4] FIX: Get spares from external metadata

am 10.02.2011 14:56:26 von adam.kwolek

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
---

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. */


--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH 3/4] imsm: FIX: Add spare disks information to array

am 10.02.2011 14:56:34 von adam.kwolek

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
---

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;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

[PATCH 4/4] FIX: Add raid5 to raid0 case to analyse_change()

am 10.02.2011 14:56:43 von adam.kwolek

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

Signed-off-by: Adam Kwolek
---

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;

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH 0/4] Prepare mdadm for migrations (external meta)

am 14.02.2011 01:17:18 von NeilBrown

On Thu, 10 Feb 2011 14:55:53 +0100 Adam Kwolek 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(-)
>

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html