]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2scrub: reorder exit status check after calling lvremove maint master next
authorSamuel Smith <satlug@net153.net>
Sat, 5 Jul 2025 03:38:21 +0000 (22:38 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 9 Jul 2025 16:43:09 +0000 (12:43 -0400)
Checking for snapshot device existence resets the status code in $?.
Reording the conditions will allow the retry loop to work properly.

Signed-off-by: Samuel Smith <satlug@net153.net>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20250705033821.3695205-1-satlug@net153.net
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
scrub/e2scrub.in

index 043bc12b391c752b297459f7f50bbbb3e58770a7..6f9b5ce2a83877b2ddc52b8d0a86064911fa8f93 100644 (file)
@@ -182,7 +182,7 @@ snap_dev="/dev/${LVM2_VG_NAME}/${snap}"
 teardown() {
        # Remove and wait for removal to succeed.
        ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}"
-       while [ -e "${snap_dev}" ] && [ "$?" -eq "5" ]; do
+       while [ "$?" -eq "5" ] && [ -e "${snap_dev}" ]; do
                sleep 0.5
                ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}"
        done
@@ -210,7 +210,7 @@ setup() {
        # Try to remove snapshot for 30s, bail out if we can't remove it.
        lvremove_deadline="$(( $(date "+%s") + 30))"
        ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}" 2>/dev/null
-       while [ -e "${snap_dev}" ] && [ "$?" -eq "5" ] &&
+       while [ "$?" -eq "5" ] && [ -e "${snap_dev}" ] &&
              [ "$(date "+%s")" -lt "${lvremove_deadline}" ]; do
                sleep 0.5
                ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}"