From 75d7e04eb4662a814c26010d447eed8a862f5ec1 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Wed, 18 May 2022 13:35:21 +0200 Subject: dissect-image: Explicitly remove partitions when done with image When closing a loop device, the kernel will asynchronously remove the probed partitions. This can lead to race conditions where we try to reuse a partition device that still needs to be removed by the kernel. To avoid such issues, let's explicitly try to remove any partitions using BLKPG_DEL_PARTITION when we're done with an image. To make sure we don't try to remove partitions when we want them to remain (e.g. systemd-dissect --mount), we add dissected_image_relinquish() in a similar vein to loop_device_relinquish() and decrypted_image_relinquish(). --- src/sysext/sysext.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/sysext') diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index 364af195e0..002ebb09f8 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -584,6 +584,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) { return log_error_errno(r, "Failed to relinquish DM devices: %m"); } + dissected_image_relinquish(m); loop_device_relinquish(d); break; } -- cgit v1.2.1