diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-13 14:35:15 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-12-17 13:50:57 +0100 |
commit | b887c8b8a836963c2949ae6a11b77430886d0b77 (patch) | |
tree | fad28eb8e069d3d4c817997169249e6c30936ebb /src | |
parent | dissect-image: split out a chunk of dissect_image() out (diff) | |
download | systemd-b887c8b8a836963c2949ae6a11b77430886d0b77.tar.gz systemd-b887c8b8a836963c2949ae6a11b77430886d0b77.tar.bz2 systemd-b887c8b8a836963c2949ae6a11b77430886d0b77.zip |
dissect-image: wait for the root to appear
dissect-image would wait for the root device and paritions to appear. But if we
had an image with no partitions, we'd not wait at all. If the kernel or udev
were slow in creating device nodes or symlinks, subsequent mount attempt might
fail if nspawn won the race.
Calling wait_for_partitions_to_appear() in case of no partitions means that we
verify that the kernel agrees that there are no partitions. We verify that the
kernel sees the same number of partitions as blkid, so let's that also in this
case.
This makes the failure in #10526 much less likely, but doesn't eliminate it
completely. Stay tuned.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/dissect-image.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 0147c45d8..0e2fb9afb 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -221,6 +221,8 @@ static int loop_wait_for_partitions_to_appear( sd_device_enumerator **ret_enumerator) { int r; + log_debug("Waiting for device (parent + %d partitions) to appear...", num_partitions); + for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) { r = wait_for_partitions_to_appear(fd, d, num_partitions, ret_enumerator); if (r != -EAGAIN) @@ -320,6 +322,10 @@ int dissect_image( if (!m) return -ENOMEM; + r = sd_device_new_from_devnum(&d, 'b', st.st_rdev); + if (r < 0) + return r; + if (!(flags & DISSECT_IMAGE_GPT_ONLY) && (flags & DISSECT_IMAGE_REQUIRE_ROOT)) { const char *usage = NULL; @@ -353,6 +359,10 @@ int dissect_image( m->encrypted = streq_ptr(fstype, "crypto_LUKS"); + r = loop_wait_for_partitions_to_appear(fd, d, 0, &e); + if (r < 0) + return r; + *ret = TAKE_PTR(m); return 0; @@ -374,10 +384,6 @@ int dissect_image( if (!pl) return -errno ?: -ENOMEM; - r = sd_device_new_from_devnum(&d, 'b', st.st_rdev); - if (r < 0) - return r; - r = loop_wait_for_partitions_to_appear(fd, d, blkid_partlist_numof_partitions(pl), &e); if (r < 0) return r; |