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

 



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

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.

Signed-off-by: Marcin Labun <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


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