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

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