[PATCH] FIX: chunk_size cannot be read by mdstat

[PATCH] FIX: chunk_size cannot be read by mdstat

am 29.11.2010 10:56:50 von adam.kwolek

Chunk size is not read by mdstat due to too week checking of 'check' string in mdstat.
It is the same result for 'check' and 'chunk_size' check.

Add string length additional condition for checking.

Signed-off-by: Adam Kwolek
---

mdstat.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/mdstat.c b/mdstat.c
index bb030bf..5f69e31 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -248,7 +248,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
else
ent->resync = 0;
} else if (ent->percent == -1 &&
- (w[0] == 'r' || w[0] == 'c')) {
+ (w[0] == 'r' ||
+ ((w[0] == 'c') && strlen(w) < 9))) {
if (strncmp(w, "resync", 4)==0)
ent->resync = 1;
if (strncmp(w, "reshape", 7)==0)

--
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] FIX: chunk_size cannot be read by mdstat

am 29.11.2010 15:26:19 von adam.kwolek

SSd2ZSBmb3VuZCB0aGF0IGNvbmRpdGlvbiBvbiBzdHJsZW4oKSBkb2Vzbid0 IGFsd2F5cyB3b3Jr
IChJIHdhbnRlZCB0byBhY2hpZXZlIHRoZSBzYW1lIGNvZGUgc3R5bGUgOykp LA0Kc28gY2hlY2sg
Zm9yICJjaGVjayIgc3RyaW5nIGhhcyB0byBiZSB1c2VkIGluc3RlYWQuDQoN CkJSDQpBZGFtDQoN
Cg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBsaW51 eC1yYWlkLW93bmVy
QHZnZXIua2VybmVsLm9yZyBbbWFpbHRvOmxpbnV4LXJhaWQtDQo+IG93bmVy QHZnZXIua2VybmVs
Lm9yZ10gT24gQmVoYWxmIE9mIEFkYW0gS3dvbGVrDQo+IFNlbnQ6IE1vbmRh eSwgTm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Vsc2UgaWYgKGVudC0+cGVyY2Vu dCA9PSAtMSAmJg0K
PiAtCQkJCSAgICh3WzBdID09ICdyJyB8fCB3WzBdID09ICdjJykpIHsNCj4g KwkJCQkgICAod1sw
XSA9PSAncicgfHwNCj4gKwkJCQkgICAgKCh3WzBdID09ICdjJykgJiYgc3Ry bGVuKHcpIDwgOSkp
KSB7DQo+ICAJCQkJaWYgKHN0cm5jbXAodywgInJlc3luYyIsIDQpPT0wKQ0K PiAgCQkJCQllbnQt
PnJlc3luYyA9IDE7DQo+ICAJCQkJaWYgKHN0cm5jbXAodywgInJlc2hhcGUi LCA3KT09MCkNCj4g
DQo+IC0tDQo+IFRvIHVuc3Vic2NyaWJlIGZyb20gdGhpcyBsaXN0OiBzZW5k IHRoZSBsaW5lICJ1
bnN1YnNjcmliZSBsaW51eC1yYWlkIg0KPiBpbg0KPiB0aGUgYm9keSBvZiBh IG1lc3NhZ2UgdG8g
bWFqb3Jkb21vQHZnZXIua2VybmVsLm9yZw0KPiBNb3JlIG1ham9yZG9tbyBp bmZvIGF0ICBodHRw
Oi8vdmdlci5rZXJuZWwub3JnL21ham9yZG9tby1pbmZvLmh0bWwNCg==
--
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] FIX: chunk_size cannot be read by mdstat

am 30.11.2010 01:22:11 von NeilBrown

On Mon, 29 Nov 2010 10:56:50 +0100 Adam Kwolek wrote:

> Chunk size is not read by mdstat due to too week checking of 'check' string in mdstat.
> It is the same result for 'check' and 'chunk_size' check.

Actually chunk size is not read because there is no code to try to read it.
The chunk size needs to be reported by the personality, and they are
inconsistent in the way they report it so it is much easier to just ignore it.
GET_ARRAY_INFO gets the chunk size easily, so we stick with that when chunk
size is needed.

Thanks,
NeilBrown



>
> Add string length additional condition for checking.
>
> Signed-off-by: Adam Kwolek
> ---
>
> mdstat.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/mdstat.c b/mdstat.c
> index bb030bf..5f69e31 100644
> --- a/mdstat.c
> +++ b/mdstat.c
> @@ -248,7 +248,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
> else
> ent->resync = 0;
> } else if (ent->percent == -1 &&
> - (w[0] == 'r' || w[0] == 'c')) {
> + (w[0] == 'r' ||
> + ((w[0] == 'c') && strlen(w) < 9))) {
> if (strncmp(w, "resync", 4)==0)
> ent->resync = 1;
> if (strncmp(w, "reshape", 7)==0)

--
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] FIX: chunk_size cannot be read by mdstat

am 30.11.2010 08:28:01 von adam.kwolek

In such case code:
a->info.array.chunk_size = mdstat->chunk_size;

from managemon.c, function manage_member()
has to be removed or guarded for 0 value of mdstat->chunk_size as it corrupts information in active array.

BR
Adam




> -----Original Message-----
> From: Neil Brown [mailto:neilb@suse.de]
> Sent: Tuesday, November 30, 2010 1:22 AM
> To: Kwolek, Adam
> Cc: linux-raid@vger.kernel.org; Williams, Dan J; Ciechanowski, Ed
> Subject: Re: [PATCH] FIX: chunk_size cannot be read by mdstat
>
> On Mon, 29 Nov 2010 10:56:50 +0100 Adam Kwolek
> wrote:
>
> > Chunk size is not read by mdstat due to too week checking of 'check'
> string in mdstat.
> > It is the same result for 'check' and 'chunk_size' check.
>
> Actually chunk size is not read because there is no code to try to read
> it.
> The chunk size needs to be reported by the personality, and they are
> inconsistent in the way they report it so it is much easier to just
> ignore it.
> GET_ARRAY_INFO gets the chunk size easily, so we stick with that when
> chunk
> size is needed.
>
> Thanks,
> NeilBrown
>
>
>
> >
> > Add string length additional condition for checking.
> >
> > Signed-off-by: Adam Kwolek
> > ---
> >
> > mdstat.c | 3 ++-
> > 1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/mdstat.c b/mdstat.c
> > index bb030bf..5f69e31 100644
> > --- a/mdstat.c
> > +++ b/mdstat.c
> > @@ -248,7 +248,8 @@ struct mdstat_ent *mdstat_read(int hold, int
> start)
> > else
> > ent->resync = 0;
> > } else if (ent->percent == -1 &&
> > - (w[0] == 'r' || w[0] == 'c')) {
> > + (w[0] == 'r' ||
> > + ((w[0] == 'c') && strlen(w) < 9))) {
> > if (strncmp(w, "resync", 4)==0)
> > ent->resync = 1;
> > if (strncmp(w, "reshape", 7)==0)

--
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] FIX: chunk_size cannot be read by mdstat

am 30.11.2010 08:36:18 von NeilBrown

On Tue, 30 Nov 2010 07:28:01 +0000 "Kwolek, Adam"
wrote:

> In such case code:
> a->info.array.chunk_size = mdstat->chunk_size;
>
> from managemon.c, function manage_member()
> has to be removed or guarded for 0 value of mdstat->chunk_size as it corrupts information in active array.
>

Good point. I have removed that assignment, and removed the chunk_size field
from mdstat_ent.

Thanks,
NeilBrown

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