linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 32/33] Fix the count of member devices in mdstat_read function.
       [not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C67@irsmsx504.ger.corp.intel.com>
@ 2010-07-05 10:51 ` Hawrylewicz Czarnowski, Przemyslaw
  2010-07-06  7:51 ` Neil Brown
  1 sibling, 0 replies; 2+ messages in thread
From: Hawrylewicz Czarnowski, Przemyslaw @ 2010-07-05 10:51 UTC (permalink / raw)
  To: linux-raid@vger.kernel.org

From: Czarnowska, Anna 
Sent: Monday, July 05, 2010 11:45 AM
To: Neil Brown
Cc: linux-raid@vger.kernel.org; Czarnowska, Anna; Hawrylewicz Czarnowski, Przemyslaw; Labun, Marcin; Neubauer, Wojciech; Williams, Dan J; Ciechanowski, Ed; dledford@redhat.com
Subject: [PATCH 32/33] Fix the count of member devices in mdstat_read function.

From: Marcin Labun <marcin.labun@intel.com>

Correction of the number of container or volume member devices (devcnt in struct mdstat_ent). The number after the last devices was counted towards member of devices.

Signed-off-by: Marcin Labun <marcin.labun@intel.com>
---
 mdstat.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/mdstat.c b/mdstat.c
index 01a126b..5b9d997 100644
--- a/mdstat.c
+++ b/mdstat.c
@@ -94,19 +94,20 @@ static void free_member_devnames(struct dev_member *m)
      }
 }
 
-static void add_member_devname(struct dev_member **m, char *name)
+static int add_member_devname(struct dev_member **m, char *name)
 {
      struct dev_member *new;
      char *t;
 
      if ((t = strchr(name, '[')) == NULL)
            /* not a device */
-           return;
+           return 1;
 
      new = malloc(sizeof(*new));
      new->name = strndup(name, t - name);
      new->next = *m;
      *m = new;
+     return 0;
 }
 
 void free_mdstat(struct mdstat_ent *ms) @@ -207,8 +208,9 @@ struct mdstat_ent *mdstat_read(int hold, int start)
                  } else if (in_devs && strcmp(w, "blocks")==0)
                        in_devs = 0;
                  else if (in_devs) {
-                       ent->devcnt++;
-                       add_member_devname(&ent->members, w);
+
+                       if (add_member_devname(&ent->members, w) == 0)
+                             ent->devcnt++;
                        if (strncmp(w, "md", 2)==0) {
                              /* This has an md device as a component.
                               * If that device is already in the
--
1.6.4.2


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

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

* Re: [PATCH 32/33] Fix the count of member devices in mdstat_read function.
       [not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C67@irsmsx504.ger.corp.intel.com>
  2010-07-05 10:51 ` [PATCH 32/33] Fix the count of member devices in mdstat_read function Hawrylewicz Czarnowski, Przemyslaw
@ 2010-07-06  7:51 ` Neil Brown
  1 sibling, 0 replies; 2+ messages in thread
From: Neil Brown @ 2010-07-06  7:51 UTC (permalink / raw)
  To: Czarnowska, Anna
  Cc: linux-raid@vger.kernel.org, Hawrylewicz Czarnowski, Przemyslaw,
	Labun, Marcin, Neubauer, Wojciech, Williams, Dan J,
	Ciechanowski, Ed, dledford@redhat.com

On Mon, 5 Jul 2010 10:45:05 +0100
"Czarnowska, Anna" <anna.czarnowska@intel.com> wrote:

> From: Marcin Labun <marcin.labun@intel.com>
> 
> 
> 
> Correction of the number of container or volume member devices (devcnt in struct mdstat_ent). The number after the last devices was counted towards member of devices.

Thanks.
I have applied this fix, though I inverted the value returned by
add_member_devname so it is 0 for failure and 1 for success.
(if 0 is used for success, then it is best to use negative numbers for
failure I find).

NeilBrown


> 
> 
> 
> Signed-off-by: Marcin Labun <marcin.labun@intel.com<mailto:marcin.labun@intel.com>>
> 
> ---
> 
>  mdstat.c |   10 ++++++----
> 
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> 
> 
> diff --git a/mdstat.c b/mdstat.c
> 
> index 01a126b..5b9d997 100644
> 
> --- a/mdstat.c
> 
> +++ b/mdstat.c
> 
> @@ -94,19 +94,20 @@ static void free_member_devnames(struct dev_member *m)
> 
>       }
> 
>  }
> 
> 
> 
> -static void add_member_devname(struct dev_member **m, char *name)
> 
> +static int add_member_devname(struct dev_member **m, char *name)
> 
>  {
> 
>       struct dev_member *new;
> 
>       char *t;
> 
> 
> 
>       if ((t = strchr(name, '[')) == NULL)
> 
>             /* not a device */
> 
> -           return;
> 
> +           return 1;
> 
> 
> 
>       new = malloc(sizeof(*new));
> 
>       new->name = strndup(name, t - name);
> 
>       new->next = *m;
> 
>       *m = new;
> 
> +     return 0;
> 
>  }
> 
> 
> 
>  void free_mdstat(struct mdstat_ent *ms) @@ -207,8 +208,9 @@ struct mdstat_ent *mdstat_read(int hold, int start)
> 
>                   } else if (in_devs && strcmp(w, "blocks")==0)
> 
>                         in_devs = 0;
> 
>                   else if (in_devs) {
> 
> -                       ent->devcnt++;
> 
> -                       add_member_devname(&ent->members, w);
> 
> +
> 
> +                       if (add_member_devname(&ent->members, w) == 0)
> 
> +                             ent->devcnt++;
> 
>                         if (strncmp(w, "md", 2)==0) {
> 
>                               /* This has an md device as a component.
> 
>                                * If that device is already in the
> 
> --
> 
> 1.6.4.2
> 
> 
> 
> ---------------------------------------------------------------------
> Intel Technology Poland sp. z o.o.
> z siedziba w Gdansku
> ul. Slowackiego 173
> 80-298 Gdansk
> 
> Sad Rejonowy Gdansk Polnoc w Gdansku, 
> VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, 
> numer KRS 101882
> 
> NIP 957-07-52-316
> Kapital zakladowy 200.000 zl
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.


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

end of thread, other threads:[~2010-07-06  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <A9DE54D0CD747C4CB06DCE5B6FA2246FDA893C67@irsmsx504.ger.corp.intel.com>
2010-07-05 10:51 ` [PATCH 32/33] Fix the count of member devices in mdstat_read function Hawrylewicz Czarnowski, Przemyslaw
2010-07-06  7:51 ` Neil Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).