Skip to content

Commit 47b01ab

Browse files
sarroutbisergio-correia
authored andcommitted
Improve boot performance by removing key check
Function clevis_luks_check_valid_key_or_keyfile is spending most of the boot time dedicated to unlock devices. However, this function is always returning true for an already encrypted device (normal call execution). Parameterizing this function to avoid this check allows decreasing boot time about 2 seconds per luks device Signed-off-by: Sergio Arroutbi <sarroutb@redhat.com>
1 parent 59ee73c commit 47b01ab

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/luks/clevis-luks-common-functions.in

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ clevis_luks_check_valid_key_or_keyfile() {
328328
clevis_luks_unlock_device_by_slot() {
329329
local DEV="${1}"
330330
local SLT="${2}"
331+
local SKIP_CHECK="${3}"
331332

332333
[ -z "${DEV}" ] && return 1
333334
[ -z "${SLT}" ] && return 1
@@ -342,15 +343,18 @@ clevis_luks_unlock_device_by_slot() {
342343
|| [ -z "${passphrase}" ]; then
343344
return 1
344345
fi
345-
346-
clevis_luks_check_valid_key_or_keyfile "${DEV}" "${passphrase}" || return 1
346+
if [ -z "${SKIP_CHECK}" ]; then
347+
clevis_luks_check_valid_key_or_keyfile "${DEV}" "${passphrase}" || return 1
348+
fi
347349
printf '%s' "${passphrase}"
348350
}
349351

350352
# clevis_luks_unlock_device() does the unlock of the device passed as
351353
# parameter and returns the decoded passphrase.
352354
clevis_luks_unlock_device() {
353355
local DEV="${1}"
356+
local SKIP_CHECK="YES"
357+
354358
[ -z "${DEV}" ] && return 1
355359

356360
local used_slots
@@ -361,7 +365,7 @@ clevis_luks_unlock_device() {
361365

362366
local slt pt
363367
for slt in ${used_slots}; do
364-
if ! pt=$(clevis_luks_unlock_device_by_slot "${DEV}" "${slt}") \
368+
if ! pt=$(clevis_luks_unlock_device_by_slot "${DEV}" "${slt}" "${SKIP_CHECK}") \
365369
|| [ -z "${pt}" ]; then
366370
continue
367371
fi

0 commit comments

Comments
 (0)