2014-05-28 17:23:46 +04:00
#!/bin/sh
2015-02-17 13:03:20 +03:00
# Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
2014-05-28 17:23:46 +04:00
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2014-05-28 17:23:46 +04:00
# test activation race for raid's --syncaction check
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2014-05-28 17:23:46 +04:00
2016-09-09 19:27:12 +03:00
# Current support for syncaction in cluster is broken
# might get fixed one day though
# meanwhile skipped
SKIP_WITH_CLVMD = 1
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-05-31 02:26:10 +04:00
# Proper mismatch count 1.5.2+ upstream, 1.3.5 < x < 1.4.0 in RHEL6
aux have_raid 1 3 5 &&
! aux have_raid 1 4 0 ||
aux have_raid 1 5 2 || skip
2014-05-28 17:23:46 +04:00
aux prepare_vg 3
lvcreate -n $lv1 $vg -l1 --type raid1
2014-10-25 18:03:44 +04:00
aux wait_for_sync $vg $lv1
2014-05-28 17:23:46 +04:00
START = $( get pv_field " $dev2 " pe_start --units 1k)
METASIZE = $( get lv_field $vg /${ lv1 } _rmeta_1 size -a --units 1k)
SEEK = $(( ${ START % \. 00k } + ${ METASIZE % \. 00k } ))
# Overwrite some portion of _rimage_1
2015-02-17 13:03:20 +03:00
#aux delay_dev "$dev2" 10 10
2014-05-31 02:26:10 +04:00
dd if = /dev/urandom of = " $dev2 " bs = 1K count = 1 seek = $SEEK oflag = direct
2015-02-17 13:03:20 +03:00
# 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
2014-05-28 17:23:46 +04:00
lvchange --syncaction check $vg /$lv1
2015-02-17 13:03:20 +03:00
# Wait till scrubbing is finished
aux wait_for_sync $vg $lv1
2014-05-28 17:23:46 +04:00
check lv_field $vg /$lv1 raid_mismatch_count "128"
# Let's deactivate
lvchange -an $vg /$lv1
lvchange -ay $vg /$lv1
# noone has it open and target is read & running
2014-10-21 12:52:57 +04:00
dmsetup info -c | grep $vg
2014-05-28 17:23:46 +04:00
#sleep 10 < "$DM_DEV_DIR/$vg/$lv1" &
# "check" should find discrepancies but not change them
# 'lvs' should show results
# FIXME
# this looks like some race with 'write' during activation
# and syncaction...
# For now it fails with:
# device-mapper: message ioctl on failed: Device or resource busy
#
2014-10-25 18:03:44 +04:00
# As solution for now - user needs to run --synaction on synchronous raid array
#
aux wait_for_sync $vg $lv1
2014-05-28 17:23:46 +04:00
2015-02-17 13:03:20 +03:00
# Check raid array doesn't know about error yet
2014-10-25 18:03:44 +04:00
check lv_field $vg /$lv1 raid_mismatch_count "0"
2014-05-28 17:23:46 +04:00
2015-02-17 13:03:20 +03:00
# 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"
2014-05-28 17:23:46 +04:00
vgremove -ff $vg