return 1;
}
if (bmf.pathname[0]) {
- if (strcmp(s->bitmap_file,"none") == 0) {
+ if (str_is_none(s->bitmap_file) == true) {
if (ioctl(fd, SET_BITMAP_FILE, -1) != 0) {
pr_err("failed to remove bitmap %s\n",
bmf.pathname);
return 1;
}
if (array.state & (1 << MD_SB_BITMAP_PRESENT)) {
- if (strcmp(s->bitmap_file, "none")==0) {
+ if (str_is_none(s->bitmap_file) == true) {
array.state &= ~(1 << MD_SB_BITMAP_PRESENT);
if (md_set_array_info(fd, &array) != 0) {
if (array.state & (1 << MD_SB_CLUSTERED))
return 1;
}
- if (strcmp(s->bitmap_file, "none") == 0) {
+ if (str_is_none(s->bitmap_file) == true) {
pr_err("no bitmap found on %s\n", devname);
return 1;
}
dv = map_dev(disk.major, disk.minor, 1);
if (!dv)
continue;
- if (((disk.state & (1 << MD_DISK_WRITEMOSTLY)) == 0) &&
+ if ((disk.state & (1 << MD_DISK_WRITEMOSTLY)) &&
(strcmp(s->bitmap_file, "clustered") == 0)) {
pr_err("%s disks marked write-mostly are not supported with clustered bitmap\n",devname);
free(mdi);
char *subarray = NULL;
int ret = 0;
char container_dev[PATH_MAX];
- char buf[20];
+ char buf[SYSFS_MAX_BUF_SIZE];
if (s->consistency_policy != CONSISTENCY_POLICY_RESYNC &&
s->consistency_policy != CONSISTENCY_POLICY_PPL) {
}
if (s->consistency_policy == CONSISTENCY_POLICY_PPL) {
- if (sysfs_get_str(sra, NULL, "sync_action", buf, 20) <= 0) {
+ if (sysfs_get_str(sra, NULL, "sync_action", buf, sizeof(buf)) <= 0) {
ret = 1;
goto free_info;
} else if (strcmp(buf, "reshape\n") == 0) {
else {
struct mdinfo *sra = sysfs_read(-1, st->devnm, GET_VERSION);
int err;
- char buf[20];
+ char buf[SYSFS_MAX_BUF_SIZE];
if (!sra)
return -1;
/* Need to clear any 'read-auto' status */
- if (sysfs_get_str(sra, NULL, "array_state", buf, 20) > 0 &&
+ if (sysfs_get_str(sra, NULL, "array_state", buf, sizeof(buf)) > 0 &&
strncmp(buf, "read-auto", 9) == 0)
sysfs_set_str(sra, NULL, "array_state", "clean");
return unfreeze_container(st);
else {
struct mdinfo *sra = sysfs_read(-1, st->devnm, GET_VERSION);
- char buf[20];
+ char buf[SYSFS_MAX_BUF_SIZE];
if (sra &&
- sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 &&
+ sysfs_get_str(sra, NULL, "sync_action", buf, sizeof(buf)) > 0 &&
strcmp(buf, "frozen\n") == 0)
sysfs_set_str(sra, NULL, "sync_action", "idle");
sysfs_free(sra);
static void wait_reshape(struct mdinfo *sra)
{
int fd = sysfs_get_fd(sra, NULL, "sync_action");
- char action[20];
+ char action[SYSFS_MAX_BUF_SIZE];
if (fd < 0)
return;
- while (sysfs_fd_get_str(fd, action, 20) > 0 &&
+ while (sysfs_fd_get_str(fd, action, sizeof(action)) > 0 &&
strncmp(action, "reshape", 7) == 0)
sysfs_wait(fd, NULL);
close(fd);
* to close a race with the array_state going clean before the
* next write to raid_disks / stripe_cache_size
*/
- char safe[50];
+ char safe[SYSFS_MAX_BUF_SIZE];
int rc;
/* only 'raid_disks' and 'stripe_cache_size' trigger md_allow_write */
remaining = sd->next;
sysfs_set_str(sra, sd, "state", "faulty");
- sysfs_set_str(sra, sd, "slot", "none");
+ sysfs_set_str(sra, sd, "slot", STR_COMMON_NONE);
/* for external metadata disks should be removed in mdmon */
if (!st->ss->external)
sysfs_set_str(sra, sd, "state", "remove");
return NULL;
}
- if (re->after.data_disks == re->before.data_disks &&
- get_linux_version() < 2006032)
- return "in-place reshape is not safe before 2.6.32 - sorry.";
-
- if (re->after.data_disks < re->before.data_disks &&
- get_linux_version() < 2006030)
- return "reshape to fewer devices is not supported before 2.6.30 - sorry.";
-
re->backup_blocks = compute_backup_blocks(
info->new_chunk, info->array.chunk_size,
re->after.data_disks, re->before.data_disks);
return 1;
}
- if (s->raiddisks && s->raiddisks < array.raid_disks &&
- array.level > 1 && get_linux_version() < 2006032 &&
- !check_env("MDADM_FORCE_FEWER")) {
- pr_err("reducing the number of devices is not safe before Linux 2.6.32\n"
- " Please use a newer kernel\n");
- return 1;
- }
-
if (array.level > 1 && s->size > 1 &&
(unsigned long long) (array.chunk_size / 1024) > s->size) {
pr_err("component size must be larger than chunk size.\n");
if (!mdmon_running(st->container_devnm))
start_mdmon(st->container_devnm);
ping_monitor(container);
- if (mdmon_running(st->container_devnm) &&
- st->update_tail == NULL)
- st->update_tail = &st->updates;
+ if (mdmon_running(st->container_devnm) == false) {
+ pr_err("No mdmon found. Grow cannot continue.\n");
+ goto release;
+ }
}
if (s->size == MAX_SIZE)
/* got truncated to 32bit, write to
* component_size instead
*/
- if (sra)
- rv = sysfs_set_num(sra, NULL,
- "component_size", s->size);
- else
- rv = -1;
+ rv = sysfs_set_num(sra, NULL, "component_size", s->size);
} else {
rv = md_set_array_info(fd, &array);
* a backport has been arranged.
*/
if (sra == NULL ||
- sysfs_set_str(sra, NULL, "resync_start",
- "none") < 0)
+ sysfs_set_str(sra, NULL, "resync_start", STR_COMMON_NONE) < 0)
pr_err("--assume-clean not supported with --grow on this kernel\n");
}
md_get_array_info(fd, &array);
static int verify_reshape_position(struct mdinfo *info, int level)
{
int ret_val = 0;
- char buf[40];
+ char buf[SYSFS_MAX_BUF_SIZE];
int rv;
/* read sync_max, failure can mean raid0 array */
- rv = sysfs_get_str(info, NULL, "sync_max", buf, 40);
+ rv = sysfs_get_str(info, NULL, "sync_max", buf, sizeof(buf));
if (rv > 0) {
char *ep;
unsigned long long array_size;
int done;
struct mdinfo *sra = NULL;
- char buf[20];
+ char buf[SYSFS_MAX_BUF_SIZE];
/* when reshaping a RAID0, the component_size might be zero.
* So try to fix that up.
dprintf("Cannot get array information.\n");
goto release;
}
+ if (st->update_tail == NULL)
+ st->update_tail = &st->updates;
if (array.level == 0 && info->component_size == 0) {
get_dev_size(fd, NULL, &array_size);
info->component_size = array_size / array.raid_disks;
if (!forked)
if (continue_via_systemd(container ?: sra->sys_name,
- GROW_SERVICE)) {
+ GROW_SERVICE, NULL)) {
free(fdlist);
free(offsets);
sysfs_free(sra);
ping_monitor(container);
if (!forked && !freeze_reshape)
- if (continue_via_systemd(container, GROW_SERVICE))
+ if (continue_via_systemd(container, GROW_SERVICE, NULL))
return 0;
switch (forked ? 0 : fork()) {
unsigned long long array_size = (info->component_size
* reshape->before.data_disks);
int fd;
- char buf[20];
+ char buf[SYSFS_MAX_BUF_SIZE];
/* First, we unsuspend any region that is now known to be safe.
* If suspend_point is on the 'wrong' side of reshape_progress, then
/* Check that sync_action is still 'reshape' to avoid
* waiting forever on a dead array
*/
- char action[20];
- if (sysfs_get_str(info, NULL, "sync_action", action, 20) <= 0 ||
+ char action[SYSFS_MAX_BUF_SIZE];
+ if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) <= 0 ||
strncmp(action, "reshape", 7) != 0)
break;
/* Some kernels reset 'sync_completed' to zero
*/
if (completed == 0) {
unsigned long long reshapep;
- char action[20];
- if (sysfs_get_str(info, NULL, "sync_action", action, 20) > 0 &&
+ char action[SYSFS_MAX_BUF_SIZE];
+ if (sysfs_get_str(info, NULL, "sync_action", action, sizeof(action)) > 0 &&
strncmp(action, "idle", 4) == 0 &&
sysfs_get_ll(info, NULL,
"reshape_position", &reshapep) == 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 ||
+ str_is_none(buf) == false) {
/* The abort might only be temporary. Wait up to 10
* seconds for fd to contain a valid number again.
*/
if (sd->disk.state & (1<<MD_DISK_FAULTY))
continue;
if (sd->disk.state & (1<<MD_DISK_SYNC)) {
- char sbuf[100];
+ char sbuf[SYSFS_MAX_BUF_SIZE];
if (sysfs_get_str(sra, sd, "state",
sbuf, sizeof(sbuf)) < 0 ||
lseek64(afd, __le64_to_cpu(bsb2.arraystart)*512, 0);
if ((unsigned long long)read(afd, abuf, len) != len)
fail("read first from array failed");
- if (memcmp(bbuf, abuf, len) != 0) {
-#if 0
- int i;
- printf("offset=%llu len=%llu\n",
- (unsigned long long)__le64_to_cpu(bsb2.arraystart)*512, len);
- for (i=0; i<len; i++)
- if (bbuf[i] != abuf[i]) {
- printf("first diff byte %d\n", i);
- break;
- }
-#endif
+ if (memcmp(bbuf, abuf, len) != 0)
fail("data1 compare failed");
- }
}
if (bsb2.length2) {
unsigned long long len = __le64_to_cpu(bsb2.length2)*512;
start_mdmon(container);
ping_monitor(container);
- if (mdmon_running(container))
- st->update_tail = &st->updates;
- else {
+ if (mdmon_running(container) == false) {
pr_err("No mdmon found. Grow cannot continue.\n");
ret_val = 1;
goto Grow_continue_command_exit;