111a82d14SPhilippe Mathieu-Daudé#!/usr/bin/env bash 2*9dd003a9SVladimir Sementsov-Ogievskiy# group: rw quick 39e1cb96dSKevin Wolf# 49e1cb96dSKevin Wolf# Test concurrent pread/pwrite 59e1cb96dSKevin Wolf# 69e1cb96dSKevin Wolf# Copyright (C) 2014 Red Hat, Inc. 79e1cb96dSKevin Wolf# 89e1cb96dSKevin Wolf# This program is free software; you can redistribute it and/or modify 99e1cb96dSKevin Wolf# it under the terms of the GNU General Public License as published by 109e1cb96dSKevin Wolf# the Free Software Foundation; either version 2 of the License, or 119e1cb96dSKevin Wolf# (at your option) any later version. 129e1cb96dSKevin Wolf# 139e1cb96dSKevin Wolf# This program is distributed in the hope that it will be useful, 149e1cb96dSKevin Wolf# but WITHOUT ANY WARRANTY; without even the implied warranty of 159e1cb96dSKevin Wolf# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 169e1cb96dSKevin Wolf# GNU General Public License for more details. 179e1cb96dSKevin Wolf# 189e1cb96dSKevin Wolf# You should have received a copy of the GNU General Public License 199e1cb96dSKevin Wolf# along with this program. If not, see <http://www.gnu.org/licenses/>. 209e1cb96dSKevin Wolf# 219e1cb96dSKevin Wolf 229e1cb96dSKevin Wolf# creator 239e1cb96dSKevin Wolfowner=kwolf@redhat.com 249e1cb96dSKevin Wolf 259e1cb96dSKevin Wolfseq=`basename $0` 269e1cb96dSKevin Wolfecho "QA output created by $seq" 279e1cb96dSKevin Wolf 289e1cb96dSKevin Wolfstatus=1 # failure is the default! 299e1cb96dSKevin Wolf 309e1cb96dSKevin Wolf_cleanup() 319e1cb96dSKevin Wolf{ 329e1cb96dSKevin Wolf _cleanup_test_img 339e1cb96dSKevin Wolf} 349e1cb96dSKevin Wolftrap "_cleanup; exit \$status" 0 1 2 3 15 359e1cb96dSKevin Wolf 369e1cb96dSKevin Wolf# get standard environment, filters and checks 379e1cb96dSKevin Wolf. ./common.rc 389e1cb96dSKevin Wolf. ./common.filter 399e1cb96dSKevin Wolf 40f5106206SKevin Wolf_supported_fmt raw 419e1cb96dSKevin Wolf_supported_proto generic 429e1cb96dSKevin Wolf_supported_os Linux 439e1cb96dSKevin Wolf 449e1cb96dSKevin WolfCLUSTER_SIZE=4k 459e1cb96dSKevin Wolfsize=128M 469e1cb96dSKevin Wolf 479e1cb96dSKevin Wolf_make_test_img $size 489e1cb96dSKevin Wolf 499e1cb96dSKevin Wolfecho 509e1cb96dSKevin Wolfecho "== Some concurrent requests involving RMW ==" 519e1cb96dSKevin Wolf 528cedcffdSEric Blaketest_io() 539e1cb96dSKevin Wolf{ 548f9e835fSKevin Wolfecho "open -o driver=$IMGFMT,file.align=4k blkdebug::$TEST_IMG" 559e1cb96dSKevin Wolf# A simple RMW request 569e1cb96dSKevin Wolfcat <<EOF 579e1cb96dSKevin Wolfaio_write -P 10 0x200 0x200 589e1cb96dSKevin Wolfaio_flush 599e1cb96dSKevin WolfEOF 609e1cb96dSKevin Wolf 619e1cb96dSKevin Wolf# Sequential RMW requests on the same physical sector 629e1cb96dSKevin Wolfoff=0x1000 63117bc3faSPeter Lievenfor ev in "head" "after_head"; do 649e1cb96dSKevin Wolfcat <<EOF 655be5b776SEric Blakebreak pwritev_rmw_$ev A 669e1cb96dSKevin Wolfaio_write -P 10 $((off + 0x200)) 0x200 679e1cb96dSKevin Wolfwait_break A 689e1cb96dSKevin Wolfaio_write -P 11 $((off + 0x400)) 0x200 699e1cb96dSKevin Wolfsleep 100 709e1cb96dSKevin Wolfresume A 719e1cb96dSKevin Wolfaio_flush 729e1cb96dSKevin WolfEOF 739e1cb96dSKevin Wolfoff=$((off + 0x1000)) 749e1cb96dSKevin Wolfdone 759e1cb96dSKevin Wolf 769e1cb96dSKevin Wolf# Chained dependencies 779e1cb96dSKevin Wolfcat <<EOF 785be5b776SEric Blakebreak pwritev_rmw_after_tail A 799e1cb96dSKevin Wolfaio_write -P 10 0x5000 0x200 809e1cb96dSKevin Wolfwait_break A 819e1cb96dSKevin Wolfaio_write -P 11 0x5200 0x200 829e1cb96dSKevin Wolfaio_write -P 12 0x5400 0x200 839e1cb96dSKevin Wolfaio_write -P 13 0x5600 0x200 849e1cb96dSKevin Wolfaio_write -P 14 0x5800 0x200 859e1cb96dSKevin Wolfaio_write -P 15 0x5a00 0x200 869e1cb96dSKevin Wolfaio_write -P 16 0x5c00 0x200 879e1cb96dSKevin Wolfaio_write -P 17 0x5e00 0x200 889e1cb96dSKevin Wolfsleep 100 899e1cb96dSKevin Wolfresume A 909e1cb96dSKevin Wolfaio_flush 919e1cb96dSKevin WolfEOF 929e1cb96dSKevin Wolf 939e1cb96dSKevin Wolf# Overlapping multiple requests 949e1cb96dSKevin Wolfcat <<EOF 955be5b776SEric Blakebreak pwritev_rmw_after_tail A 969e1cb96dSKevin Wolfaio_write -P 10 0x6000 0x200 979e1cb96dSKevin Wolfwait_break A 985be5b776SEric Blakebreak pwritev_rmw_after_head B 999e1cb96dSKevin Wolfaio_write -P 10 0x7e00 0x200 1009e1cb96dSKevin Wolfwait_break B 1019e1cb96dSKevin Wolfaio_write -P 11 0x6800 0x1000 1029e1cb96dSKevin Wolfresume A 1039e1cb96dSKevin Wolfsleep 100 1049e1cb96dSKevin Wolfresume B 1059e1cb96dSKevin Wolfaio_flush 1069e1cb96dSKevin WolfEOF 1079e1cb96dSKevin Wolf 1089e1cb96dSKevin Wolfcat <<EOF 1095be5b776SEric Blakebreak pwritev_rmw_after_tail A 1109e1cb96dSKevin Wolfaio_write -P 10 0x8000 0x200 1119e1cb96dSKevin Wolfwait_break A 1125be5b776SEric Blakebreak pwritev_rmw_after_head B 1139e1cb96dSKevin Wolfaio_write -P 10 0x9e00 0x200 1149e1cb96dSKevin Wolfwait_break B 1159e1cb96dSKevin Wolfaio_write -P 11 0x8800 0x1000 1169e1cb96dSKevin Wolfresume B 1179e1cb96dSKevin Wolfsleep 100 1189e1cb96dSKevin Wolfresume A 1199e1cb96dSKevin Wolfaio_flush 1209e1cb96dSKevin WolfEOF 1219e1cb96dSKevin Wolf 1229e1cb96dSKevin Wolfcat <<EOF 1235be5b776SEric Blakebreak pwritev_rmw_after_tail A 1249e1cb96dSKevin Wolfaio_write -P 10 0xa000 0x200 1259e1cb96dSKevin Wolfwait_break A 1269e1cb96dSKevin Wolfaio_write -P 11 0xa800 0x1000 1275be5b776SEric Blakebreak pwritev_rmw_after_head B 1289e1cb96dSKevin Wolfaio_write -P 10 0xbe00 0x200 1299e1cb96dSKevin Wolfwait_break B 1309e1cb96dSKevin Wolfresume A 1319e1cb96dSKevin Wolfsleep 100 1329e1cb96dSKevin Wolfresume B 1339e1cb96dSKevin Wolfaio_flush 1349e1cb96dSKevin WolfEOF 1359e1cb96dSKevin Wolf 1369e1cb96dSKevin Wolfcat <<EOF 1375be5b776SEric Blakebreak pwritev_rmw_after_tail A 1389e1cb96dSKevin Wolfaio_write -P 10 0xc000 0x200 1399e1cb96dSKevin Wolfwait_break A 1409e1cb96dSKevin Wolfaio_write -P 11 0xc800 0x1000 1415be5b776SEric Blakebreak pwritev_rmw_after_head B 1429e1cb96dSKevin Wolfaio_write -P 10 0xde00 0x200 1439e1cb96dSKevin Wolfwait_break B 1449e1cb96dSKevin Wolfresume B 1459e1cb96dSKevin Wolfsleep 100 1469e1cb96dSKevin Wolfresume A 1479e1cb96dSKevin Wolfaio_flush 1489e1cb96dSKevin WolfEOF 1499e1cb96dSKevin Wolf 1509e1cb96dSKevin Wolf# Only RMW for the tail part 1519e1cb96dSKevin Wolfcat <<EOF 1525be5b776SEric Blakebreak pwritev_rmw_after_tail A 1539e1cb96dSKevin Wolfaio_write -P 10 0xe000 0x1800 1549e1cb96dSKevin Wolfwait_break A 1559e1cb96dSKevin Wolfaio_write -P 11 0xf000 0xc00 1569e1cb96dSKevin Wolfsleep 100 1579e1cb96dSKevin Wolfresume A 1589e1cb96dSKevin Wolfaio_flush 1599e1cb96dSKevin WolfEOF 1609e1cb96dSKevin Wolf 1619e1cb96dSKevin Wolfcat <<EOF 1629e1cb96dSKevin Wolfbreak pwritev A 1639e1cb96dSKevin Wolfaio_write -P 10 0x10000 0x800 1649e1cb96dSKevin Wolfwait_break A 1655be5b776SEric Blakebreak pwritev_rmw_after_tail B 1669e1cb96dSKevin Wolfaio_write -P 11 0x10000 0x400 1679e1cb96dSKevin Wolfbreak pwritev_done C 1689e1cb96dSKevin Wolfresume A 1699e1cb96dSKevin Wolfwait_break C 1709e1cb96dSKevin Wolfresume C 1719e1cb96dSKevin Wolfsleep 100 1729e1cb96dSKevin Wolfwait_break B 1739e1cb96dSKevin Wolfresume B 1749e1cb96dSKevin Wolfaio_flush 1759e1cb96dSKevin WolfEOF 1769e1cb96dSKevin Wolf 1779e1cb96dSKevin Wolfcat <<EOF 1789e1cb96dSKevin Wolfbreak pwritev A 1799e1cb96dSKevin Wolfaio_write -P 10 0x11000 0x800 1809e1cb96dSKevin Wolfwait_break A 1819e1cb96dSKevin Wolfaio_write -P 11 0x11000 0x1000 1829e1cb96dSKevin Wolfsleep 100 1839e1cb96dSKevin Wolfresume A 1849e1cb96dSKevin Wolfaio_flush 1859e1cb96dSKevin WolfEOF 1869e1cb96dSKevin Wolf} 1879e1cb96dSKevin Wolf 1889e1cb96dSKevin Wolftest_io | $QEMU_IO | _filter_qemu_io | \ 1899e1cb96dSKevin Wolf sed -e 's,[0-9/]* bytes at offset [0-9]*,XXX/XXX bytes at offset XXX,g' \ 1909e1cb96dSKevin Wolf -e 's/^[0-9]* \(bytes\|KiB\)/XXX bytes/' \ 191d04c1555SFam Zheng -e '/Suspended/d' \ 192d04c1555SFam Zheng -e '/blkdebug: Resuming request/d' 1939e1cb96dSKevin Wolf 1949e1cb96dSKevin Wolfecho 1959e1cb96dSKevin Wolfecho "== Verify image content ==" 1969e1cb96dSKevin Wolf 1978cedcffdSEric Blakeverify_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 # Chained dependencies 2169e1cb96dSKevin Wolf echo read -P 10 0x5000 0x200 2179e1cb96dSKevin Wolf echo read -P 11 0x5200 0x200 2189e1cb96dSKevin Wolf echo read -P 12 0x5400 0x200 2199e1cb96dSKevin Wolf echo read -P 13 0x5600 0x200 2209e1cb96dSKevin Wolf echo read -P 14 0x5800 0x200 2219e1cb96dSKevin Wolf echo read -P 15 0x5a00 0x200 2229e1cb96dSKevin Wolf echo read -P 16 0x5c00 0x200 2239e1cb96dSKevin Wolf echo read -P 17 0x5e00 0x200 2249e1cb96dSKevin Wolf 2259e1cb96dSKevin Wolf # Overlapping multiple requests 2269e1cb96dSKevin Wolf echo read -P 10 0x6000 0x200 2279e1cb96dSKevin Wolf echo read -P 0 0x6200 0x600 2289e1cb96dSKevin Wolf echo read -P 11 0x6800 0x1000 2299e1cb96dSKevin Wolf echo read -P 0 0x7800 0x600 2309e1cb96dSKevin Wolf echo read -P 10 0x7e00 0x200 2319e1cb96dSKevin Wolf 2329e1cb96dSKevin Wolf echo read -P 10 0x8000 0x200 2339e1cb96dSKevin Wolf echo read -P 0 0x8200 0x600 2349e1cb96dSKevin Wolf echo read -P 11 0x8800 0x1000 2359e1cb96dSKevin Wolf echo read -P 0 0x9800 0x600 2369e1cb96dSKevin Wolf echo read -P 10 0x9e00 0x200 2379e1cb96dSKevin Wolf 2389e1cb96dSKevin Wolf echo read -P 10 0xa000 0x200 2399e1cb96dSKevin Wolf echo read -P 0 0xa200 0x600 2409e1cb96dSKevin Wolf echo read -P 11 0xa800 0x1000 2419e1cb96dSKevin Wolf echo read -P 0 0xb800 0x600 2429e1cb96dSKevin Wolf echo read -P 10 0xbe00 0x200 2439e1cb96dSKevin Wolf 2449e1cb96dSKevin Wolf echo read -P 10 0xc000 0x200 2459e1cb96dSKevin Wolf echo read -P 0 0xc200 0x600 2469e1cb96dSKevin Wolf echo read -P 11 0xc800 0x1000 2479e1cb96dSKevin Wolf echo read -P 0 0xd800 0x600 2489e1cb96dSKevin Wolf echo read -P 10 0xde00 0x200 2499e1cb96dSKevin Wolf 2509e1cb96dSKevin Wolf # Only RMW for the tail part 2519e1cb96dSKevin Wolf echo read -P 10 0xe000 0x1000 2529e1cb96dSKevin Wolf echo read -P 11 0xf800 0x400 2539e1cb96dSKevin Wolf echo read -P 0 0xfc00 0x400 2549e1cb96dSKevin Wolf 2559e1cb96dSKevin Wolf echo read -P 11 0x10000 0x400 2569e1cb96dSKevin Wolf echo read -P 10 0x10400 0x400 2579e1cb96dSKevin Wolf 2589e1cb96dSKevin Wolf echo read -P 11 0x11800 0x800 2599e1cb96dSKevin Wolf} 2609e1cb96dSKevin Wolf 2619e1cb96dSKevin Wolfverify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io 2629e1cb96dSKevin Wolf 2639e1cb96dSKevin Wolf_check_test_img 2649e1cb96dSKevin Wolf 2659e1cb96dSKevin Wolf# success, all done 2669e1cb96dSKevin Wolfecho "*** done" 2679e1cb96dSKevin Wolfrm -f $seq.full 2689e1cb96dSKevin Wolfstatus=0 269