/* wait for reshape to pass the critical region */
while(1) {
unsigned long long comp;
+ char a[20];
+
if (sysfs_get_ll(sra, NULL, "sync_completed", &comp)<0) {
sleep(5);
break;
}
if (comp >= nstripe)
break;
+
+ /* perhaps the entire reshape has completed */
+ if (comp == 0 &&
+ sysfs_get_str(sra, NULL, "sync_action", a, sizeof(a)) == 0 &&
+ strncmp(a, "idle", 4) == 0)
+ break;
sleep(1);
}
extern int sysfs_uevent(struct mdinfo *sra, char *event);
extern int sysfs_get_ll(struct mdinfo *sra, struct mdinfo *dev,
char *name, unsigned long long *val);
+extern int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
+ char *name, char *buf, int buf_len);
extern int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms);
extern int sysfs_set_array(struct mdinfo *info, int vers);
extern int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd);
return 0;
}
+int sysfs_get_str(struct mdinfo *sra, struct mdinfo *dev,
+ char *name, char *buf, int buf_len)
+{
+ char fname[50];
+ int n;
+ int fd;
+
+ sprintf(fname, "/sys/block/%s/md/%s/%s",
+ sra->sys_name, dev?dev->sys_name:"", name);
+ fd = open(fname, O_RDONLY);
+ if (fd < 0)
+ return -1;
+ n = read(fd, buf, buf_len);
+ close(fd);
+ if (n <= 0)
+ return -1;
+ buf[n] = 0;
+ return 0;
+}
+
int sysfs_set_safemode(struct mdinfo *sra, unsigned long ms)
{
unsigned long sec;