[PATCH 0/3] Fix freezing multiple array in container during assembly

[PATCH 0/3] Fix freezing multiple array in container during assembly

am 29.09.2011 17:53:27 von adam.kwolek

The following series corrects freezing reshaped array in container during assembly
while other arrays are present also.

The goal of patches is to get entire assembled container (all arrays inside)
to be blocked from monitoring when reshape is in progress /exactly as when reshape
is initialized from mdadm command line/.

BR
Adam

---

Adam Kwolek (3):
FIX: Remove error message during reshape restart (v2)
FIX: Block array monitoring if any array is under reshape in container
Move code to check_mdmon_version() function


Assemble.c | 19 ++++++++-
Grow.c | 44 ++++++++++++++++++----
mdadm.h | 2 +
msg.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++-------------
msg.h | 3 +
5 files changed, 152 insertions(+), 37 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/3] Move code to check_mdmon_version() function

am 29.09.2011 17:53:36 von adam.kwolek

Move code to function for code reuse.

Signed-off-by: Adam Kwolek
---

msg.c | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/msg.c b/msg.c
index a10c930..98d6d13 100644
--- a/msg.c
+++ b/msg.c
@@ -281,6 +281,40 @@ int block_subarray(struct mdinfo *sra)

return rc;
}
+
+/* check mdmon version if it supports
+ * array blocking mechanism
+ */
+int check_mdmon_version(char *container)
+{
+ char *version = NULL;
+ int devnum = devname2devnum(container);
+
+ if (!mdmon_running(devnum)) {
+ /* if mdmon is not active we assume that any instance that is
+ * later started will match the current mdadm version, if this
+ * assumption is violated we may inadvertantly rebuild an array
+ * that was meant for reshape, or start rebuild on a spare that
+ * was to be moved to another container
+ */
+ /* pass */;
+ } else {
+ int ver;
+
+ version = ping_monitor_version(container);
+ ver = version ? mdadm_version(version) : -1;
+ free(version);
+ if (ver < 3002000) {
+ fprintf(stderr, Name
+ ": mdmon instance for %s cannot be disabled\n",
+ container);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
/**
* block_monitor - prevent mdmon spare assignment
* @container - container to block
@@ -302,34 +336,13 @@ int block_subarray(struct mdinfo *sra)
*/
int block_monitor(char *container, const int freeze)
{
- int devnum = devname2devnum(container);
struct mdstat_ent *ent, *e, *e2;
struct mdinfo *sra = NULL;
- char *version = NULL;
char buf[64];
int rv = 0;

- if (!mdmon_running(devnum)) {
- /* if mdmon is not active we assume that any instance that is
- * later started will match the current mdadm version, if this
- * assumption is violated we may inadvertantly rebuild an array
- * that was meant for reshape, or start rebuild on a spare that
- * was to be moved to another container
- */
- /* pass */;
- } else {
- int ver;
-
- version = ping_monitor_version(container);
- ver = version ? mdadm_version(version) : -1;
- free(version);
- if (ver < 3002000) {
- fprintf(stderr, Name
- ": mdmon instance for %s cannot be disabled\n",
- container);
- return -1;
- }
- }
+ if (check_mdmon_version(container))
+ return -1;

ent = mdstat_read(0, 0);
if (!ent) {

--
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/3] FIX: Block array monitoring if any array is under reshape

am 29.09.2011 17:53:45 von adam.kwolek

When reshape is started in container on single array, all other container
members are blocked from monitoring also. After container reassembly
we have to construct the same situation.
Currently array under reshape is blocked only.

To block whole container during reshape we have 2 cases:
1. first assembled array is not reshaped and second is under reshape
2. first assembled array not reshaped and second is not under reshape

This patch addresses first case.
If current array is under reshape, block it. Second not reshaped array
will be blocked if container has any blocked array.

Signed-off-by: Adam Kwolek
---

Assemble.c | 19 +++++++++++++++++--
Grow.c | 28 ++++++++++++++++++++++++++++
mdadm.h | 2 ++
msg.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
msg.h | 1 +
5 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/Assemble.c b/Assemble.c
index c6aad20..59ce650 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -1526,8 +1526,23 @@ int assemble_container_content(struct supertype *st, int mdfd,
if (sysfs_set_array(content, md_get_version(mdfd)) != 0)
return 1;

- if (content->reshape_active)
- block_subarray(content);
+
+ if (st->ss->external) {
+ if (content->reshape_active) {
+ /* Current array in container is under reshape
+ * block it from monitoring
+ */
+ block_subarray(content);
+ } else {
+ /* If any previously assembled array is under reshape
+ * currently assembled array have to be blocked before
+ * array activation also.
+ * Check if any array in container is blocked
+ * and do the same for this one.
+ */
+ block_array_if_any_is_blocked(st, content);
+ }
+ }

if (sra)
sysfs_free(sra);
diff --git a/Grow.c b/Grow.c
index 4a25165..3e13c8f 100644
--- a/Grow.c
+++ b/Grow.c
@@ -539,6 +539,34 @@ static int check_idle(struct supertype *st)
return is_idle;
}

+/* Block currently assembed array if any array in container
+ * is blocked.
+ * Function has to be used during container assembly
+ * to make sure that all arrays in container are blocked
+ * if one is under reshape.
+ * This restores situation when reshape is started when
+ * all container components are blocked.
+ */
+int block_array_if_any_is_blocked(struct supertype *st, struct mdinfo *content)
+{
+ int container_dev = (st->container_dev != NoMdDev
+ ? st->container_dev : st->devnum);
+ char buf[1024];
+
+ fmt_devname(buf, container_dev);
+
+ if (check_blocked_monitor(buf) > 0) {
+ if (sysfs_get_str(content, NULL, "metadata_version",
+ buf, 1024) > 0) {
+ buf[9] = '-';
+ sysfs_set_str(content, NULL, "metadata_version", buf);
+ }
+ }
+
+ return 1;
+}
+
+
static int freeze_container(struct supertype *st)
{
int container_dev = (st->container_dev != NoMdDev
diff --git a/mdadm.h b/mdadm.h
index 8dd37d9..d0ffd4d 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -477,6 +477,8 @@ extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume);
extern int sysfs_disk_to_scsi_id(int fd, __u32 *id);
extern int sysfs_unique_holder(int devnum, long rdev);
extern int sysfs_freeze_array(struct mdinfo *sra);
+extern int block_array_if_any_is_blocked(struct supertype *st,
+ struct mdinfo *content);
extern int load_sys(char *path, char *buf);
extern int reshape_prepare_fdlist(char *devname,
struct mdinfo *sra,
diff --git a/msg.c b/msg.c
index 98d6d13..f903afb 100644
--- a/msg.c
+++ b/msg.c
@@ -424,6 +424,58 @@ int block_monitor(char *container, const int freeze)
return rv;
}

+/* Function checks if any container member or container itself
+ * is blocked (mdmon is blocked).
+ * It can occur that during assembly process first array in container
+ * is under reshape, this means that any activated array
+ * has to be blocked also, to keep whole container blocked
+ * Returns:
+ * -1: error
+ * 0: not blocked
+ * 1: something is blocked
+ */
+int check_blocked_monitor(char *container)
+{
+ struct mdstat_ent *ent, *e;
+ struct mdinfo *sra = NULL;
+ int rv = 0;
+
+ if (check_mdmon_version(container))
+ return -1;
+
+ ent = mdstat_read(0, 0);
+ if (!ent) {
+ fprintf(stderr, Name
+ ": failed to read /proc/mdstat while checking"
+ " if mdmon is disabled\n");
+ return -1;
+ }
+
+ /* check if any container member is frozen */
+ for (e = ent; e; e = e->next) {
+ if (!is_container_member(e, container))
+ continue;
+ sysfs_free(sra);
+ sra = sysfs_read(-1, e->devnum, GET_VERSION);
+ if (!sra) {
+ fprintf(stderr, Name
+ ": failed to read sysfs for subarray%s\n",
+ to_subarray(e, container));
+ break;
+ }
+ /* check frozen state */
+ if (sra->text_version[0] == '-') {
+ rv = 1;
+ break;
+ }
+ }
+
+ sysfs_free(sra);
+ free_mdstat(ent);
+
+ return rv;
+}
+
void unblock_monitor(char *container, const int unfreeze)
{
struct mdstat_ent *ent, *e;
diff --git a/msg.h b/msg.h
index c6d037d..fb5815e 100644
--- a/msg.h
+++ b/msg.h
@@ -32,6 +32,7 @@ extern int block_subarray(struct mdinfo *sra);
extern int unblock_subarray(struct mdinfo *sra, const int unfreeze);
extern int block_monitor(char *container, const int freeze);
extern void unblock_monitor(char *container, const int unfreeze);
+extern int check_blocked_monitor(char *container);
extern int fping_monitor(int sock);
extern int ping_manager(char *devname);


--
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/3] FIX: Remove error message during reshape restart (v2)

am 29.09.2011 17:53:54 von adam.kwolek

When reshape is started in container on single array, all other container
members are blocked from monitoring also. After container reassembly
we have to construct the same situation.
Currently array under reshape is blocked only.

To block whole container during reshape we have 2 cases:
1. first assembled array is not reshaped and second is under reshape
2. first assembled array not reshaped and second is not under reshape

This patch addresses second case.
First assembled array is not reshaped and not blocked. Second reshaped
array is under reshape and it is blocked. When all reshaped array
parameters are verified and set in reshape continue freeze_container()
function block all other present in container and not blocked array(s).

This call to freeze_container() serves for native metadata case also.

This patch replaces its previous version that hides error message only.

Signed-off-by: Adam Kwolek
---

Grow.c | 18 +++++++++---------
msg.c | 10 +++++++---
msg.h | 2 +-
3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/Grow.c b/Grow.c
index 3e13c8f..8f75ab8 100644
--- a/Grow.c
+++ b/Grow.c
@@ -566,8 +566,7 @@ int block_array_if_any_is_blocked(struct supertype *st, struct mdinfo *content)
return 1;
}

-
-static int freeze_container(struct supertype *st)
+static int freeze_container(struct supertype *st, int restart)
{
int container_dev = (st->container_dev != NoMdDev
? st->container_dev : st->devnum);
@@ -575,11 +574,12 @@ static int freeze_container(struct supertype *st)

if (!check_idle(st))
return -1;
-
+
fmt_devname(container, container_dev);

- if (block_monitor(container, 1)) {
- fprintf(stderr, Name ": failed to freeze container\n");
+ if (block_monitor(container, 1, restart)) {
+ if (!restart)
+ fprintf(stderr, Name ": failed to freeze container\n");
return -2;
}

@@ -597,7 +597,7 @@ static void unfreeze_container(struct supertype *st)
unblock_monitor(container, 1);
}

-static int freeze(struct supertype *st)
+static int freeze(struct supertype *st, int restart)
{
/* Try to freeze resync/rebuild on this array/container.
* Return -1 if the array is busy,
@@ -606,7 +606,7 @@ static int freeze(struct supertype *st)
* return 1 if it worked.
*/
if (st->ss->external)
- return freeze_container(st);
+ return freeze_container(st, restart);
else {
struct mdinfo *sra = sysfs_read(-1, st->devnum, GET_VERSION);
int err;
@@ -1522,7 +1522,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
devname);
return 1;
}
- frozen = freeze(st);
+ frozen = freeze(st, 0);
if (frozen < -1) {
/* freeze() already spewed the reason */
return 1;
@@ -3653,7 +3653,7 @@ int Grow_continue(int mdfd, struct supertype *st, struct mdinfo *info,
if (st->ss->external) {
fmt_devname(buf, st->container_dev);
container = buf;
- freeze(st);
+ freeze(st, 1);

if (!mdmon_running(st->container_dev))
start_mdmon(st->container_dev);
diff --git a/msg.c b/msg.c
index f903afb..48a5bc3 100644
--- a/msg.c
+++ b/msg.c
@@ -334,7 +334,7 @@ int check_mdmon_version(char *container)
* As older versions of mdmon (which might run from initrd) don't understand
* this, we first check that the running mdmon is new enough.
*/
-int block_monitor(char *container, const int freeze)
+int block_monitor(char *container, const int freeze, const int restart)
{
struct mdstat_ent *ent, *e, *e2;
struct mdinfo *sra = NULL;
@@ -364,8 +364,12 @@ int block_monitor(char *container, const int freeze)
break;
}
/* can't reshape an array that we can't monitor */
- if (sra->text_version[0] == '-')
- break;
+ if (sra->text_version[0] == '-') {
+ if (restart)
+ continue;
+ else
+ break;
+ }

if (freeze && sysfs_freeze_array(sra) < 1)
break;
diff --git a/msg.h b/msg.h
index fb5815e..15aef2a 100644
--- a/msg.h
+++ b/msg.h
@@ -30,7 +30,7 @@ extern int ping_monitor(char *devname);
extern int ping_monitor_by_id(int devnum);
extern int block_subarray(struct mdinfo *sra);
extern int unblock_subarray(struct mdinfo *sra, const int unfreeze);
-extern int block_monitor(char *container, const int freeze);
+extern int block_monitor(char *container, const int freeze, const int restart);
extern void unblock_monitor(char *container, const int unfreeze);
extern int check_blocked_monitor(char *container);
extern int fping_monitor(int sock);

--
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 1/3] Move code to check_mdmon_version() function

am 03.10.2011 01:45:56 von NeilBrown

--Sig_/r_ZwJ6_RJw+WcI2.MPPk4X.
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Thu, 29 Sep 2011 17:53:36 +0200 Adam Kwolek wrot=
e:

> Move code to function for code reuse.
>=20
> Signed-off-by: Adam Kwolek

Applied, thanks.

though it might be better for "check_mdmon_version" also took a version
number to compare against.

NeilBrown

> ---
>=20
> msg.c | 59 ++++++++++++++++++++++++++++++++++++-----------------------
> 1 files changed, 36 insertions(+), 23 deletions(-)
>=20
> diff --git a/msg.c b/msg.c
> index a10c930..98d6d13 100644
> --- a/msg.c
> +++ b/msg.c
> @@ -281,6 +281,40 @@ int block_subarray(struct mdinfo *sra)
> =20
> return rc;
> }
> +
> +/* check mdmon version if it supports
> + * array blocking mechanism
> + */
> +int check_mdmon_version(char *container)
> +{
> + char *version =3D NULL;
> + int devnum =3D devname2devnum(container);
> +
> + if (!mdmon_running(devnum)) {
> + /* if mdmon is not active we assume that any instance that is
> + * later started will match the current mdadm version, if this
> + * assumption is violated we may inadvertantly rebuild an array
> + * that was meant for reshape, or start rebuild on a spare that
> + * was to be moved to another container
> + */
> + /* pass */;
> + } else {
> + int ver;
> +
> + version =3D ping_monitor_version(container);
> + ver =3D version ? mdadm_version(version) : -1;
> + free(version);
> + if (ver < 3002000) {
> + fprintf(stderr, Name
> + ": mdmon instance for %s cannot be disabled\n",
> + container);
> + return -1;
> + }
> + }
> +
> + return 0;
> +}
> +
> /**
> * block_monitor - prevent mdmon spare assignment
> * @container - container to block
> @@ -302,34 +336,13 @@ int block_subarray(struct mdinfo *sra)
> */
> int block_monitor(char *container, const int freeze)
> {
> - int devnum =3D devname2devnum(container);
> struct mdstat_ent *ent, *e, *e2;
> struct mdinfo *sra =3D NULL;
> - char *version =3D NULL;
> char buf[64];
> int rv =3D 0;
> =20
> - if (!mdmon_running(devnum)) {
> - /* if mdmon is not active we assume that any instance that is
> - * later started will match the current mdadm version, if this
> - * assumption is violated we may inadvertantly rebuild an array
> - * that was meant for reshape, or start rebuild on a spare that
> - * was to be moved to another container
> - */
> - /* pass */;
> - } else {
> - int ver;
> -
> - version =3D ping_monitor_version(container);
> - ver =3D version ? mdadm_version(version) : -1;
> - free(version);
> - if (ver < 3002000) {
> - fprintf(stderr, Name
> - ": mdmon instance for %s cannot be disabled\n",
> - container);
> - return -1;
> - }
> - }
> + if (check_mdmon_version(container))
> + return -1;
> =20
> ent =3D mdstat_read(0, 0);
> if (!ent) {



--Sig_/r_ZwJ6_RJw+WcI2.MPPk4X.
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)

iD8DBQFOiPe0G5fc6gV+Wb0RAqLHAKDW+mI+oIdUdHH2S2NuWU9cn3qh6QCf czuE
G/eAlVgdLQGh8DCasNnFLg4=
=y30n
-----END PGP SIGNATURE-----

--Sig_/r_ZwJ6_RJw+WcI2.MPPk4X.--
--
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 2/3] FIX: Block array monitoring if any array is underreshape in container

am 03.10.2011 01:54:20 von NeilBrown

--Sig_/YR1=WaAv5k0l3sHuDZ.NnAq
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Thu, 29 Sep 2011 17:53:45 +0200 Adam Kwolek wrot=
e:

> When reshape is started in container on single array, all other container
> members are blocked from monitoring also. After container reassembly
> we have to construct the same situation.
> Currently array under reshape is blocked only.
>=20
> To block whole container during reshape we have 2 cases:
> 1. first assembled array is not reshaped and second is under reshape
> 2. first assembled array not reshaped and second is not under reshape
>=20
> This patch addresses first case.
> If current array is under reshape, block it. Second not reshaped array
> will be blocked if container has any blocked array.

This feels like the wrong approach.

The metadata for the container should "know" if a reshape is pending and so
rebuilt monitoring should be disabled.

So I think we could just arrange that "struct mdinfo" has some flag which
says "recovery-blocked". And we block based on that.=20
That feels a lot more robust that looking through /sys for the other parts =
of
the array.

Could you try that please?

Thanks,
NeilBrown


>=20
> Signed-off-by: Adam Kwolek
> ---
>=20
> Assemble.c | 19 +++++++++++++++++--
> Grow.c | 28 ++++++++++++++++++++++++++++
> mdadm.h | 2 ++
> msg.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> msg.h | 1 +
> 5 files changed, 100 insertions(+), 2 deletions(-)
>=20
> diff --git a/Assemble.c b/Assemble.c
> index c6aad20..59ce650 100644
> --- a/Assemble.c
> +++ b/Assemble.c
> @@ -1526,8 +1526,23 @@ int assemble_container_content(struct supertype *s=
t, int mdfd,
> if (sysfs_set_array(content, md_get_version(mdfd)) !=3D 0)
> return 1;
> =20
> - if (content->reshape_active)
> - block_subarray(content);
> +
> + if (st->ss->external) {
> + if (content->reshape_active) {
> + /* Current array in container is under reshape
> + * block it from monitoring
> + */
> + block_subarray(content);
> + } else {
> + /* If any previously assembled array is under reshape
> + * currently assembled array have to be blocked before
> + * array activation also.
> + * Check if any array in container is blocked
> + * and do the same for this one.
> + */
> + block_array_if_any_is_blocked(st, content);
> + }
> + }
> =20
> if (sra)
> sysfs_free(sra);
> diff --git a/Grow.c b/Grow.c
> index 4a25165..3e13c8f 100644
> --- a/Grow.c
> +++ b/Grow.c
> @@ -539,6 +539,34 @@ static int check_idle(struct supertype *st)
> return is_idle;
> }
> =20
> +/* Block currently assembed array if any array in container
> + * is blocked.
> + * Function has to be used during container assembly
> + * to make sure that all arrays in container are blocked
> + * if one is under reshape.
> + * This restores situation when reshape is started when
> + * all container components are blocked.
> + */
> +int block_array_if_any_is_blocked(struct supertype *st, struct mdinfo *c=
ontent)
> +{
> + int container_dev =3D (st->container_dev !=3D NoMdDev
> + ? st->container_dev : st->devnum);
> + char buf[1024];
> +
> + fmt_devname(buf, container_dev);
> +
> + if (check_blocked_monitor(buf) > 0) {
> + if (sysfs_get_str(content, NULL, "metadata_version",
> + buf, 1024) > 0) {
> + buf[9] =3D '-';
> + sysfs_set_str(content, NULL, "metadata_version", buf);
> + }
> + }
> +
> + return 1;
> +}
> +
> +
> static int freeze_container(struct supertype *st)
> {
> int container_dev =3D (st->container_dev !=3D NoMdDev
> diff --git a/mdadm.h b/mdadm.h
> index 8dd37d9..d0ffd4d 100644
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -477,6 +477,8 @@ extern int sysfs_add_disk(struct mdinfo *sra, struct =
mdinfo *sd, int resume);
> extern int sysfs_disk_to_scsi_id(int fd, __u32 *id);
> extern int sysfs_unique_holder(int devnum, long rdev);
> extern int sysfs_freeze_array(struct mdinfo *sra);
> +extern int block_array_if_any_is_blocked(struct supertype *st,
> + struct mdinfo *content);
> extern int load_sys(char *path, char *buf);
> extern int reshape_prepare_fdlist(char *devname,
> struct mdinfo *sra,
> diff --git a/msg.c b/msg.c
> index 98d6d13..f903afb 100644
> --- a/msg.c
> +++ b/msg.c
> @@ -424,6 +424,58 @@ int block_monitor(char *container, const int freeze)
> return rv;
> }
> =20
> +/* Function checks if any container member or container itself
> + * is blocked (mdmon is blocked).
> + * It can occur that during assembly process first array in container
> + * is under reshape, this means that any activated array
> + * has to be blocked also, to keep whole container blocked
> + * Returns:
> + * -1: error
> + * 0: not blocked
> + * 1: something is blocked
> + */
> +int check_blocked_monitor(char *container)
> +{
> + struct mdstat_ent *ent, *e;
> + struct mdinfo *sra =3D NULL;
> + int rv =3D 0;
> +
> + if (check_mdmon_version(container))
> + return -1;
> +
> + ent =3D mdstat_read(0, 0);
> + if (!ent) {
> + fprintf(stderr, Name
> + ": failed to read /proc/mdstat while checking"
> + " if mdmon is disabled\n");
> + return -1;
> + }
> +
> + /* check if any container member is frozen */
> + for (e =3D ent; e; e =3D e->next) {
> + if (!is_container_member(e, container))
> + continue;
> + sysfs_free(sra);
> + sra =3D sysfs_read(-1, e->devnum, GET_VERSION);
> + if (!sra) {
> + fprintf(stderr, Name
> + ": failed to read sysfs for subarray%s\n",
> + to_subarray(e, container));
> + break;
> + }
> + /* check frozen state */
> + if (sra->text_version[0] == '-') {
> + rv =3D 1;
> + break;
> + }
> + }
> +
> + sysfs_free(sra);
> + free_mdstat(ent);
> +
> + return rv;
> +}
> +
> void unblock_monitor(char *container, const int unfreeze)
> {
> struct mdstat_ent *ent, *e;
> diff --git a/msg.h b/msg.h
> index c6d037d..fb5815e 100644
> --- a/msg.h
> +++ b/msg.h
> @@ -32,6 +32,7 @@ extern int block_subarray(struct mdinfo *sra);
> extern int unblock_subarray(struct mdinfo *sra, const int unfreeze);
> extern int block_monitor(char *container, const int freeze);
> extern void unblock_monitor(char *container, const int unfreeze);
> +extern int check_blocked_monitor(char *container);
> extern int fping_monitor(int sock);
> extern int ping_manager(char *devname);
> =20


--Sig_/YR1=WaAv5k0l3sHuDZ.NnAq
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)

iD8DBQFOiPmsG5fc6gV+Wb0RAkQnAJ4oV08LPiFflUwGSEfiZ3prOwaIjgCe L4YX
CG0xL951pIGI0kOmIzL2fIA=
=bQOl
-----END PGP SIGNATURE-----

--Sig_/YR1=WaAv5k0l3sHuDZ.NnAq--
--
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 3/3] FIX: Remove error message during reshape restart(v2)

am 03.10.2011 01:57:15 von NeilBrown

--Sig_/0p8TyACR9Ikv3VbWDm5_S_e
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Thu, 29 Sep 2011 17:53:54 +0200 Adam Kwolek wrot=
e:

> When reshape is started in container on single array, all other container
> members are blocked from monitoring also. After container reassembly
> we have to construct the same situation.
> Currently array under reshape is blocked only.
>=20
> To block whole container during reshape we have 2 cases:
> 1. first assembled array is not reshaped and second is under reshape
> 2. first assembled array not reshaped and second is not under reshape
>=20
> This patch addresses second case.
> First assembled array is not reshaped and not blocked. Second reshaped
> array is under reshape and it is blocked. When all reshaped array
> parameters are verified and set in reshape continue freeze_container()
> function block all other present in container and not blocked array(s).
>=20
> This call to freeze_container() serves for native metadata case also.
>=20
> This patch replaces its previous version that hides error message only.

I won't apply this one just now as it relates to the previous patch that I
want changed.
If you still think this is appropriate, please resubmit with the other fixe=
s.

Thanks,

NeilBrown


>=20
> Signed-off-by: Adam Kwolek
> ---
>=20
> Grow.c | 18 +++++++++---------
> msg.c | 10 +++++++---
> msg.h | 2 +-
> 3 files changed, 17 insertions(+), 13 deletions(-)
>=20
> diff --git a/Grow.c b/Grow.c
> index 3e13c8f..8f75ab8 100644
> --- a/Grow.c
> +++ b/Grow.c
> @@ -566,8 +566,7 @@ int block_array_if_any_is_blocked(struct supertype *s=
t, struct mdinfo *content)
> return 1;
> }
> =20
> -
> -static int freeze_container(struct supertype *st)
> +static int freeze_container(struct supertype *st, int restart)
> {
> int container_dev =3D (st->container_dev !=3D NoMdDev
> ? st->container_dev : st->devnum);
> @@ -575,11 +574,12 @@ static int freeze_container(struct supertype *st)
> =20
> if (!check_idle(st))
> return -1;
> -=09
> +
> fmt_devname(container, container_dev);
> =20
> - if (block_monitor(container, 1)) {
> - fprintf(stderr, Name ": failed to freeze container\n");
> + if (block_monitor(container, 1, restart)) {
> + if (!restart)
> + fprintf(stderr, Name ": failed to freeze container\n");
> return -2;
> }
> =20
> @@ -597,7 +597,7 @@ static void unfreeze_container(struct supertype *st)
> unblock_monitor(container, 1);
> }
> =20
> -static int freeze(struct supertype *st)
> +static int freeze(struct supertype *st, int restart)
> {
> /* Try to freeze resync/rebuild on this array/container.
> * Return -1 if the array is busy,
> @@ -606,7 +606,7 @@ static int freeze(struct supertype *st)
> * return 1 if it worked.
> */
> if (st->ss->external)
> - return freeze_container(st);
> + return freeze_container(st, restart);
> else {
> struct mdinfo *sra =3D sysfs_read(-1, st->devnum, GET_VERSION);
> int err;
> @@ -1522,7 +1522,7 @@ int Grow_reshape(char *devname, int fd, int quiet, =
char *backup_file,
> devname);
> return 1;
> }
> - frozen =3D freeze(st);
> + frozen =3D freeze(st, 0);
> if (frozen < -1) {
> /* freeze() already spewed the reason */
> return 1;
> @@ -3653,7 +3653,7 @@ int Grow_continue(int mdfd, struct supertype *st, s=
truct mdinfo *info,
> if (st->ss->external) {
> fmt_devname(buf, st->container_dev);
> container =3D buf;
> - freeze(st);
> + freeze(st, 1);
> =20
> if (!mdmon_running(st->container_dev))
> start_mdmon(st->container_dev);
> diff --git a/msg.c b/msg.c
> index f903afb..48a5bc3 100644
> --- a/msg.c
> +++ b/msg.c
> @@ -334,7 +334,7 @@ int check_mdmon_version(char *container)
> * As older versions of mdmon (which might run from initrd) don't unders=
tand
> * this, we first check that the running mdmon is new enough.
> */
> -int block_monitor(char *container, const int freeze)
> +int block_monitor(char *container, const int freeze, const int restart)
> {
> struct mdstat_ent *ent, *e, *e2;
> struct mdinfo *sra =3D NULL;
> @@ -364,8 +364,12 @@ int block_monitor(char *container, const int freeze)
> break;
> }
> /* can't reshape an array that we can't monitor */
> - if (sra->text_version[0] == '-')
> - break;
> + if (sra->text_version[0] == '-') {
> + if (restart)
> + continue;
> + else
> + break;
> + }
> =20
> if (freeze && sysfs_freeze_array(sra) < 1)
> break;
> diff --git a/msg.h b/msg.h
> index fb5815e..15aef2a 100644
> --- a/msg.h
> +++ b/msg.h
> @@ -30,7 +30,7 @@ extern int ping_monitor(char *devname);
> extern int ping_monitor_by_id(int devnum);
> extern int block_subarray(struct mdinfo *sra);
> extern int unblock_subarray(struct mdinfo *sra, const int unfreeze);
> -extern int block_monitor(char *container, const int freeze);
> +extern int block_monitor(char *container, const int freeze, const int re=
start);
> extern void unblock_monitor(char *container, const int unfreeze);
> extern int check_blocked_monitor(char *container);
> extern int fping_monitor(int sock);


--Sig_/0p8TyACR9Ikv3VbWDm5_S_e
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)

iD8DBQFOiPpbG5fc6gV+Wb0RAv2JAKCPg5bup5in3tweh71E6Su2WjrbzwCg gB9t
83N5ST+mtCF/LrwtOICE9dE=
=X88M
-----END PGP SIGNATURE-----

--Sig_/0p8TyACR9Ikv3VbWDm5_S_e--
--
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