diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-12-19 17:17:35 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-12-19 23:27:47 +0100 |
commit | 052eaf5c9302ac64f1de965babfaf9c120740f73 (patch) | |
tree | 98134869033fb615b95d8e74265d5410d40b9b19 | |
parent | Merge pull request #11212 from keszybz/mount-storm-revert (diff) | |
download | systemd-052eaf5c9302ac64f1de965babfaf9c120740f73.tar.gz systemd-052eaf5c9302ac64f1de965babfaf9c120740f73.tar.bz2 systemd-052eaf5c9302ac64f1de965babfaf9c120740f73.zip |
gpt-auto-generator: don't wait for udev
Generators run in a context where waiting for udev is not an option,
simply because it's not running there yet. Hence, let's not wait for it
in this case.
This is generally OK to do as we are operating on the root disk only
here, which should have been probed already by the time we come this
far.
An alternative fix might be to remove the udev dependency from image
dissection again in the long run (and thus replace reliance on
/dev/block/x:y somehow with something else).
Fixes: #11205
-rw-r--r-- | src/gpt-auto-generator/gpt-auto-generator.c | 2 | ||||
-rw-r--r-- | src/shared/dissect-image.c | 25 | ||||
-rw-r--r-- | src/shared/dissect-image.h | 1 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index a6d7bcc75..e9f3d7dab 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -518,7 +518,7 @@ static int enumerate_partitions(dev_t devnum) { if (r <= 0) return r; - r = dissect_image(fd, NULL, 0, DISSECT_IMAGE_GPT_ONLY, &m); + r = dissect_image(fd, NULL, 0, DISSECT_IMAGE_GPT_ONLY|DISSECT_IMAGE_NO_UDEV, &m); if (r == -ENOPKG) { log_debug_errno(r, "No suitable partition table found, ignoring."); return 0; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 4c2e41c8b..551a67b6c 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -145,6 +145,7 @@ static int wait_for_partitions_to_appear( int fd, sd_device *d, unsigned num_partitions, + DissectImageFlags flags, sd_device_enumerator **ret_enumerator) { _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; @@ -166,9 +167,11 @@ static int wait_for_partitions_to_appear( if (device_is_mmc_special_partition(q)) continue; - r = device_wait_for_initialization(q, "block", NULL); - if (r < 0) - return r; + if (!FLAGS_SET(flags, DISSECT_IMAGE_NO_UDEV)) { + r = device_wait_for_initialization(q, "block", NULL); + if (r < 0) + return r; + } n++; } @@ -223,18 +226,22 @@ static int loop_wait_for_partitions_to_appear( int fd, sd_device *d, unsigned num_partitions, + DissectImageFlags flags, sd_device_enumerator **ret_enumerator) { _cleanup_(sd_device_unrefp) sd_device *device = NULL; int r; log_debug("Waiting for device (parent + %d partitions) to appear...", num_partitions); - r = device_wait_for_initialization(d, "block", &device); - if (r < 0) - return r; + if (!FLAGS_SET(flags, DISSECT_IMAGE_NO_UDEV)) { + r = device_wait_for_initialization(d, "block", &device); + if (r < 0) + return r; + } else + device = sd_device_ref(d); for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) { - r = wait_for_partitions_to_appear(fd, device, num_partitions, ret_enumerator); + r = wait_for_partitions_to_appear(fd, device, num_partitions, flags, ret_enumerator); if (r != -EAGAIN) return r; } @@ -369,7 +376,7 @@ int dissect_image( m->encrypted = streq_ptr(fstype, "crypto_LUKS"); - r = loop_wait_for_partitions_to_appear(fd, d, 0, &e); + r = loop_wait_for_partitions_to_appear(fd, d, 0, flags, &e); if (r < 0) return r; @@ -394,7 +401,7 @@ int dissect_image( if (!pl) return -errno ?: -ENOMEM; - r = loop_wait_for_partitions_to_appear(fd, d, blkid_partlist_numof_partitions(pl), &e); + r = loop_wait_for_partitions_to_appear(fd, d, blkid_partlist_numof_partitions(pl), flags, &e); if (r < 0) return r; diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h index 0033921fa..f50b40ea1 100644 --- a/src/shared/dissect-image.h +++ b/src/shared/dissect-image.h @@ -57,6 +57,7 @@ typedef enum DissectImageFlags { DISSECT_IMAGE_MOUNT_ROOT_ONLY = 1 << 6, /* Mount only the root partition */ DISSECT_IMAGE_MOUNT_NON_ROOT_ONLY = 1 << 7, /* Mount only non-root partitions */ DISSECT_IMAGE_VALIDATE_OS = 1 << 8, /* Refuse mounting images that aren't identifyable as OS images */ + DISSECT_IMAGE_NO_UDEV = 1 << 9, /* Don't wait for udev initializing things */ } DissectImageFlags; struct DissectedImage { |