19e1cb96dSKevin Wolf#!/bin/bash 29e1cb96dSKevin Wolf# 39e1cb96dSKevin Wolf# Test concurrent pread/pwrite 49e1cb96dSKevin Wolf# 59e1cb96dSKevin Wolf# Copyright (C) 2014 Red Hat, Inc. 69e1cb96dSKevin Wolf# 79e1cb96dSKevin Wolf# This program is free software; you can redistribute it and/or modify 89e1cb96dSKevin Wolf# it under the terms of the GNU General Public License as published by 99e1cb96dSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 109e1cb96dSKevin Wolf# (at your option) any later version. 119e1cb96dSKevin Wolf# 129e1cb96dSKevin Wolf# This program is distributed in the hope that it will be useful, 139e1cb96dSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 149e1cb96dSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 159e1cb96dSKevin Wolf# GNU General Public License for more details. 169e1cb96dSKevin Wolf# 179e1cb96dSKevin Wolf# You should have received a copy of the GNU General Public License 189e1cb96dSKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 199e1cb96dSKevin Wolf# 209e1cb96dSKevin Wolf 219e1cb96dSKevin Wolf# creator 229e1cb96dSKevin Wolfowner=kwolf@redhat.com 239e1cb96dSKevin Wolf 249e1cb96dSKevin Wolfseq=`basename $0` 259e1cb96dSKevin Wolfecho "QA output created by $seq" 269e1cb96dSKevin Wolf 279e1cb96dSKevin Wolfhere=`pwd` 289e1cb96dSKevin Wolftmp=/tmp/$$ 299e1cb96dSKevin Wolfstatus=1 # failure is the default! 309e1cb96dSKevin Wolf 319e1cb96dSKevin Wolf_cleanup() 329e1cb96dSKevin Wolf{ 339e1cb96dSKevin Wolf _cleanup_test_img 349e1cb96dSKevin Wolf} 359e1cb96dSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 369e1cb96dSKevin Wolf 379e1cb96dSKevin Wolf# get standard environment, filters and checks 389e1cb96dSKevin Wolf. ./common.rc 399e1cb96dSKevin Wolf. ./common.filter 409e1cb96dSKevin Wolf 41*f5106206SKevin Wolf_supported_fmt raw 429e1cb96dSKevin Wolf_supported_proto generic 439e1cb96dSKevin Wolf_supported_os Linux 449e1cb96dSKevin Wolf 459e1cb96dSKevin WolfCLUSTER_SIZE=4k 469e1cb96dSKevin Wolfsize=128M 479e1cb96dSKevin Wolf 489e1cb96dSKevin Wolf_make_test_img $size 499e1cb96dSKevin Wolf 509e1cb96dSKevin Wolfecho 519e1cb96dSKevin Wolfecho "== Some concurrent requests involving RMW ==" 529e1cb96dSKevin Wolf 539e1cb96dSKevin Wolffunction test_io() 549e1cb96dSKevin Wolf{ 559e1cb96dSKevin Wolfecho "open -o file.align=4k blkdebug::$TEST_IMG" 569e1cb96dSKevin Wolf# A simple RMW request 579e1cb96dSKevin Wolfcat <<EOF 589e1cb96dSKevin Wolfaio_write -P 10 0x200 0x200 599e1cb96dSKevin Wolfaio_flush 609e1cb96dSKevin WolfEOF 619e1cb96dSKevin Wolf 629e1cb96dSKevin Wolf# Sequential RMW requests on the same physical sector 639e1cb96dSKevin Wolfoff=0x1000 649e1cb96dSKevin Wolffor ev in "head" "after_head" "tail" "after_tail"; do 659e1cb96dSKevin Wolfcat <<EOF 669e1cb96dSKevin Wolfbreak pwritev_rmw.$ev A 679e1cb96dSKevin Wolfaio_write -P 10 $((off + 0x200)) 0x200 689e1cb96dSKevin Wolfwait_break A 699e1cb96dSKevin Wolfaio_write -P 11 $((off + 0x400)) 0x200 709e1cb96dSKevin Wolfsleep 100 719e1cb96dSKevin Wolfresume A 729e1cb96dSKevin Wolfaio_flush 739e1cb96dSKevin WolfEOF 749e1cb96dSKevin Wolfoff=$((off + 0x1000)) 759e1cb96dSKevin Wolfdone 769e1cb96dSKevin Wolf 779e1cb96dSKevin Wolf# Chained dependencies 789e1cb96dSKevin Wolfcat <<EOF 799e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 809e1cb96dSKevin Wolfaio_write -P 10 0x5000 0x200 819e1cb96dSKevin Wolfwait_break A 829e1cb96dSKevin Wolfaio_write -P 11 0x5200 0x200 839e1cb96dSKevin Wolfaio_write -P 12 0x5400 0x200 849e1cb96dSKevin Wolfaio_write -P 13 0x5600 0x200 859e1cb96dSKevin Wolfaio_write -P 14 0x5800 0x200 869e1cb96dSKevin Wolfaio_write -P 15 0x5a00 0x200 879e1cb96dSKevin Wolfaio_write -P 16 0x5c00 0x200 889e1cb96dSKevin Wolfaio_write -P 17 0x5e00 0x200 899e1cb96dSKevin Wolfsleep 100 909e1cb96dSKevin Wolfresume A 919e1cb96dSKevin Wolfaio_flush 929e1cb96dSKevin WolfEOF 939e1cb96dSKevin Wolf 949e1cb96dSKevin Wolf# Overlapping multiple requests 959e1cb96dSKevin Wolfcat <<EOF 969e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 979e1cb96dSKevin Wolfaio_write -P 10 0x6000 0x200 989e1cb96dSKevin Wolfwait_break A 999e1cb96dSKevin Wolfbreak pwritev_rmw.after_head B 1009e1cb96dSKevin Wolfaio_write -P 10 0x7e00 0x200 1019e1cb96dSKevin Wolfwait_break B 1029e1cb96dSKevin Wolfaio_write -P 11 0x6800 0x1000 1039e1cb96dSKevin Wolfresume A 1049e1cb96dSKevin Wolfsleep 100 1059e1cb96dSKevin Wolfresume B 1069e1cb96dSKevin Wolfaio_flush 1079e1cb96dSKevin WolfEOF 1089e1cb96dSKevin Wolf 1099e1cb96dSKevin Wolfcat <<EOF 1109e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 1119e1cb96dSKevin Wolfaio_write -P 10 0x8000 0x200 1129e1cb96dSKevin Wolfwait_break A 1139e1cb96dSKevin Wolfbreak pwritev_rmw.after_head B 1149e1cb96dSKevin Wolfaio_write -P 10 0x9e00 0x200 1159e1cb96dSKevin Wolfwait_break B 1169e1cb96dSKevin Wolfaio_write -P 11 0x8800 0x1000 1179e1cb96dSKevin Wolfresume B 1189e1cb96dSKevin Wolfsleep 100 1199e1cb96dSKevin Wolfresume A 1209e1cb96dSKevin Wolfaio_flush 1219e1cb96dSKevin WolfEOF 1229e1cb96dSKevin Wolf 1239e1cb96dSKevin Wolfcat <<EOF 1249e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 1259e1cb96dSKevin Wolfaio_write -P 10 0xa000 0x200 1269e1cb96dSKevin Wolfwait_break A 1279e1cb96dSKevin Wolfaio_write -P 11 0xa800 0x1000 1289e1cb96dSKevin Wolfbreak pwritev_rmw.after_head B 1299e1cb96dSKevin Wolfaio_write -P 10 0xbe00 0x200 1309e1cb96dSKevin Wolfwait_break B 1319e1cb96dSKevin Wolfresume A 1329e1cb96dSKevin Wolfsleep 100 1339e1cb96dSKevin Wolfresume B 1349e1cb96dSKevin Wolfaio_flush 1359e1cb96dSKevin WolfEOF 1369e1cb96dSKevin Wolf 1379e1cb96dSKevin Wolfcat <<EOF 1389e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 1399e1cb96dSKevin Wolfaio_write -P 10 0xc000 0x200 1409e1cb96dSKevin Wolfwait_break A 1419e1cb96dSKevin Wolfaio_write -P 11 0xc800 0x1000 1429e1cb96dSKevin Wolfbreak pwritev_rmw.after_head B 1439e1cb96dSKevin Wolfaio_write -P 10 0xde00 0x200 1449e1cb96dSKevin Wolfwait_break B 1459e1cb96dSKevin Wolfresume B 1469e1cb96dSKevin Wolfsleep 100 1479e1cb96dSKevin Wolfresume A 1489e1cb96dSKevin Wolfaio_flush 1499e1cb96dSKevin WolfEOF 1509e1cb96dSKevin Wolf 1519e1cb96dSKevin Wolf# Only RMW for the tail part 1529e1cb96dSKevin Wolfcat <<EOF 1539e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail A 1549e1cb96dSKevin Wolfaio_write -P 10 0xe000 0x1800 1559e1cb96dSKevin Wolfwait_break A 1569e1cb96dSKevin Wolfaio_write -P 11 0xf000 0xc00 1579e1cb96dSKevin Wolfsleep 100 1589e1cb96dSKevin Wolfresume A 1599e1cb96dSKevin Wolfaio_flush 1609e1cb96dSKevin WolfEOF 1619e1cb96dSKevin Wolf 1629e1cb96dSKevin Wolfcat <<EOF 1639e1cb96dSKevin Wolfbreak pwritev A 1649e1cb96dSKevin Wolfaio_write -P 10 0x10000 0x800 1659e1cb96dSKevin Wolfwait_break A 1669e1cb96dSKevin Wolfbreak pwritev_rmw.after_tail B 1679e1cb96dSKevin Wolfaio_write -P 11 0x10000 0x400 1689e1cb96dSKevin Wolfbreak pwritev_done C 1699e1cb96dSKevin Wolfresume A 1709e1cb96dSKevin Wolfwait_break C 1719e1cb96dSKevin Wolfresume C 1729e1cb96dSKevin Wolfsleep 100 1739e1cb96dSKevin Wolfwait_break B 1749e1cb96dSKevin Wolfresume B 1759e1cb96dSKevin Wolfaio_flush 1769e1cb96dSKevin WolfEOF 1779e1cb96dSKevin Wolf 1789e1cb96dSKevin Wolfcat <<EOF 1799e1cb96dSKevin Wolfbreak pwritev A 1809e1cb96dSKevin Wolfaio_write -P 10 0x11000 0x800 1819e1cb96dSKevin Wolfwait_break A 1829e1cb96dSKevin Wolfaio_write -P 11 0x11000 0x1000 1839e1cb96dSKevin Wolfsleep 100 1849e1cb96dSKevin Wolfresume A 1859e1cb96dSKevin Wolfaio_flush 1869e1cb96dSKevin WolfEOF 1879e1cb96dSKevin Wolf} 1889e1cb96dSKevin Wolf 1899e1cb96dSKevin Wolftest_io | $QEMU_IO | _filter_qemu_io | \ 1909e1cb96dSKevin Wolf sed -e 's,[0-9/]* bytes at offset [0-9]*,XXX/XXX bytes at offset XXX,g' \ 1919e1cb96dSKevin Wolf -e 's/^[0-9]* \(bytes\|KiB\)/XXX bytes/' \ 1929e1cb96dSKevin Wolf -e '/Suspended/d' 1939e1cb96dSKevin Wolf 1949e1cb96dSKevin Wolfecho 1959e1cb96dSKevin Wolfecho "== Verify image content ==" 1969e1cb96dSKevin Wolf 1979e1cb96dSKevin Wolffunction verify_io() 1989e1cb96dSKevin Wolf{ 1999e1cb96dSKevin Wolf # A simple RMW request 2009e1cb96dSKevin Wolf echo read -P 0 0 0x200 2019e1cb96dSKevin Wolf echo read -P 10 0x200 0x200 2029e1cb96dSKevin Wolf echo read -P 0 0x400 0xc00 2039e1cb96dSKevin Wolf 2049e1cb96dSKevin Wolf # Sequential RMW requests on the same physical sector 2059e1cb96dSKevin Wolf echo read -P 0 0x1000 0x200 2069e1cb96dSKevin Wolf echo read -P 10 0x1200 0x200 2079e1cb96dSKevin Wolf echo read -P 11 0x1400 0x200 2089e1cb96dSKevin Wolf echo read -P 0 0x1600 0xa00 2099e1cb96dSKevin Wolf 2109e1cb96dSKevin Wolf echo read -P 0 0x2000 0x200 2119e1cb96dSKevin Wolf echo read -P 10 0x2200 0x200 2129e1cb96dSKevin Wolf echo read -P 11 0x2400 0x200 2139e1cb96dSKevin Wolf echo read -P 0 0x2600 0xa00 2149e1cb96dSKevin Wolf 2159e1cb96dSKevin Wolf echo read -P 0 0x3000 0x200 2169e1cb96dSKevin Wolf echo read -P 10 0x3200 0x200 2179e1cb96dSKevin Wolf echo read -P 11 0x3400 0x200 2189e1cb96dSKevin Wolf echo read -P 0 0x3600 0xa00 2199e1cb96dSKevin Wolf 2209e1cb96dSKevin Wolf echo read -P 0 0x4000 0x200 2219e1cb96dSKevin Wolf echo read -P 10 0x4200 0x200 2229e1cb96dSKevin Wolf echo read -P 11 0x4400 0x200 2239e1cb96dSKevin Wolf echo read -P 0 0x4600 0xa00 2249e1cb96dSKevin Wolf 2259e1cb96dSKevin Wolf # Chained dependencies 2269e1cb96dSKevin Wolf echo read -P 10 0x5000 0x200 2279e1cb96dSKevin Wolf echo read -P 11 0x5200 0x200 2289e1cb96dSKevin Wolf echo read -P 12 0x5400 0x200 2299e1cb96dSKevin Wolf echo read -P 13 0x5600 0x200 2309e1cb96dSKevin Wolf echo read -P 14 0x5800 0x200 2319e1cb96dSKevin Wolf echo read -P 15 0x5a00 0x200 2329e1cb96dSKevin Wolf echo read -P 16 0x5c00 0x200 2339e1cb96dSKevin Wolf echo read -P 17 0x5e00 0x200 2349e1cb96dSKevin Wolf 2359e1cb96dSKevin Wolf # Overlapping multiple requests 2369e1cb96dSKevin Wolf echo read -P 10 0x6000 0x200 2379e1cb96dSKevin Wolf echo read -P 0 0x6200 0x600 2389e1cb96dSKevin Wolf echo read -P 11 0x6800 0x1000 2399e1cb96dSKevin Wolf echo read -P 0 0x7800 0x600 2409e1cb96dSKevin Wolf echo read -P 10 0x7e00 0x200 2419e1cb96dSKevin Wolf 2429e1cb96dSKevin Wolf echo read -P 10 0x8000 0x200 2439e1cb96dSKevin Wolf echo read -P 0 0x8200 0x600 2449e1cb96dSKevin Wolf echo read -P 11 0x8800 0x1000 2459e1cb96dSKevin Wolf echo read -P 0 0x9800 0x600 2469e1cb96dSKevin Wolf echo read -P 10 0x9e00 0x200 2479e1cb96dSKevin Wolf 2489e1cb96dSKevin Wolf echo read -P 10 0xa000 0x200 2499e1cb96dSKevin Wolf echo read -P 0 0xa200 0x600 2509e1cb96dSKevin Wolf echo read -P 11 0xa800 0x1000 2519e1cb96dSKevin Wolf echo read -P 0 0xb800 0x600 2529e1cb96dSKevin Wolf echo read -P 10 0xbe00 0x200 2539e1cb96dSKevin Wolf 2549e1cb96dSKevin Wolf echo read -P 10 0xc000 0x200 2559e1cb96dSKevin Wolf echo read -P 0 0xc200 0x600 2569e1cb96dSKevin Wolf echo read -P 11 0xc800 0x1000 2579e1cb96dSKevin Wolf echo read -P 0 0xd800 0x600 2589e1cb96dSKevin Wolf echo read -P 10 0xde00 0x200 2599e1cb96dSKevin Wolf 2609e1cb96dSKevin Wolf # Only RMW for the tail part 2619e1cb96dSKevin Wolf echo read -P 10 0xe000 0x1000 2629e1cb96dSKevin Wolf echo read -P 11 0xf800 0x400 2639e1cb96dSKevin Wolf echo read -P 0 0xfc00 0x400 2649e1cb96dSKevin Wolf 2659e1cb96dSKevin Wolf echo read -P 11 0x10000 0x400 2669e1cb96dSKevin Wolf echo read -P 10 0x10400 0x400 2679e1cb96dSKevin Wolf 2689e1cb96dSKevin Wolf echo read -P 11 0x11800 0x800 2699e1cb96dSKevin Wolf} 2709e1cb96dSKevin Wolf 2719e1cb96dSKevin Wolfverify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io 2729e1cb96dSKevin Wolf 2739e1cb96dSKevin Wolf_check_test_img 2749e1cb96dSKevin Wolf 2759e1cb96dSKevin Wolf# success, all done 2769e1cb96dSKevin Wolfecho "*** done" 2779e1cb96dSKevin Wolfrm -f $seq.full 2789e1cb96dSKevin Wolfstatus=0 279