1#!/usr/bin/env bash 2# group: rw quick 3# 4# Check the interaction of request padding (to fit alignment restrictions) with 5# vectored I/O from the guest 6# 7# Copyright Red Hat 8# 9# This program is free software; you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation; either version 2 of the License, or 12# (at your option) any later version. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program. If not, see <http://www.gnu.org/licenses/>. 21# 22 23seq=$(basename $0) 24echo "QA output created by $seq" 25 26status=1 # failure is the default! 27 28_cleanup() 29{ 30 _cleanup_test_img 31} 32trap "_cleanup; exit \$status" 0 1 2 3 15 33 34# get standard environment, filters and checks 35cd .. 36. ./common.rc 37. ./common.filter 38 39_supported_fmt raw 40_supported_proto file 41 42_make_test_img 1M 43 44IMGSPEC="driver=blkdebug,align=4096,image.driver=file,image.filename=$TEST_IMG" 45 46# Four combinations: 47# - Offset 4096, length 1023 * 512 + 512: Fully aligned to 4k 48# - Offset 4096, length 1023 * 512 + 4096: Head is aligned, tail is not 49# - Offset 512, length 1023 * 512 + 512: Neither head nor tail are aligned 50# - Offset 512, length 1023 * 512 + 4096: Tail is aligned, head is not 51for start_offset in 4096 512; do 52 for last_element_length in 512 4096; do 53 length=$((1023 * 512 + $last_element_length)) 54 55 echo 56 echo "== performing 1024-element vectored requests to image (offset: $start_offset; length: $length) ==" 57 58 # Fill with data for testing 59 $QEMU_IO -c 'write -P 1 0 1M' "$TEST_IMG" | _filter_qemu_io 60 61 # 1023 512-byte buffers, and then one with length $last_element_length 62 cmd_params="-P 2 $start_offset $(yes 512 | head -n 1023 | tr '\n' ' ') $last_element_length" 63 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" $QEMU_IO \ 64 -c "writev $cmd_params" \ 65 --image-opts \ 66 "$IMGSPEC" \ 67 | _filter_qemu_io 68 69 # Read all patterns -- read the part we just wrote with writev twice, 70 # once "normally", and once with a readv, so we see that that works, too 71 QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" $QEMU_IO \ 72 -c "read -P 1 0 $start_offset" \ 73 -c "read -P 2 $start_offset $length" \ 74 -c "readv $cmd_params" \ 75 -c "read -P 1 $((start_offset + length)) $((1024 * 1024 - length - start_offset))" \ 76 --image-opts \ 77 "$IMGSPEC" \ 78 | _filter_qemu_io 79 done 80done 81 82# success, all done 83echo "*** done" 84rm -f $seq.full 85status=0 86