#!/bin/sh
-# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
METASIZE=$(get lv_field $vg/${lv1}_rmeta_1 size -a --units 1k)
SEEK=$((${START%\.00k} + ${METASIZE%\.00k}))
# Overwrite some portion of _rimage_1
+
+#aux delay_dev "$dev2" 10 10
dd if=/dev/urandom of="$dev2" bs=1K count=1 seek=$SEEK oflag=direct
+# FIXME
+# Some delay - there is currently race in upstream kernel
+# test may occasionaly fail with:
+# device-mapper: message ioctl on failed: Device or resource busy
+#
+# Heinz's kernel seems to fix this particular issue but
+# has some other problem for now
+aux udev_wait
-aux wait_for_sync $vg $lv1
lvchange --syncaction check $vg/$lv1
+
+# Wait till scrubbing is finished
+aux wait_for_sync $vg $lv1
+
check lv_field $vg/$lv1 raid_mismatch_count "128"
# Let's deactivate
lvchange -an $vg/$lv1
-# Slow down write by 100ms
-aux delay_dev "$dev2" 0 50
lvchange -ay $vg/$lv1
# noone has it open and target is read & running
dmsetup info -c | grep $vg
# As solution for now - user needs to run --synaction on synchronous raid array
#
aux wait_for_sync $vg $lv1
-should lvchange --syncaction check $vg/$lv1
-aux enable_dev "$dev2"
+# Check raid array doesn't know about error yet
check lv_field $vg/$lv1 raid_mismatch_count "0"
+# Start scrubbing
+lvchange --syncaction check $vg/$lv1
+
+# Wait till scrubbing is finished
+aux wait_for_sync $vg $lv1
+
+# Retest mistmatch exists
+check lv_field $vg/$lv1 raid_mismatch_count "128"
+
vgremove -ff $vg