Blame SOURCES/kvm-iotests-Repairing-error-during-snapshot-deletion.patch

357786
From 4ffeaaff9109fbdf63bca8c0f944d6ebc46c9ffd Mon Sep 17 00:00:00 2001
357786
From: Max Reitz <mreitz@redhat.com>
357786
Date: Mon, 18 Jun 2018 17:16:55 +0200
357786
Subject: [PATCH 46/54] iotests: Repairing error during snapshot deletion
357786
357786
RH-Author: Max Reitz <mreitz@redhat.com>
357786
Message-id: <20180618171655.25987-3-mreitz@redhat.com>
357786
Patchwork-id: 80784
357786
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/2] iotests: Repairing error during snapshot deletion
357786
Bugzilla: 1527085
357786
RH-Acked-by: John Snow <jsnow@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
357786
This adds a test for an I/O error during snapshot deletion, and maybe
357786
more importantly, for how to repair the resulting image.  If the
357786
snapshot has been deleted before the error occurs, the only negative
357786
result will be leaked clusters -- and those should be repairable with
357786
qemu-img check -r leaks.
357786
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
Reviewed-by: Eric Blake <eblake@redhat.com>
357786
Message-id: 20180509200059.31125-3-mreitz@redhat.com
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
(cherry picked from commit b41ad73a3bb972eb43cf52d28669f67ea3fe1762)
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 tests/qemu-iotests/217     | 90 ++++++++++++++++++++++++++++++++++++++++++++++
357786
 tests/qemu-iotests/217.out | 42 ++++++++++++++++++++++
357786
 tests/qemu-iotests/group   |  1 +
357786
 3 files changed, 133 insertions(+)
357786
 create mode 100755 tests/qemu-iotests/217
357786
 create mode 100644 tests/qemu-iotests/217.out
357786
357786
diff --git a/tests/qemu-iotests/217 b/tests/qemu-iotests/217
357786
new file mode 100755
357786
index 0000000..d3ab5d7
357786
--- /dev/null
357786
+++ b/tests/qemu-iotests/217
357786
@@ -0,0 +1,90 @@
357786
+#!/bin/bash
357786
+#
357786
+# I/O errors when working with internal qcow2 snapshots, and repairing
357786
+# the result
357786
+#
357786
+# Copyright (C) 2018 Red Hat, Inc.
357786
+#
357786
+# This program is free software; you can redistribute it and/or modify
357786
+# it under the terms of the GNU General Public License as published by
357786
+# the Free Software Foundation; either version 2 of the License, or
357786
+# (at your option) any later version.
357786
+#
357786
+# This program is distributed in the hope that it will be useful,
357786
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
357786
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
357786
+# GNU General Public License for more details.
357786
+#
357786
+# You should have received a copy of the GNU General Public License
357786
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
357786
+
357786
+seq=$(basename $0)
357786
+echo "QA output created by $seq"
357786
+
357786
+status=1	# failure is the default!
357786
+
357786
+_cleanup()
357786
+{
357786
+    _cleanup_test_img
357786
+    rm -f "$TEST_DIR/blkdebug.conf"
357786
+}
357786
+trap "_cleanup; exit \$status" 0 1 2 3 15
357786
+
357786
+# get standard environment, filters and checks
357786
+. ./common.rc
357786
+. ./common.filter
357786
+
357786
+# This test is specific to qcow2
357786
+_supported_fmt qcow2
357786
+_supported_proto file
357786
+_supported_os Linux
357786
+
357786
+# This test needs clusters with at least a refcount of 2 so that
357786
+# OFLAG_COPIED is not set.  refcount_bits=1 is therefore unsupported.
357786
+_unsupported_imgopts 'refcount_bits=1[^0-9]'
357786
+
357786
+echo
357786
+echo '=== Simulating an I/O error during snapshot deletion ==='
357786
+echo
357786
+
357786
+_make_test_img 64M
357786
+$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
357786
+
357786
+# Create the snapshot
357786
+$QEMU_IMG snapshot -c foo "$TEST_IMG"
357786
+
357786
+# Verify the snapshot is there
357786
+echo
357786
+_img_info | grep 'Snapshot list'
357786
+echo '(Snapshot filtered)'
357786
+echo
357786
+
357786
+# Try to delete the snapshot (with an error happening when freeing the
357786
+# then leaked clusters)
357786
+cat > "$TEST_DIR/blkdebug.conf" <
357786
+[inject-error]
357786
+event = "cluster_free"
357786
+errno = "5"
357786
+EOF
357786
+$QEMU_IMG snapshot -d foo "blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
357786
+
357786
+# Verify the snapshot is gone
357786
+echo
357786
+_img_info | grep 'Snapshot list'
357786
+
357786
+# Should only show leaks
357786
+echo '--- Checking test image ---'
357786
+_check_test_img
357786
+
357786
+echo
357786
+
357786
+# As there are only leaks, this should be able to fully repair the
357786
+# image
357786
+echo '--- Repairing test image ---'
357786
+_check_test_img -r leaks
357786
+
357786
+
357786
+# success, all done
357786
+echo '*** done'
357786
+rm -f $seq.full
357786
+status=0
357786
diff --git a/tests/qemu-iotests/217.out b/tests/qemu-iotests/217.out
357786
new file mode 100644
357786
index 0000000..e3fc40a
357786
--- /dev/null
357786
+++ b/tests/qemu-iotests/217.out
357786
@@ -0,0 +1,42 @@
357786
+QA output created by 217
357786
+
357786
+=== Simulating an I/O error during snapshot deletion ===
357786
+
357786
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
357786
+wrote 65536/65536 bytes at offset 0
357786
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
357786
+
357786
+Snapshot list:
357786
+(Snapshot filtered)
357786
+
357786
+qcow2_free_clusters failed: Input/output error
357786
+qemu-img: Could not delete snapshot 'foo': Failed to free the cluster and L1 table: Input/output error
357786
+
357786
+--- Checking test image ---
357786
+Leaked cluster 4 refcount=2 reference=1
357786
+Leaked cluster 5 refcount=2 reference=1
357786
+Leaked cluster 6 refcount=1 reference=0
357786
+Leaked cluster 7 refcount=1 reference=0
357786
+
357786
+4 leaked clusters were found on the image.
357786
+This means waste of disk space, but no harm to data.
357786
+
357786
+--- Repairing test image ---
357786
+Leaked cluster 4 refcount=2 reference=1
357786
+Leaked cluster 5 refcount=2 reference=1
357786
+Leaked cluster 6 refcount=1 reference=0
357786
+Leaked cluster 7 refcount=1 reference=0
357786
+Repairing cluster 4 refcount=2 reference=1
357786
+Repairing cluster 5 refcount=2 reference=1
357786
+Repairing cluster 6 refcount=1 reference=0
357786
+Repairing cluster 7 refcount=1 reference=0
357786
+Repairing OFLAG_COPIED L2 cluster: l1_index=0 l1_entry=40000 refcount=1
357786
+Repairing OFLAG_COPIED data cluster: l2_entry=50000 refcount=1
357786
+The following inconsistencies were found and repaired:
357786
+
357786
+    4 leaked clusters
357786
+    2 corruptions
357786
+
357786
+Double checking the fixed image now...
357786
+No errors were found on the image.
357786
+*** done
357786
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
357786
index d228008..cd7bc29 100644
357786
--- a/tests/qemu-iotests/group
357786
+++ b/tests/qemu-iotests/group
357786
@@ -215,4 +215,5 @@
357786
 214 rw auto
357786
 215 rw auto quick
357786
 216 rw auto quick
357786
+217 rw auto quick
357786
 218 rw auto quick
357786
-- 
357786
1.8.3.1
357786