Re: [PATCH 32/33] Fix the count of member devices in mdstat_read function.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> From: Marcin Labun <marcin.labun@xxxxxxxxx>
> 
> 
> 
> 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@xxxxxxxxx<mailto:marcin.labun@xxxxxxxxx>>
> 
> ---
> 
>  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.

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


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux