blob: c1f77e1b86207f101cdaaba91ed0fbd1dae50bbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
#
# FS QA Test 108
#
# Test partial block device failure. Calls like fsync() should report failure
# on partial I/O failure, e.g. a single failed disk in a raid 0 stripe.
#
# Test motivated by an XFS bug, and this commit fixed the issue
# xfs: return errors from partial I/O failures to files
#
. ./common/preamble
_begin_fstest auto quick rw
# Override the default cleanup function.
_cleanup()
{
cd /
echo running > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/state
$UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
$LVM_PROG vgremove -f $vgname >>$seqres.full 2>&1
$LVM_PROG pvremove -f $SCRATCH_DEV $SCSI_DEBUG_DEV >>$seqres.full 2>&1
$UDEV_SETTLE_PROG
_put_scsi_debug_dev
rm -f $tmp.*
}
# Import common functions.
. ./common/filter
. ./common/scsi_debug
# real QA test starts here
_supported_fs generic
_require_scratch_nolvm
_require_block_device $SCRATCH_DEV
_require_scsi_debug
_require_command "$LVM_PROG" lvm
# We cannot ensure the Logical Volume is aligned to the zone boundary
_require_non_zoned_device $SCRATCH_DEV
lvname=lv_$seq
vgname=vg_$seq
physical=`blockdev --getpbsz $SCRATCH_DEV`
logical=`blockdev --getss $SCRATCH_DEV`
size=$(_small_fs_size_mb 300)
lvsize=$((size * 91 / 100))
# _get_scsi_debug_dev returns a scsi debug device with 128M in size by default
SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 $size`
test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
# create striped volume with 4MB stripe size
$LVM_PROG pvcreate -f $SCSI_DEBUG_DEV $SCRATCH_DEV >>$seqres.full 2>&1
$LVM_PROG vgcreate -f $vgname $SCSI_DEBUG_DEV $SCRATCH_DEV >>$seqres.full 2>&1
# We use yes pipe instead of 'lvcreate --yes' because old version of lvm
# (like 2.02.95 in RHEL6) don't support --yes option
yes | $LVM_PROG lvcreate -i 2 -I 4m -L ${lvsize}m -n $lvname $vgname \
>>$seqres.full 2>&1
# wait for lv creation to fully complete
$UDEV_SETTLE_PROG >>$seqres.full 2>&1
# _mkfs_dev exits the test on failure, this makes sure test lv is created by
# above vgcreate/lvcreate operations
_mkfs_dev /dev/mapper/$vgname-$lvname
_mount -t $FSTYP /dev/mapper/$vgname-$lvname $SCRATCH_MNT
# create a test file with contiguous blocks which will span across the 2 disks
$XFS_IO_PROG -f -c "pwrite 0 16M" -c fsync $SCRATCH_MNT/testfile >>$seqres.full
# offline the scsi debug device
echo offline > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/state
# write to an allocated area of the test file with writes which spans both disks
# and call fsync, the fsync should report failure
$XFS_IO_PROG -c "pwrite -b 1M 0 6M" -c fsync $SCRATCH_MNT/testfile \
>>$seqres.full
status=0
exit
|