50
50
51
51
typeset datafile1=" $( mktemp -t zvol_misc_fua1.XXXXXX) "
52
52
typeset datafile2=" $( mktemp -t zvol_misc_fua2.XXXXXX) "
53
+ typeset datafile3=" $( mktemp -t zvol_misc_fua3_log.XXXXXX) "
53
54
typeset zvolpath=${ZVOL_DEVDIR} /$TESTPOOL /$TESTVOL
54
55
56
+ typeset DISK1=${DISKS%% * }
55
57
function cleanup
56
58
{
57
- rm " $datafile1 " " $datafile2 "
59
+ log_must zpool remove $TESTPOOL $datafile3
60
+ rm " $datafile1 " " $datafile2 " " $datafile2 "
61
+ }
62
+
63
+ # Prints the total number of sync writes for a vdev
64
+ # $1: vdev
65
+ function get_sync
66
+ {
67
+ zpool iostat -p -H -v -r $TESTPOOL $1 | \
68
+ awk ' /[0-9]+$/{s+=$4+$5} END{print s}'
58
69
}
59
70
60
71
function do_test {
61
72
# Wait for udev to create symlinks to our zvol
62
73
block_device_wait $zvolpath
63
74
75
+ # Write using sync (creates FLUSH calls after writes, but not FUA)
76
+ old_vdev_writes=$( get_sync $DISK1 )
77
+ old_log_writes=$( get_sync $datafile3 )
78
+
79
+ log_must fio --name=write_iops --size=5M \
80
+ --ioengine=libaio --verify=0 --bs=4K \
81
+ --iodepth=1 --rw=randwrite --group_reporting=1 \
82
+ --filename=$zvolpath --sync=1
83
+
84
+ vdev_writes=$(( $(get_sync $DISK1 ) - $old_vdev_writes ))
85
+ log_writes=$(( $(get_sync $datafile3 ) - $old_log_writes ))
86
+
87
+ # When we're doing sync writes, we should see many more writes go to
88
+ # the log vs the first vdev. Experiments show anywhere from a 160-320x
89
+ # ratio of writes to the log vs the first vdev (due to some straggler
90
+ # writes to the first vdev).
91
+ #
92
+ # Check that we have a large ratio (100x) of sync writes going to the
93
+ # log device
94
+ ratio=$(( $log_writes / $vdev_writes ))
95
+ if [ $ratio -lt 100 ] ; then
96
+ log_fail " Expected > 100x more log writes than vdev writes. " \
97
+ " Got $log_writes log writes, $vdev_writes vdev writes."
98
+ fi
99
+
64
100
# Create a data file
65
101
log_must dd if=/dev/urandom of=" $datafile1 " bs=1M count=5
66
102
@@ -81,6 +117,8 @@ log_assert "Verify that a ZFS volume can do Force Unit Access (FUA)"
81
117
log_onexit cleanup
82
118
83
119
log_must zfs set compression=off $TESTPOOL /$TESTVOL
120
+ log_must truncate -s 100M $datafile3
121
+ log_must zpool add $TESTPOOL log $datafile3
84
122
85
123
log_note " Testing without blk-mq"
86
124
0 commit comments