2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2012 Red Hat, Inc. All Rights Reserved.
7 # Test mkfs.xfs against various types of devices with varying
8 # logical & physical sector sizes and offsets.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
31 # real QA test starts here
39 # Remove xfs signature so -f isn't needed to re-mkfs
43 dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null
48 echo "==================="
49 echo "mkfs with opts: $@" | sed -e "s,$SCSI_DEBUG_DEV,DEVICE,"
50 $MKFS_XFS_PROG $@ 2>/dev/null > $tmp.mkfs.full
56 cat $tmp.mkfs.full | _filter_mkfs >> $seqres.full 2>$tmp.mkfs
58 echo "Got sector size: $sectsz"
59 device=`echo $@ | awk '{print $NF}'`
63 # === 4k physical 512b logical aligned
65 echo "==================="
66 echo "4k physical 512b logical aligned"
67 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128`
68 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
69 # sector size should default to 4k
70 _check_mkfs $SCSI_DEBUG_DEV
71 # blocksize smaller than physical sectorsize should revert to logical sectorsize
72 _check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV
73 ) | tee -a $seqres.full
76 # === 4k physical 512b logical unaligned
78 echo "==================="
79 echo "4k physical 512b logical unaligned"
80 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128`
81 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
82 # should fail on misalignment
83 _check_mkfs $SCSI_DEBUG_DEV
84 # should fall back to logical sector size with force
85 _check_mkfs -f $SCSI_DEBUG_DEV
86 # with 4k sector specified should fail without force
87 _check_mkfs -s size=4096 $SCSI_DEBUG_DEV
88 # with 4k sector specified should fall back to logical sector size with force
89 _check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV
90 ) | tee -a $seqres.full
93 # === hard 4k physical / 4k logical
95 echo "==================="
96 echo "hard 4k physical / 4k logical"
97 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128`
98 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
99 # block size smaller than sector size should fail
100 _check_mkfs -b size=2048 $SCSI_DEBUG_DEV
101 # sector size smaller than physical sector size should fail
102 _check_mkfs -s size=512 $SCSI_DEBUG_DEV
103 ) | tee -a $seqres.full