]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Increase buffer for sysfs disk state
authorTomasz Majchrzak <tomasz.majchrzak@intel.com>
Thu, 27 Oct 2016 09:34:16 +0000 (11:34 +0200)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Thu, 17 Nov 2016 14:46:42 +0000 (09:46 -0500)
Bad block support has incremented sysfs disk state reported by kernel
("external_bbl") so it became longer than 20 bytes. It causes reshape to
fail as it reads truncated entry from sysfs.

Increase buffer so it can accommodate the string including all state
values currently implemented in kernel at the same time.

Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Grow.c
monitor.c
super-intel.c

diff --git a/Grow.c b/Grow.c
index a8f62432c86a4170f80931e5ca7ad34f680d2e7d..455c5f90bf58c27408235396c5914bbcfc02ec85 100755 (executable)
--- a/Grow.c
+++ b/Grow.c
@@ -4048,8 +4048,10 @@ static int grow_backup(struct mdinfo *sra,
                        if (sd->disk.state & (1<<MD_DISK_FAULTY))
                                continue;
                        if (sd->disk.state & (1<<MD_DISK_SYNC)) {
-                               char sbuf[20];
-                               if (sysfs_get_str(sra, sd, "state", sbuf, 20) < 0 ||
+                               char sbuf[100];
+
+                               if (sysfs_get_str(sra, sd, "state",
+                                                 sbuf, sizeof(sbuf)) < 0 ||
                                    strstr(sbuf, "faulty") ||
                                    strstr(sbuf, "in_sync") == NULL) {
                                        /* this device is dead */
index 4c79ce23b4308b9119f6333d1ea6aac53ac8b614..3c554abaf144f2ae1e7bd69ea3de757a1f71f83e 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -131,8 +131,8 @@ static enum sync_action read_action( int fd)
 
 int read_dev_state(int fd)
 {
-       char buf[60];
-       int n = read_attr(buf, 60, fd);
+       char buf[100];
+       int n = read_attr(buf, sizeof(buf), fd);
        char *cp;
        int rv = 0;
 
index 1f79eab82886046e45b1fddfea2ccbaf6cd86a05..574008809895cb0117c3bca90f406614902afb01 100644 (file)
@@ -10708,9 +10708,10 @@ int check_degradation_change(struct mdinfo *info,
                        if (sd->disk.state & (1<<MD_DISK_FAULTY))
                                continue;
                        if (sd->disk.state & (1<<MD_DISK_SYNC)) {
-                               char sbuf[20];
+                               char sbuf[100];
+
                                if (sysfs_get_str(info,
-                                       sd, "state", sbuf, 20) < 0 ||
+                                       sd, "state", sbuf, sizeof(sbuf)) < 0 ||
                                        strstr(sbuf, "faulty") ||
                                        strstr(sbuf, "in_sync") == NULL) {
                                        /* this device is dead */