xfstests 279: test mkfs with various sector sizes & alignments
PATCH 1/1 xfstests 279: test mkfs with various sector sizes & alignments
This test uses the scsi_debug module to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.
Check out the scenarios in the test, I think I have the right outcomes specified...
Hope it's not looking too hacky.
---
279 new file +115 -0
@@ -0,0 +1,115 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets. +# +#----------------------------------------------------------------------- +# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=0 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs +_supported_os Linux + +_require_scsi_debug + +rm -f $seq.full + +_get_sector_size() +{ + xfs_db -c "sb 0" -c "p sectsize" $SCSI_DEBUG_DEV | awk '{print $3}' +} + +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &> /dev/null +} + +_check_mkfs() +{ + echo "===================" | tee -a $seq.full + echo "mkfs with opts: $@" | sed -e "s/\/dev\/sd./DEVICE/" | tee -a $seq.full + mkfs.xfs $@ >> $seq.full 2>&1 + if [ $? -ne 0 ]; then + echo "Failed." | tee -a $seq.full + return + fi + echo "Passed." | tee -a $seq.full + echo -n "Got sector size: " | tee -a $seq.full + _get_sector_size | tee -a $seq.full + device=`echo $@ | awk '{print $NF}'` + _wipe_device $device +} + +# === 4k physical 512b logical aligned +echo "===================" | tee -a $seq.full +echo "4k physical 512b logical aligned" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs "" $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize +_put_scsi_debug_dev + + +# === 4k physical 512b logical unaligned +echo "===================" | tee -a $seq.full +echo "4k physical 512b logical unaligned" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128` +# should fail on misalignment +_check_mkfs "" $SCSI_DEBUG_DEV +# should fall back to logical sector size with force +_check_mkfs -f $SCSI_DEBUG_DEV +# with 4k sector specified should fail without force +_check_mkfs -s size=4096 $SCSI_DEBUG_DEV +# with 4k sector specified should fall back to logical sector size with force +_check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV +_put_scsi_debug_dev + +# === hard 4k physical / 4k logical +echo "===================" | tee -a $seq.full +echo "hard 4k physical / 4k logical" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128` +# block size smaller than sector size should fail +_check_mkfs -b size=2048 $SCSI_DEBUG_DEV +# sector size smaller than physical sector size should fail +_check_mkfs -s size=512 $SCSI_DEBUG_DEV +_put_scsi_debug_dev + +exit
279.out new file +31 -0
@@ -0,0 +1,31 @@ +QA output created by 279 +=================== +4k physical 512b logical aligned +=================== +mkfs with opts: DEVICE +Passed. +Got sector size: 4096 +=================== +4k physical 512b logical unaligned +=================== +mkfs with opts: DEVICE +Failed. +=================== +mkfs with opts: -f DEVICE +Passed. +Got sector size: 512 +=================== +mkfs with opts: -s size=4096 DEVICE +Failed. +=================== +mkfs with opts: -s size=4096 -f DEVICE +Passed. +Got sector size: 4096 +=================== +hard 4k physical / 4k logical +=================== +mkfs with opts: -b size=2048 DEVICE +Failed. +=================== +mkfs with opts: -s size=512 DEVICE +Failed.
common.scsi_debug new file +62 -0
62 lines not on this page · raw message
group +1 -0
@@ -392,3 +392,4 @@ deprecated 276 auto rw metadata 277 auto ioctl quick metadata 278 repair auto +279 auto mkfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 23 lines · Eric Sandeen
This test uses the
scsi_debugmodule to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.Check out the scenarios in the test, I think I have the right outcomes specified...
Hope it's not looking too hacky.
Signed-off-by Eric Sandeen <[email protected]>---
279 new file +5
-0@@ -0,0 +1,115 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets.
....
279 line 32
Quoted 6 lines
279 new file +6
-0+seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=0 # failure is the default!
status=1 means failure is the default....
Quoted 15 lines
279 new file +15
-0+trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs
279 line 57
Quoted 10 lines
279 new file +10
-0+_supported_os Linux + +_require_scsi_debug + +rm -f $seq.full + +_get_sector_size() +{ + xfs_db -c "sb 0" -c "p sectsize" $SCSI_DEBUG_DEV | awk '{print $3}' +}
Hmmm. seems unnecessary - can be got from mkfs output.
279 line 68
Quoted 11 lines
279 new file +11
-0+ +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &> /dev/null +} + +_check_mkfs() +{ + echo "===================" | tee -a $seq.full + echo "mkfs with opts: $@" | sed -e "s/\/dev\/sd./DEVICE/" | tee -a $seq.full
you could use sed's alternative delimiter to avoid needing to escape the path name. i.e | sed -e "s,/dev/sd.,DEVICE,"
279 line 69
Quoted 1 line
279 new file +1
-0+ mkfs.xfs $@ >> $seq.full 2>&1
mkfs.xfs $@ | tee -a $seq.full | filter_mkfs 2> $tmp.mkfs
279 line 75
Quoted 8 lines
279 new file +6
-0+ if [ $? -ne 0 ]; then + echo "Failed." | tee -a $seq.full + return + fi + echo "Passed." | tee -a $seq.full + echo -n "Got sector size: " | tee -a $seq.full
. $tmp.mkfs
echo -n "Got sector size: $sectsz " | tee -a $seq.full
279 line 78
Quoted 3 lines
279 new file +3
-0+ _get_sector_size | tee -a $seq.full + device=`echo $@ | awk '{print $NF}'` + _wipe_device $device
Not sure what this is supposed to do. The awk statement prints the number of fields in the input record, and _wipe_device uses that as a file name? What am I missing?
Quoted 1 line
+}
pretty much the entire output of this function is teed to $seq.full. You could do that at the call site. i.e.
_check_mkfs .... | tee -a $seq.full
Even better:
279 line 87
Quoted 8 lines
279 new file +8
-0+ +# === 4k physical 512b logical aligned +echo "===================" | tee -a $seq.full +echo "4k physical 512b logical aligned" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs "" $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize
(missing a test case here?)
Quoted 1 line
+_put_scsi_debug_dev
(
echo "==================="
echo "4k physical 512b logical aligned" SCSI_DEBUG_DEV=_get_scsi_debug_dev 4096 512 0 128
# sector size should default to 4k
_check_mkfs "" $SCSI_DEBUG_DEV
# blocksize smaller than physical sectorsize should revert to logical sectorsize _put_scsi_debug_dev
) | tee -a $seq.full
.....
279
Quoted 2 lines
279 new file +2
-0+ +exit
status=0
exit
279
Quoted 12 lines
279 new file +12
-0+# Functions useful for tests on unique block devices +# + +_require_scsi_debug() +{ + # make sure we have the module and it's not already used + modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found" + lsmod | grep -wq scsi_debug && _notrun "scsi_debug module in use" + # make sure it has the features we need + # logical/physical sectors plus unmap support all went in together + modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old" +}
Might work for modules, but what about CONFIG_SCSI_DEBUG=y? I thought you could do all this configuration stuff through the /sys/bus/scsi/drivers/scsi_debug interface so you didn't need to screw with modules and parameters?
Quoted 19 lines
279 new file +19
-0+ +# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]] +_get_scsi_debug_dev() +{ + # Defaults to phys 512, logical 512, aligned + physical=${1-512} + logical=${2-512} + unaligned=${3-0} + size=${4-128} + + phys_exp=0 + while [ $logical -lt $physical ]; do + let physical=physical/2 + let phys_exp=phys_exp+1 + done + opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size" + echo "scsi_debug options $opts" >> $seq.full + modprobe scsi_debug $opts + [ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
279
Quoted 10 lines
279 new file +10
-0+ sleep 1 + device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'` + echo "/dev/$device" +} + +_put_scsi_debug_dev() +{ + sleep 1 + rmmod scsi_debug || _fail "Could not remove scsi_debug module" +}
What is the sleep for?
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 25 lines · Dave Chinner
Quoted 23 lines · Eric Sandeen
This test uses the
scsi_debugmodule to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.Check out the scenarios in the test, I think I have the right outcomes specified...
Hope it's not looking too hacky.
Signed-off-by Eric Sandeen <[email protected]>---
279 new file +5
-0@@ -0,0 +1,115 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets.....
Quoted 8 lines
279 line 32
Quoted 6 lines
279 new file +6
-0+seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=0 # failure is the default!status=1 means failure is the default....
stupid cut & paste....
Quoted 19 lines
Quoted 19 lines
279 new file +19
-0+trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs +_supported_os Linux + +_require_scsi_debug +
Quoted 8 lines
279 line 57
Quoted 6 lines
279 new file +6
-0+rm -f $seq.full + +_get_sector_size() +{ + xfs_db -c "sb 0" -c "p sectsize" $SCSI_DEBUG_DEV | awk '{print $3}' +}Hmmm. seems unnecessary - can be got from mkfs output.
Thanks, forgot about that trick.
Quoted 6 lines
Quoted 6 lines
279 new file +6
-0+ +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &> /dev/null +}
Quoted 8 lines
279 line 68
Quoted 5 lines
279 new file +5
-0+ +_check_mkfs() +{ + echo "===================" | tee -a $seq.full + echo "mkfs with opts: $@" | sed -e "s/\/dev\/sd./DEVICE/" | tee -a $seq.fullyou could use sed's alternative delimiter to avoid needing to escape the path name. i.e | sed -e "s,/dev/sd.,DEVICE,"
good idea.
Quoted 16 lines
279 line 69
Quoted 1 line
279 new file +1
-0+ mkfs.xfs $@ >> $seq.full 2>&1mkfs.xfs $@ | tee -a $seq.full |
filter_mkfs2> $tmp.mkfs279 line 75
Quoted 8 lines
279 new file +6
-0+ if [ $? -ne 0 ]; then + echo "Failed." | tee -a $seq.full + return + fi + echo "Passed." | tee -a $seq.full + echo -n "Got sector size: " | tee -a $seq.full. $tmp.mkfs
echo -n "Got sector size: $sectsz " | tee -a $seq.full
Quoted 7 lines
279 line 78
Quoted 3 lines
279 new file +3
-0+ _get_sector_size | tee -a $seq.full + device=`echo $@ | awk '{print $NF}'` + _wipe_device $deviceNot sure what this is supposed to do. The awk statement prints the number of fields in the input record, and
_wipe_deviceuses that as a file name? What am I missing?
that '{print $NF}' prints the last field...
Quoted 9 lines
Quoted 1 line
+}
pretty much the entire output of this function is teed to $seq.full. You could do that at the call site. i.e.
_check_mkfs .... | tee -a $seq.fullEven better:
Quoted 10 lines
279 line 87
Quoted 8 lines
279 new file +8
-0+ +# === 4k physical 512b logical aligned +echo "===================" | tee -a $seq.full +echo "4k physical 512b logical aligned" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs "" $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize(missing a test case here?)
yep
Quoted 11 lines
Quoted 1 line
+_put_scsi_debug_dev
(
echo "==================="
echo "4k physical 512b logical aligned" SCSI_DEBUG_DEV=_get_scsi_debug_dev 4096 512 0 128
# sector size should default to 4k
_check_mkfs"" $SCSI_DEBUG_DEV
# blocksize smaller than physical sectorsize should revert to logical sectorsize_put_scsi_debug_dev
) | tee -a $seq.full
ok... will see if I can get the right stuff to the right place ...
Quoted 16 lines
.....
279
Quoted 2 lines
279 new file +2
-0+ +exitstatus=0
exitQuoted 9 lines
279 new file +9
-0+# Functions useful for tests on unique block devices +# + +_require_scsi_debug() +{ + # make sure we have the module and it's not already used + modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found" + lsmod | grep -wq scsi_debug && _notrun "scsi_debug module in use" + # make sure it has the features we need
Quoted 8 lines
279
Quoted 3 lines
279 new file +3
-0+ # logical/physical sectors plus unmap support all went in together + modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old" +}Might work for modules, but what about
CONFIG_SCSI_DEBUG=y? I thought you could do all this configuration stuff through the/sys/bus/scsi/drivers/scsi_debuginterface so you didn't need to screw with modules and parameters?
sigh, have to handle them both I suppose.
/sys/bus/pseudo/drivers/scsi_debug actually...
# ls /sys/bus/pseudo/drivers/scsi_debug/ adapter0 bind dif every_nth map no_lun_0 num_tgts scsi_level unbind add_host delay dix fake_rw max_luns no_uld opts sector_size virtual_gb ato dev_size_mb dsense guard max_queue num_parts ptype uevent vpd_use_hostno
not sure offhand how to do things like set alignment there.
Quoted 23 lines
Quoted 23 lines
279 new file +23
-0+ +# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]] +_get_scsi_debug_dev() +{ + # Defaults to phys 512, logical 512, aligned + physical=${1-512} + logical=${2-512} + unaligned=${3-0} + size=${4-128} + + phys_exp=0 + while [ $logical -lt $physical ]; do + let physical=physical/2 + let phys_exp=phys_exp+1 + done + opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size" + echo "scsi_debug options $opts" >> $seq.full + modprobe scsi_debug $opts + [ $? -eq 0 ] || _fail "scsi_debug modprobe failed" + sleep 1 + device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'` + echo "/dev/$device" +}
Quoted 8 lines
279
Quoted 6 lines
279 new file +6
-0+ +_put_scsi_debug_dev() +{ + sleep 1 + rmmod scsi_debug || _fail "Could not remove scsi_debug module" +}What is the sleep for?
Module stays busy w/o it and the rmmod fails, not sure why offhand.... which probably makes it not very robust :)
-Eric
Quoted 3 lines
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 11 lines · Eric Sandeen
Quoted 8 lines · Dave Chinner
279 line 78
Quoted 3 lines · Eric Sandeen
279 new file +3
-0+ _get_sector_size | tee -a $seq.full + device=`echo $@ | awk '{print $NF}'` + _wipe_device $deviceNot sure what this is supposed to do. The awk statement prints the number of fields in the input record, and
_wipe_deviceuses that as a file name? What am I missing?that '{print $NF}' prints the last field...
/me slaps forehead. NF and $NF give different things..
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
common.scsi_debug new file +9
-0+# Functions useful for tests on unique block devices +# + +_require_scsi_debug() +{ + # make sure we have the module and it's not already used + modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found" + lsmod | grep -wq scsi_debug && _notrun "scsi_debug module in use" + # make sure it has the features we needQuoted 8 lines
common.scsi_debug line 33
Quoted 3 lines
common.scsi_debug new file +3
-0+ # logical/physical sectors plus unmap support all went in together + modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old" +}Might work for modules, but what about
CONFIG_SCSI_DEBUG=y? I thought you could do all this configuration stuff through the/sys/bus/scsi/drivers/scsi_debuginterface so you didn't need to screw with modules and parameters?
Quoted 1 line
sigh, have to handle them both I suppose.
Actaully, having looked at this, don't bother. Just use the module version. Adding CONFIG_SCSI_DEBUG=y makes your system fail to boot if you have /dev/sdaX entries as your boot device. The scsi debug device becomes /dev/sda, and funnily enough stuff stops working because /dev/sda2 isn't the root filesystem anymore...
Quoted 10 lines
Quoted 7 lines
common.scsi_debug line 62
Quoted 5 lines
common.scsi_debug new file +5
-0+_put_scsi_debug_dev() +{ + sleep 1 + rmmod scsi_debug || _fail "Could not remove scsi_debug module" +}What is the sleep for?
Module stays busy w/o it and the rmmod fails, not sure why offhand.... which probably makes it not very robust :)
Hmmm. We don't have any active references to it after mkfs exists. Seems kind of strange. I've seen similar things with blkid running probes in the background due to udev events when the device is first created. Given that we are just running a mkfs on it, the lifetime of the device is under a second, right? Perhaps adding a udev_settle call after doing the modprobe might solve this....
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v2 1/1 xfstests 279: test mkfs with various sector sizes & alignments
In reply to Eric SandeenThis test uses the scsi_debug module to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.
---
Dave, I think this implements all your suggestions (in one way or another...) except the non-modular scsi_debug. I don't know how to manipulate things like offset if it's built in, but if you want to look... I don't see it.
279 new file +120 -0
@@ -0,0 +1,120 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets. +# +#----------------------------------------------------------------------- +# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs +_supported_os Linux + +_require_scsi_debug + +rm -f $seq.full + +# Remove xfs signature so -f isn't needed to re-mkfs +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null +} + +_check_mkfs() +{ + echo "===================" + echo "mkfs with opts: $@" | sed -e "s,/dev/sd.,DEVICE," + mkfs.xfs $@ 2>/dev/null > $tmp.mkfs.full + if [ $? -ne 0 ]; then + echo "Failed." + return + fi + echo "Passed." + cat $tmp.mkfs.full | _filter_mkfs >> $seq.full 2>$tmp.mkfs + . $tmp.mkfs + echo "Got sector size: $sectsz" + device=`echo $@ | awk '{print $NF}'` + _wipe_device $device +} + +# === 4k physical 512b logical aligned +( +echo "===================" +echo "4k physical 512b logical aligned" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize +_check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + + +# === 4k physical 512b logical unaligned +( +echo "===================" | tee -a $seq.full +echo "4k physical 512b logical unaligned" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128` +# should fail on misalignment +_check_mkfs $SCSI_DEBUG_DEV +# should fall back to logical sector size with force +_check_mkfs -f $SCSI_DEBUG_DEV +# with 4k sector specified should fail without force +_check_mkfs -s size=4096 $SCSI_DEBUG_DEV +# with 4k sector specified should fall back to logical sector size with force +_check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +# === hard 4k physical / 4k logical +( +echo "===================" | tee -a $seq.full +echo "hard 4k physical / 4k logical" | tee -a $seq.full +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128` +# block size smaller than sector size should fail +_check_mkfs -b size=2048 $SCSI_DEBUG_DEV +# sector size smaller than physical sector size should fail +_check_mkfs -s size=512 $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +status=0 +exit
279.out new file +35 -0
@@ -0,0 +1,35 @@ +QA output created by 279 +=================== +4k physical 512b logical aligned +=================== +mkfs with opts: DEVICE +Passed. +Got sector size: 4096 +=================== +mkfs with opts: -b size=2048 -f DEVICE +Passed. +Got sector size: 512 +=================== +4k physical 512b logical unaligned +=================== +mkfs with opts: DEVICE +Failed. +=================== +mkfs with opts: -f DEVICE +Passed. +Got sector size: 512 +=================== +mkfs with opts: -s size=4096 DEVICE +Failed. +=================== +mkfs with opts: -s size=4096 -f DEVICE +Passed. +Got sector size: 4096 +=================== +hard 4k physical / 4k logical +=================== +mkfs with opts: -b size=2048 DEVICE +Failed. +=================== +mkfs with opts: -s size=512 DEVICE +Failed.
common.scsi_debug new file +62 -0
62 lines not on this page · raw message
group +1 -0
@@ -392,3 +392,4 @@ deprecated 276 auto rw metadata 277 auto ioctl quick metadata 278 repair auto +279 auto mkfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v3 1/1 xfstests 279: test mkfs with various sector sizes & alignments
This test uses the scsi_debug module to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.
---
Dave, I think this implements all your suggestions (in one way or another...) except the non-modular scsi_debug. I don't know how to manipulate things like offset if it's built in, but if you want to look... I don't see it.
V3: remove a couple stray/extra "tee" commands
I looked into doing a generic version of this but I think without the sector size checking unique to xfs it's a little pointless.
279 new file +120 -0
@@ -0,0 +1,120 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets. +# +#----------------------------------------------------------------------- +# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + _put_scsi_debug_dev +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs +_supported_os Linux + +_require_scsi_debug + +rm -f $seq.full + +# Remove xfs signature so -f isn't needed to re-mkfs +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null +} + +_check_mkfs() +{ + echo "===================" + echo "mkfs with opts: $@" | sed -e "s,/dev/sd.,DEVICE," + /sbin/mkfs.xfs $@ 2>/dev/null > $tmp.mkfs.full + if [ $? -ne 0 ]; then + echo "Failed." + return + fi + echo "Passed." + cat $tmp.mkfs.full | _filter_mkfs >> $seq.full 2>$tmp.mkfs + . $tmp.mkfs + echo "Got sector size: $sectsz" + device=`echo $@ | awk '{print $NF}'` + _wipe_device $device +} + +# === 4k physical 512b logical aligned +( +echo "===================" +echo "4k physical 512b logical aligned" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize +_check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +# === 4k physical 512b logical unaligned +( +echo "===================" +echo "4k physical 512b logical unaligned" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128` +# should fail on misalignment +_check_mkfs $SCSI_DEBUG_DEV +# should fall back to logical sector size with force +_check_mkfs -f $SCSI_DEBUG_DEV +# with 4k sector specified should fail without force +_check_mkfs -s size=4096 $SCSI_DEBUG_DEV +# with 4k sector specified should fall back to logical sector size with force +_check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +# === hard 4k physical / 4k logical +( +echo "===================" +echo "hard 4k physical / 4k logical" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128` +# block size smaller than sector size should fail +_check_mkfs -b size=2048 $SCSI_DEBUG_DEV +# sector size smaller than physical sector size should fail +_check_mkfs -s size=512 $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +status=0 +exit
279.out new file +35 -0
@@ -0,0 +1,35 @@ +QA output created by 279 +=================== +4k physical 512b logical aligned +=================== +mkfs with opts: DEVICE +Passed. +Got sector size: 4096 +=================== +mkfs with opts: -b size=2048 -f DEVICE +Passed. +Got sector size: 512 +=================== +4k physical 512b logical unaligned +=================== +mkfs with opts: DEVICE +Failed. +=================== +mkfs with opts: -f DEVICE +Passed. +Got sector size: 512 +=================== +mkfs with opts: -s size=4096 DEVICE +Failed. +=================== +mkfs with opts: -s size=4096 -f DEVICE +Passed. +Got sector size: 4096 +=================== +hard 4k physical / 4k logical +=================== +mkfs with opts: -b size=2048 DEVICE +Failed. +=================== +mkfs with opts: -s size=512 DEVICE +Failed.
common.scsi_debug new file +62 -0
62 lines not on this page · raw message
group +1 -0
@@ -392,3 +392,4 @@ deprecated 276 auto rw metadata 277 auto ioctl quick metadata 278 repair auto +279 auto mkfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 12 lines · Eric Sandeen
This test uses the
scsi_debugmodule to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.Signed-off-by Eric Sandeen <[email protected]>---
Dave, I think this implements all your suggestions (in one way or another...) except the non-modular
scsi_debug. I don't know how to manipulate things like offset if it's built in, but if you want to look... I don't see it.
Quoted 4 lines
V3: remove a couple stray/extra "tee" commands
I looked into doing a generic version of this but I think without the sector size checking unique to xfs it's a little pointless.
Dave, think this is ok now?
Thanks,
-Eric
Quoted 245 lines
279 new file +120
-0@@ -0,0 +1,120 @@ +#! /bin/bash +# FS QA Test No. 279 +# +# Test mkfs.xfs against various types of devices with varying +# logical & physical sector sizes and offsets. +# +#----------------------------------------------------------------------- +# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + _put_scsi_debug_dev +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.scsi_debug + +# real QA test starts here +_supported_fs xfs +_supported_os Linux + +_require_scsi_debug + +rm -f $seq.full + +# Remove xfs signature so -f isn't needed to re-mkfs +_wipe_device() +{ + device=$1 + dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null +} + +_check_mkfs() +{ + echo "===================" + echo "mkfs with opts: $@" | sed -e "s,/dev/sd.,DEVICE," + /sbin/mkfs.xfs $@ 2>/dev/null > $tmp.mkfs.full + if [ $? -ne 0 ]; then + echo "Failed." + return + fi + echo "Passed." + cat $tmp.mkfs.full | _filter_mkfs >> $seq.full 2>$tmp.mkfs + . $tmp.mkfs + echo "Got sector size: $sectsz" + device=`echo $@ | awk '{print $NF}'` + _wipe_device $device +} + +# === 4k physical 512b logical aligned +( +echo "===================" +echo "4k physical 512b logical aligned" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128` +# sector size should default to 4k +_check_mkfs $SCSI_DEBUG_DEV +# blocksize smaller than physical sectorsize should revert to logical sectorsize +_check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +# === 4k physical 512b logical unaligned +( +echo "===================" +echo "4k physical 512b logical unaligned" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128` +# should fail on misalignment +_check_mkfs $SCSI_DEBUG_DEV +# should fall back to logical sector size with force +_check_mkfs -f $SCSI_DEBUG_DEV +# with 4k sector specified should fail without force +_check_mkfs -s size=4096 $SCSI_DEBUG_DEV +# with 4k sector specified should fall back to logical sector size with force +_check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +# === hard 4k physical / 4k logical +( +echo "===================" +echo "hard 4k physical / 4k logical" +SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128` +# block size smaller than sector size should fail +_check_mkfs -b size=2048 $SCSI_DEBUG_DEV +# sector size smaller than physical sector size should fail +_check_mkfs -s size=512 $SCSI_DEBUG_DEV +) | tee -a $seq.full +_put_scsi_debug_dev + +status=0 +exit279.out new file +35
-0@@ -0,0 +1,35 @@ +QA output created by 279 +=================== +4k physical 512b logical aligned +=================== +mkfs with opts: DEVICE +Passed. +Got sector size: 4096 +=================== +mkfs with opts: -b size=2048 -f DEVICE +Passed. +Got sector size: 512 +=================== +4k physical 512b logical unaligned +=================== +mkfs with opts: DEVICE +Failed. +=================== +mkfs with opts: -f DEVICE +Passed. +Got sector size: 512 +=================== +mkfs with opts: -s size=4096 DEVICE +Failed. +=================== +mkfs with opts: -s size=4096 -f DEVICE +Passed. +Got sector size: 4096 +=================== +hard 4k physical / 4k logical +=================== +mkfs with opts: -b size=2048 DEVICE +Failed. +=================== +mkfs with opts: -s size=512 DEVICE +Failed.common.scsi_debug new file +62
-0@@ -0,0 +1,62 @@ +##/bin/bash +# +# Copyright (c) 2012 Red Hat, Inc +# All Rights Reserved. +# +# Written by Eric Sandeen <[email protected]> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# +# Functions useful for tests on unique block devices +# + +_require_scsi_debug() +{ + # make sure we have the module and it's not already used + modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found" + lsmod | grep -wq scsi_debug && _notrun "scsi_debug module in use" + # make sure it has the features we need + # logical/physical sectors plus unmap support all went in together + modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old" +} + +# Args: [physical sector size, [logical sector size, [unaligned(0|1), [size in megs]]]] +_get_scsi_debug_dev() +{ + # Defaults to phys 512, logical 512, aligned + physical=${1-512} + logical=${2-512} + unaligned=${3-0} + size=${4-128} + + phys_exp=0 + while [ $logical -lt $physical ]; do + let physical=physical/2 + let phys_exp=phys_exp+1 + done + opts="sector_size=$logical physblk_exp=$phys_exp lowest_aligned=$unaligned dev_size_mb=$size" + echo "scsi_debug options $opts" >> $seq.full + modprobe scsi_debug $opts + [ $? -eq 0 ] || _fail "scsi_debug modprobe failed" + sleep 1 + device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'` + echo "/dev/$device" +} + +_put_scsi_debug_dev() +{ + sleep 1 + rmmod scsi_debug || _fail "Could not remove scsi_debug module" +}group +1
-0@@ -392,3 +392,4 @@ deprecated 276 auto rw metadata 277 auto ioctl quick metadata 278 repair auto +279 auto mkfs
Quoted 5 lines
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Dave Chinner
Reviewed-byQuoted 13 lines · Eric Sandeen
Quoted 12 lines · Eric Sandeen
This test uses the
scsi_debugmodule to test mkfs against various physical & logical sector sizes, and with aligned and unaligned devices.Signed-off-by Eric Sandeen <[email protected]>---
Dave, I think this implements all your suggestions (in one way or another...) except the non-modular
scsi_debug. I don't know how to manipulate things like offset if it's built in, but if you want to look... I don't see it.
Quoted 6 lines
Quoted 4 lines
V3: remove a couple stray/extra "tee" commands
I looked into doing a generic version of this but I think without the sector size checking unique to xfs it's a little pointless.
Dave, think this is ok now?
Yup.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs