Skip to content

Commit

Permalink
Use 'dmsetup remove --retry'
Browse files Browse the repository at this point in the history
destroy-snapshot sometimes fails with "Device or resource busy" error,
retry a few times in case of udev or other process still accessing the
device.

Suggested-by: @rustybird
Fixes QubesOS/qubes-issues#9283
  • Loading branch information
marmarek committed Jun 4, 2024
1 parent fe51d74 commit aa86d39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions linux/system-config/destroy-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ case $node in
if is_unused "$snap"; then
# unused snapshot - remove it
deps+=" $(deps "$snap")"
dmsetup -- remove "$snap"
dmsetup remove --retry -- "$snap"
else
has_snapshot=true
fi
Expand All @@ -55,7 +55,7 @@ case $node in
esac

if [[ "$has_snapshot" = 'false' ]] && [[ -e "$node" ]]; then
dmsetup -- remove "$node"
dmsetup remove --retry -- "$node"
fi

# try to free unused devices
Expand All @@ -66,7 +66,7 @@ for dev in $deps; do
losetup -d "$dev" 2> /dev/null || true
;;
/dev/dm-*)
dmsetup remove "$dev" 2> /dev/null || true
dmsetup remove --retry -- "$dev" 2> /dev/null || true
;;
esac
fi
Expand Down

0 comments on commit aa86d39

Please sign in to comment.