#! /bin/sh

. dm_tools.sh

s1=89
s2=90
p1=path1
p2=path2
mpath=mpath

# The tables we're going to be using for this test
table_linear="0 1024000 linear /dev/hda3 8"
table_flakey="0 1024000 flakey /dev/hda3 8 200 200"
table_mpath="0 1024000 multipath 1 round-robin 2 0 /dev/mapper/path1 /dev/mapper/path2"

# just in case the device already exists
remove_quietly $p1 >&2 /dev/null
remove_quietly $p2 >&2 /dev/null
remove_quietly $mpath >&2 /dev/null

# create the devices
create $p1 $table_linear
create $p2 $table_flakey
create $mpath $table_mpath

exit 0

# stamp a pattern via one of the paths
stamp $p1 $s1

# check reads to mpath work
verify $mpath $s1
exit 0

# wait for p2 to stop working
sleep 20
verify $mpath $s1

# stamp across mpath
stamp $mpath $s2

# remove all the devices (otherwise we get old data in the buffer
# cache for p1)
remove $mpath
remove $p2
remove $p1

# check the mpath write worked
create $p1 $table_linear
verify $p1 $s2
remove $p1
