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
38 # Remove xfs signature so -f isn't needed to re-mkfs
42 dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null
47 echo "==================="
48 echo "mkfs with opts: $@" | sed -e "s,$SCSI_DEBUG_DEV,DEVICE,"
49 $MKFS_XFS_PROG $@ 2>/dev/null > $tmp.mkfs.full
55 cat $tmp.mkfs.full | _filter_mkfs >> $seqres.full 2>$tmp.mkfs
57 echo "Got sector size: $sectsz"
58 device=`echo $@ | awk '{print $NF}'`
62 # === 4k physical 512b logical aligned
64 echo "==================="
65 echo "4k physical 512b logical aligned"
66 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128`
67 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
68 # sector size should default to 4k
69 _check_mkfs $SCSI_DEBUG_DEV
70 # blocksize smaller than physical sectorsize should revert to logical sectorsize
71 _check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV
72 ) | tee -a $seqres.full
75 # === 4k physical 512b logical unaligned
77 echo "==================="
78 echo "4k physical 512b logical unaligned"
79 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128`
80 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
81 # should fail on misalignment
82 _check_mkfs $SCSI_DEBUG_DEV
83 # should fall back to logical sector size with force
84 _check_mkfs -f $SCSI_DEBUG_DEV
85 # with 4k sector specified should fail without force
86 _check_mkfs -s size=4096 $SCSI_DEBUG_DEV
87 # with 4k sector specified should fall back to logical sector size with force
88 _check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV
89 ) | tee -a $seqres.full
92 # === hard 4k physical / 4k logical
94 echo "==================="
95 echo "hard 4k physical / 4k logical"
96 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128`
97 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
98 # block size smaller than sector size should fail
99 _check_mkfs -b size=2048 $SCSI_DEBUG_DEV
100 # sector size smaller than physical sector size should fail
101 _check_mkfs -s size=512 $SCSI_DEBUG_DEV
102 ) | tee -a $seqres.full