summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Grzonka <mateusz.grzonka@intel.com>2021-11-24 11:45:30 +0100
committerJes Sorensen <jsorensen@fb.com>2021-11-24 07:06:12 -0500
commitb2e4f084142cfb01b69aca65e4c1488a471f637a (patch)
tree1fd0158d28a5f66464ecea649cb13bb248cb71fb
parent195d1d7658c4485e4c63e3758464e413d87043d2 (diff)
downloadmdadm-b2e4f084142cfb01b69aca65e4c1488a471f637a.tar.gz
Incremental: Close unclosed mdfd in IncrementalScan()
In addition to closing mdfd, propagate helpers to manage file descriptors across IncrementalScan(). Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r--Incremental.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Incremental.c b/Incremental.c
index cd9cc0f..9cdd31f 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -1346,7 +1346,7 @@ restart:
}
mdfd = open_dev(me->devnm);
- if (mdfd < 0)
+ if (!is_fd_valid(mdfd))
continue;
if (!isdigit(me->metadata[0])) {
/* must be a container */
@@ -1356,7 +1356,7 @@ restart:
if (st && st->ss->load_container)
ret = st->ss->load_container(st, mdfd, NULL);
- close(mdfd);
+ close_fd(&mdfd);
if (!ret && st && st->ss->container_content) {
if (map_lock(&map))
pr_err("failed to get exclusive lock on mapfile\n");
@@ -1368,7 +1368,7 @@ restart:
continue;
}
if (md_array_active(mdfd)) {
- close(mdfd);
+ close_fd(&mdfd);
continue;
}
/* Ok, we can try this one. Maybe it needs a bitmap */
@@ -1385,9 +1385,9 @@ restart:
int bmfd;
bmfd = open(mddev->bitmap_file, O_RDWR);
- if (bmfd >= 0) {
+ if (is_fd_valid(bmfd)) {
added = ioctl(mdfd, SET_BITMAP_FILE, bmfd);
- close(bmfd);
+ close_fd(&bmfd);
}
if (c->verbose >= 0) {
if (added == 0)
@@ -1416,6 +1416,7 @@ restart:
}
sysfs_free(sra);
}
+ close_fd(&mdfd);
}
map_free(mapl);
return rv;