3 # Copyright (C) 2018-2021 Red Hat Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # * Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # * Neither the name of Red Hat nor the names of its contributors may be
17 # used to endorse or promote products derived from this software without
18 # specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
24 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 # Test plugin used by test-multi-conn.sh.
34 # This plugin purposefully maintains a per-connection cache.
35 # An optional parameter tightfua=true controls whether FUA acts on
36 # just the given region, or on all pending ops in the current connection.
37 # Note that an earlier cached write on one connection can overwrite a later
38 # FUA write on another connection - this is okay (the client is buggy if
39 # it ever sends overlapping writes without coordinating flushes and still
40 # expects any particular write to occur last).
44 */*) export="$tmpdir/$(dirname $1)" conn
=$
(basename $1) ;;
45 *) export="$tmpdir" conn
=$1 ;;
49 if test ! -f "$export/$conn"; then
50 cp "$export/0" "$export/$conn"
56 if test -f "$tmpdir/strictfua"; then
57 dd of
="$export/0" if="$export/$conn" skip
=$2 seek
=$2 count
=$1 \
58 conv
=notrunc iflag
=count_bytes
,skip_bytes oflag
=seek_bytes
65 if test -f "$export/$conn-replay"; then
66 while read cnt off
; do
67 dd of
="$export/0" if="$export/$conn" skip
=$off seek
=$off count
=$cnt \
68 conv
=notrunc iflag
=count_bytes
,skip_bytes oflag
=seek_bytes
69 done < "$export/$conn-replay"
71 rm -f "$export/$conn" "$export/$conn-replay"
78 true | on |
1) touch "$tmpdir/strictfua" ;;
80 *) echo "unknown value for strictfua $3" >&2; exit 1 ;;
82 *) echo "unknown config key $2" >&2; exit 1 ;;
86 printf "%-32s" 'Initial contents' > "$tmpdir/0"
87 echo 0 > "$tmpdir/counter"
92 can_write | can_zero | can_trim | can_flush
)
99 read i
< "$tmpdir/counter"
101 echo $i > "$tmpdir/counter"
102 if test -z "$3"; then
105 mkdir
-p "$tmpdir/$3" ||
exit 1
106 cp "$tmpdir/0" "$tmpdir/$3/0"
113 dd if="$export/$conn" skip
=$4 count
=$3 iflag
=count_bytes
,skip_bytes
122 dd of
="$export/$conn" seek
=$4 conv
=notrunc oflag
=seek_bytes
123 echo $3 $4 >> "$export/$conn-replay"
129 dd of
="$export/$conn" if="/dev/zero" count
=$3 seek
=$4 conv
=notrunc\
130 oflag
=seek_bytes iflag
=count_bytes
131 echo $3 $4 >> "$export/$conn-replay"