public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfstests 279: test mkfs with various sector sizes & alignments
@ 2012-03-01 23:27 Eric Sandeen
  2012-03-02  0:15 ` Dave Chinner
  2012-03-02  4:07 ` [PATCH V2] " Eric Sandeen
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Sandeen @ 2012-03-01 23:27 UTC (permalink / raw)
  To: xfs-oss

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.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/279 b/279
new file mode 100755
index 0000000..b7ad622
--- /dev/null
+++ b/279
@@ -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
+owner=sandeen@redhat.com
+
+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
diff --git a/279.out b/279.out
new file mode 100644
index 0000000..f7734e0
--- /dev/null
+++ b/279.out
@@ -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.
diff --git a/common.scsi_debug b/common.scsi_debug
new file mode 100644
index 0000000..9f9177c
--- /dev/null
+++ b/common.scsi_debug
@@ -0,0 +1,62 @@
+##/bin/bash
+#
+# Copyright (c) 2012 Red Hat, Inc
+# All Rights Reserved.
+#
+# Written by Eric Sandeen <sandeen@redhat.com>
+#
+# 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"
+}
diff --git a/group b/group
index 6f2d748..7a91f41 100644
--- a/group
+++ b/group
@@ -392,3 +392,4 @@ deprecated
 276 auto rw metadata
 277 auto ioctl quick metadata
 278 repair auto
+279 auto mkfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-01 23:27 [PATCH] xfstests 279: test mkfs with various sector sizes & alignments Eric Sandeen
@ 2012-03-02  0:15 ` Dave Chinner
  2012-03-02  3:46   ` Eric Sandeen
  2012-03-02  4:07 ` [PATCH V2] " Eric Sandeen
  1 sibling, 1 reply; 8+ messages in thread
From: Dave Chinner @ 2012-03-02  0:15 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On Thu, Mar 01, 2012 at 05:27:13PM -0600, Eric Sandeen wrote:
> 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.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/279 b/279
> new file mode 100755
> index 0000000..b7ad622
> --- /dev/null
> +++ b/279
> @@ -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.
....
> +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....

> +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}'
> +}

Hmmm. seems unnecessary - can be got from mkfs output.

> +
> +_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,"

> +	mkfs.xfs $@ >> $seq.full 2>&1

mkfs.xfs $@ | tee -a $seq.full | filter_mkfs 2> $tmp.mkfs

> +	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

> +	_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?

> +}

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:

> +
> +# === 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?)

> +_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

.....
> +
> +exit

status=0
exit

> +# 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?

> +
> +# 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"
> +}

What is the sleep for?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-02  0:15 ` Dave Chinner
@ 2012-03-02  3:46   ` Eric Sandeen
  2012-03-02  4:28     ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2012-03-02  3:46 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Eric Sandeen, xfs-oss

On 3/1/12 6:15 PM, Dave Chinner wrote:
> On Thu, Mar 01, 2012 at 05:27:13PM -0600, Eric Sandeen wrote:
>> 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.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/279 b/279
>> new file mode 100755
>> index 0000000..b7ad622
>> --- /dev/null
>> +++ b/279
>> @@ -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.
> ....
>> +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....

>> +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}'
>> +}
> 
> Hmmm. seems unnecessary - can be got from mkfs output.

Thanks, forgot about that trick.

>> +
>> +_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,"

good idea.

>> +	mkfs.xfs $@ >> $seq.full 2>&1
> 
> mkfs.xfs $@ | tee -a $seq.full | filter_mkfs 2> $tmp.mkfs
> 
>> +	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
> 
>> +	_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?

that '{print $NF}' prints the last field...

>> +}
> 
> 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:
> 
>> +
>> +# === 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

>> +_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 ...

> .....
>> +
>> +exit
> 
> status=0
> exit
> 
>> +# 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?

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.

>> +
>> +# 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"
>> +}
> 
> 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

> Cheers,
> 
> Dave.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH V2] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-01 23:27 [PATCH] xfstests 279: test mkfs with various sector sizes & alignments Eric Sandeen
  2012-03-02  0:15 ` Dave Chinner
@ 2012-03-02  4:07 ` Eric Sandeen
  2012-03-02 16:58   ` [PATCH V3] " Eric Sandeen
  1 sibling, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2012-03-02  4:07 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

This test uses the scsi_debug module to test mkfs against
various physical & logical sector sizes, and with aligned
and unaligned devices.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

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.

diff --git a/279 b/279
new file mode 100755
index 0000000..dea7fa7
--- /dev/null
+++ b/279
@@ -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
+owner=sandeen@redhat.com
+
+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
diff --git a/279.out b/279.out
new file mode 100644
index 0000000..5c49846
--- /dev/null
+++ b/279.out
@@ -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.
diff --git a/common.scsi_debug b/common.scsi_debug
new file mode 100644
index 0000000..9f9177c
--- /dev/null
+++ b/common.scsi_debug
@@ -0,0 +1,62 @@
+##/bin/bash
+#
+# Copyright (c) 2012 Red Hat, Inc
+# All Rights Reserved.
+#
+# Written by Eric Sandeen <sandeen@redhat.com>
+#
+# 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"
+}
diff --git a/group b/group
index 6f2d748..7a91f41 100644
--- a/group
+++ b/group
@@ -392,3 +392,4 @@ deprecated
 276 auto rw metadata
 277 auto ioctl quick metadata
 278 repair auto
+279 auto mkfs


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-02  3:46   ` Eric Sandeen
@ 2012-03-02  4:28     ` Dave Chinner
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2012-03-02  4:28 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Eric Sandeen, xfs-oss

On Thu, Mar 01, 2012 at 09:46:07PM -0600, Eric Sandeen wrote:
> On 3/1/12 6:15 PM, Dave Chinner wrote:
> > On Thu, Mar 01, 2012 at 05:27:13PM -0600, Eric Sandeen wrote:
> >> +	_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?
> 
> that '{print $NF}' prints the last field...

/me slaps forehead. NF and $NF give different things..

> >> +# 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?
> 
> 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...

> >> +_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.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH V3] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-02  4:07 ` [PATCH V2] " Eric Sandeen
@ 2012-03-02 16:58   ` Eric Sandeen
  2012-03-08 22:25     ` Eric Sandeen
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2012-03-02 16:58 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

This test uses the scsi_debug module to test mkfs against
various physical & logical sector sizes, and with aligned
and unaligned devices.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

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.

diff --git a/279 b/279
new file mode 100755
index 0000000..7d30251
--- /dev/null
+++ b/279
@@ -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
+owner=sandeen@redhat.com
+
+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
diff --git a/279.out b/279.out
new file mode 100644
index 0000000..5c49846
--- /dev/null
+++ b/279.out
@@ -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.
diff --git a/common.scsi_debug b/common.scsi_debug
new file mode 100644
index 0000000..9f9177c
--- /dev/null
+++ b/common.scsi_debug
@@ -0,0 +1,62 @@
+##/bin/bash
+#
+# Copyright (c) 2012 Red Hat, Inc
+# All Rights Reserved.
+#
+# Written by Eric Sandeen <sandeen@redhat.com>
+#
+# 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"
+}
diff --git a/group b/group
index 6f2d748..7a91f41 100644
--- a/group
+++ b/group
@@ -392,3 +392,4 @@ deprecated
 276 auto rw metadata
 277 auto ioctl quick metadata
 278 repair auto
+279 auto mkfs

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH V3] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-02 16:58   ` [PATCH V3] " Eric Sandeen
@ 2012-03-08 22:25     ` Eric Sandeen
  2012-03-08 23:11       ` Dave Chinner
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Sandeen @ 2012-03-08 22:25 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs-oss

On 3/2/12 10:58 AM, Eric Sandeen wrote:
> This test uses the scsi_debug module to test mkfs against
> various physical & logical sector sizes, and with aligned
> and unaligned devices.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> 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.

Dave, think this is ok now?

Thanks,
-Eric

> diff --git a/279 b/279
> new file mode 100755
> index 0000000..7d30251
> --- /dev/null
> +++ b/279
> @@ -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
> +owner=sandeen@redhat.com
> +
> +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
> diff --git a/279.out b/279.out
> new file mode 100644
> index 0000000..5c49846
> --- /dev/null
> +++ b/279.out
> @@ -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.
> diff --git a/common.scsi_debug b/common.scsi_debug
> new file mode 100644
> index 0000000..9f9177c
> --- /dev/null
> +++ b/common.scsi_debug
> @@ -0,0 +1,62 @@
> +##/bin/bash
> +#
> +# Copyright (c) 2012 Red Hat, Inc
> +# All Rights Reserved.
> +#
> +# Written by Eric Sandeen <sandeen@redhat.com>
> +#
> +# 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"
> +}
> diff --git a/group b/group
> index 6f2d748..7a91f41 100644
> --- a/group
> +++ b/group
> @@ -392,3 +392,4 @@ deprecated
>  276 auto rw metadata
>  277 auto ioctl quick metadata
>  278 repair auto
> +279 auto mkfs
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH V3] xfstests 279: test mkfs with various sector sizes & alignments
  2012-03-08 22:25     ` Eric Sandeen
@ 2012-03-08 23:11       ` Dave Chinner
  0 siblings, 0 replies; 8+ messages in thread
From: Dave Chinner @ 2012-03-08 23:11 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Eric Sandeen, xfs-oss

On Thu, Mar 08, 2012 at 04:25:03PM -0600, Eric Sandeen wrote:
> On 3/2/12 10:58 AM, Eric Sandeen wrote:
> > This test uses the scsi_debug module to test mkfs against
> > various physical & logical sector sizes, and with aligned
> > and unaligned devices.
> > 
> > Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> > ---
> > 
> > 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.
> 
> Dave, think this is ok now?

Yup.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-03-08 23:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-01 23:27 [PATCH] xfstests 279: test mkfs with various sector sizes & alignments Eric Sandeen
2012-03-02  0:15 ` Dave Chinner
2012-03-02  3:46   ` Eric Sandeen
2012-03-02  4:28     ` Dave Chinner
2012-03-02  4:07 ` [PATCH V2] " Eric Sandeen
2012-03-02 16:58   ` [PATCH V3] " Eric Sandeen
2012-03-08 22:25     ` Eric Sandeen
2012-03-08 23:11       ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox