Correct checking if file descriptors are valid
In some cases file descriptors equal to 0 are treated as invalid. Fix it. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
parent
b2e4f08414
commit
b71de056ce
|
@ -569,8 +569,7 @@ static int select_devices(struct mddev_dev *devlist,
|
||||||
if (dfd < 0 ||
|
if (dfd < 0 ||
|
||||||
st->ss->load_super(st, dfd, NULL))
|
st->ss->load_super(st, dfd, NULL))
|
||||||
tmpdev->used = 2;
|
tmpdev->used = 2;
|
||||||
if (dfd > 0)
|
close_fd(&dfd);
|
||||||
close(dfd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
Grow.c
5
Grow.c
|
@ -2334,10 +2334,7 @@ size_change_error:
|
||||||
* number of devices (On-Line Capacity Expansion) must be
|
* number of devices (On-Line Capacity Expansion) must be
|
||||||
* performed at the level of the container
|
* performed at the level of the container
|
||||||
*/
|
*/
|
||||||
if (fd > 0) {
|
close_fd(&fd);
|
||||||
close(fd);
|
|
||||||
fd = -1;
|
|
||||||
}
|
|
||||||
rv = reshape_container(container, devname, -1, st, &info,
|
rv = reshape_container(container, devname, -1, st, &info,
|
||||||
c->force, c->backup_file, c->verbose,
|
c->force, c->backup_file, c->verbose,
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
|
|
|
@ -1702,8 +1702,8 @@ int IncrementalRemove(char *devname, char *id_path, int verbose)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
mdfd = open_dev_excl(ent->devnm);
|
mdfd = open_dev_excl(ent->devnm);
|
||||||
if (mdfd > 0) {
|
if (is_fd_valid(mdfd)) {
|
||||||
close(mdfd);
|
close_fd(&mdfd);
|
||||||
if (sysfs_get_str(&mdi, NULL, "array_state",
|
if (sysfs_get_str(&mdi, NULL, "array_state",
|
||||||
buf, sizeof(buf)) > 0) {
|
buf, sizeof(buf)) > 0) {
|
||||||
if (strncmp(buf, "active", 6) == 0 ||
|
if (strncmp(buf, "active", 6) == 0 ||
|
||||||
|
|
3
mdadm.c
3
mdadm.c
|
@ -1770,8 +1770,7 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (locked)
|
if (locked)
|
||||||
cluster_release_dlmlock();
|
cluster_release_dlmlock();
|
||||||
if (mdfd > 0)
|
close_fd(&mdfd);
|
||||||
close(mdfd);
|
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4914,7 +4914,7 @@ static int raid10_degraded(struct mdinfo *info)
|
||||||
pr_err("BUG: invalid raid disk\n");
|
pr_err("BUG: invalid raid disk\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (d->state_fd > 0)
|
if (is_fd_valid(d->state_fd))
|
||||||
found[i]++;
|
found[i]++;
|
||||||
}
|
}
|
||||||
ret = 2;
|
ret = 2;
|
||||||
|
|
Loading…
Reference in New Issue