Increase buffer for sysfs disk state

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>
This commit is contained in:
Tomasz Majchrzak 2016-10-27 11:34:16 +02:00 committed by Jes Sorensen
parent bbb52f2b1d
commit cf52eff58a
3 changed files with 9 additions and 6 deletions

6
Grow.c
View File

@ -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 */

View File

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

View 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 */