3 # Copyright (c) 2012 Red Hat, Inc
6 # Written by Eric Sandeen <sandeen@redhat.com>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it would be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 # Functions useful for tests on unique block devices
27 # make sure we have the module and it's not already used
28 modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found"
29 lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use")
30 # make sure it has the features we need
31 # logical/physical sectors plus unmap support all went in together
32 modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old"
35 # Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]]
38 # Defaults to phys 512, logical 512, aligned
45 while [ $logical -lt $physical ]; do
46 let physical=physical/2
47 let phys_exp=phys_exp+1
49 opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size"
50 echo "scsi_debug options $opts" >> $seq.full
51 modprobe scsi_debug $opts
52 [ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
54 device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
61 lsmod | grep -wq scsi_debug || return
62 rmmod scsi_debug || _fail "Could not remove scsi_debug module"