From ea16d7f48e23fef6f5db9a95fe9a679a7027048a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 14 Sep 2022 11:48:16 +0900 Subject: [PATCH] dissect-image: lazily deactivate decrypted DM volumes The DM block device may be still used by other processes. --- src/shared/dissect-image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 5eaff64f87f..5e4883a7a7c 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -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); }