Skip to content

Commit

Permalink
cryptsetup: try to detach the device multiple times before giving up
Browse files Browse the repository at this point in the history
Terrible hack for RHEL8. We are missing the blockdev@.target, so we
can't correctly express some dependencies. That means when
systemd-cryptsetup detach can fail, because for example a filesystem is
still mounted on top of the device. This can cause shutdown to hang
forever. See https://issues.redhat.com/browse/RHEL-6210
So as a workaround, let's try to detach the device multiple times
before giving up.

Proper fix is
systemd/systemd@44b0d1f

RHEL-only
Resolves: RHEL-6210
  • Loading branch information
lnykryn committed Feb 14, 2024
1 parent 8bf7a6f commit cdf70e6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cryptsetup/cryptsetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,18 @@ int main(int argc, char *argv[]) {

crypt_set_log_callback(cd, cryptsetup_log_glue, NULL);

r = crypt_deactivate(cd, argv[2]);
/* Terrible hack for RHEL8. We are missing the blockdev@.target, so we can't
correctly express some dependencies. That means when systemd-cryptsetup detach
can fail, because for example a filesystem is still mounted on top of the device.
This can cause shutdown to hang forever. See https://issues.redhat.com/browse/RHEL-6210
So as a workaround, let's try to detach the device multiple times before giving up. */
for (int i = 0; i < 10; i++) {
r = crypt_deactivate(cd, argv[2]);
if (r == 0)
break;
sleep(1);
}

if (r < 0) {
log_error_errno(r, "Failed to deactivate: %m");
goto finish;
Expand Down

0 comments on commit cdf70e6

Please sign in to comment.