From: Jacek Kryszyn Date: Tue, 19 Mar 2024 11:27:06 +0000 (+0100) Subject: Dynamic Partitions - fix remove partitions after cloning X-Git-Tag: accepted/tizen/unified/20240430.020633~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fa41820140296db0b227b7933db8b68cd51df71;p=platform%2Fcore%2Fsystem%2Fupgrade.git Dynamic Partitions - fix remove partitions after cloning Dynamic partitions from the next slot are removed after cloning using dmsetup remove. Sometimes this operation fails due to devices being busy. This fix changes the way that partitions are removed. dmsetup remove is repeated five times and --retry flag is used which makes dmsetup try to remove the device for a couple of seconds until it will fail. Change-Id: I2b13055981ed9d4ed5f6b69b516b932c96da020f --- diff --git a/scripts/upgrade-support/upgrade-common.inc b/scripts/upgrade-support/upgrade-common.inc index 34e5e0d..66ccd5e 100644 --- a/scripts/upgrade-support/upgrade-common.inc +++ b/scripts/upgrade-support/upgrade-common.inc @@ -115,7 +115,7 @@ verify_img() { check_ab_partition_scheme() { CURRENT_AB="$(/bin/sed -E 's|.*(partition_ab=)([a-b]).*|\2|' /proc/cmdline)" if [ "$CURRENT_AB" != "a" ] && [ "$CURRENT_AB" != "b" ]; then - flog "[Info] There is no A/B partition scheme" + flog "[Error] There is no A/B partition scheme" exit_error fi NEXT_AB="b" @@ -124,17 +124,30 @@ check_ab_partition_scheme() { fi } +unmap_dp () { + local part=$1 + + for i in 1 .. 5; do + if dmsetup remove --retry "${part}"; then + return 0 + fi + done + + flog "[Error] It was not possible to remove /dev/mapper/$part" + exit_error +} + unmap_next_dynamic_partitions () { if [ -n "$SUPERFS" ]; then local MAPPED_DEVICES="" MAPPED_DEVICES=$(dmsetup ls) if [[ $MAPPED_DEVICES = *"rootfs_${NEXT_AB}"* ]]; then - dmsetup remove rootfs_"${NEXT_AB}" + unmap_dp "rootfs_${NEXT_AB}" fi if [[ $MAPPED_DEVICES = *"hal_${NEXT_AB}"* ]]; then - dmsetup remove hal_"${NEXT_AB}" + unmap_dp "hal_${NEXT_AB}" fi fi }