]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: lazily deactivate decrypted DM volumes 24667/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Sep 2022 02:48:16 +0000 (11:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 17 Sep 2022 22:27:22 +0000 (07:27 +0900)
The DM block device may be still used by other processes.

src/shared/dissect-image.c

index 5eaff64f87f30ef4cd2f80afadc2f5e77b53cb56..5e4883a7a7c6028bb933b4a3b1f0329f83dc746d 100644 (file)
@@ -1567,7 +1567,8 @@ DecryptedImage* decrypted_image_unref(DecryptedImage* d) {
                 DecryptedPartition *p = d->decrypted + i;
 
                 if (p->device && p->name && !p->relinquished) {
-                        r = sym_crypt_deactivate_by_name(p->device, p->name, 0);
+                        /* Let's deactivate lazily, as the dm volume may be already/still used by other processes. */
+                        r = sym_crypt_deactivate_by_name(p->device, p->name, CRYPT_DEACTIVATE_DEFERRED);
                         if (r < 0)
                                 log_debug_errno(r, "Failed to deactivate encrypted partition %s", p->name);
                 }