*/
struct mdinfo info;
- struct stat stb;
+ dev_t rdev;
int nfd, fd2;
int d, nd;
struct supertype *st = NULL;
free(st);
return 1;
}
- fstat(nfd, &stb);
- if ((stb.st_mode & S_IFMT) != S_IFBLK) {
- pr_err("%s is not a block device!\n", newdev);
+ if (!fstat_is_blkdev(nfd, newdev, &rdev)) {
close(nfd);
free(st);
return 1;
*/
info.disk.number = d;
- info.disk.major = major(stb.st_rdev);
- info.disk.minor = minor(stb.st_rdev);
+ info.disk.major = major(rdev);
+ info.disk.minor = minor(rdev);
info.disk.raid_disk = d;
info.disk.state = (1 << MD_DISK_SYNC) | (1 << MD_DISK_ACTIVE);
st->ss->update_super(st, &info, "linear-grow-new", newdev,
char buf[20];
if (sra &&
- sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0
- && strcmp(buf, "frozen\n") == 0)
+ sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
+ strcmp(buf, "frozen\n") == 0)
sysfs_set_str(sra, NULL, "sync_action", "idle");
sysfs_free(sra);
}
if (disk.major == 0 && disk.minor == 0)
continue;
found++;
- if ((disk.state & (1 << MD_DISK_ACTIVE))
- && disk.raid_disk < data_disks)
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+ disk.raid_disk < data_disks)
/* keep this */
continue;
ioctl(fd, HOT_REMOVE_DISK,
if (disk.major == 0 && disk.minor == 0)
continue;
found++;
- if ((disk.state & (1 << MD_DISK_ACTIVE))
- && disk.raid_disk < data_disks)
+ if ((disk.state & (1 << MD_DISK_ACTIVE)) &&
+ disk.raid_disk < data_disks)
/* keep this */
continue;
ioctl(fd, SET_DISK_FAULTY,
}
if (!st->ss->external &&
- !(reshape.before.data_disks != reshape.after.data_disks
- && info->custom_array_size) &&
- info->new_level == reshape.level &&
+ !(reshape.before.data_disks != reshape.after.data_disks &&
+ info->custom_array_size) && info->new_level == reshape.level &&
!forked) {
/* no need to wait for the reshape to finish as
* there is nothing more to do.
* a backup.
*/
if (advancing) {
- if ((need_backup > info->reshape_progress
- || info->array.major_version < 0) &&
+ if ((need_backup > info->reshape_progress ||
+ info->array.major_version < 0) &&
*suspend_point < info->reshape_progress + target) {
if (need_backup < *suspend_point + 2 * target)
*suspend_point = need_backup;
* before setting 'sync_action' to 'idle'.
* So we need these extra tests.
*/
- if (completed == 0 && advancing
- && strncmp(action, "idle", 4) == 0
- && info->reshape_progress > 0)
+ if (completed == 0 && advancing &&
+ strncmp(action, "idle", 4) == 0 &&
+ info->reshape_progress > 0)
break;
- if (completed == 0 && !advancing
- && strncmp(action, "idle", 4) == 0
- && info->reshape_progress < (info->component_size
- * reshape->after.data_disks))
+ if (completed == 0 && !advancing &&
+ strncmp(action, "idle", 4) == 0 &&
+ info->reshape_progress < (info->component_size
+ * reshape->after.data_disks))
break;
sysfs_wait(fd, NULL);
if (sysfs_fd_get_ll(fd, &completed) < 0)
* it was just a device failure that leaves us degraded but
* functioning.
*/
- if (sysfs_get_str(info, NULL, "reshape_position", buf, sizeof(buf)) < 0
- || strncmp(buf, "none", 4) != 0) {
+ if (sysfs_get_str(info, NULL, "reshape_position", buf,
+ sizeof(buf)) < 0 ||
+ strncmp(buf, "none", 4) != 0) {
/* The abort might only be temporary. Wait up to 10
* seconds for fd to contain a valid number again.
*/
/* Maybe racing with array shutdown - check state */
if (fd >= 0)
close(fd);
- if (sysfs_get_str(info, NULL, "array_state", buf, sizeof(buf)) < 0
- || strncmp(buf, "inactive", 8) == 0
- || strncmp(buf, "clear",5) == 0)
+ if (sysfs_get_str(info, NULL, "array_state", buf,
+ sizeof(buf)) < 0 ||
+ strncmp(buf, "inactive", 8) == 0 ||
+ strncmp(buf, "clear",5) == 0)
return -2; /* abort */
return -1; /* complete */
}
/* reshape_progress is increasing */
if ((__le64_to_cpu(bsb.arraystart)
+ __le64_to_cpu(bsb.length)
- < info->reshape_progress)
- &&
+ < info->reshape_progress) &&
(__le64_to_cpu(bsb.arraystart2)
+ __le64_to_cpu(bsb.length2)
< info->reshape_progress))