xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / xfs / 279
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2012 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 279
6 #
7 # Test mkfs.xfs against various types of devices with varying
8 # logical & physical sector sizes and offsets.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -f $tmp.*
23     _put_scsi_debug_dev
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/scsi_debug
30
31 # real QA test starts here
32 _supported_fs xfs
33
34 _require_scsi_debug
35
36 rm -f $seqres.full
37
38 # Remove xfs signature so -f isn't needed to re-mkfs
39 _wipe_device()
40 {
41         device=$1
42         dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null
43 }
44
45 _check_mkfs()
46 {
47         echo "===================" 
48         echo "mkfs with opts: $@" | sed -e "s,$SCSI_DEBUG_DEV,DEVICE,"
49         $MKFS_XFS_PROG $@ 2>/dev/null > $tmp.mkfs.full
50         if [ $? -ne 0 ]; then
51                 echo "Failed."
52                 return
53         fi
54         echo "Passed."
55         cat $tmp.mkfs.full | _filter_mkfs >> $seqres.full 2>$tmp.mkfs
56         . $tmp.mkfs
57         echo "Got sector size: $sectsz"
58         device=`echo $@ | awk '{print $NF}'`
59         _wipe_device $device
60 }
61
62 # === 4k physical 512b logical aligned
63 (
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
73 _put_scsi_debug_dev
74
75 # === 4k physical 512b logical unaligned
76 (
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
90 _put_scsi_debug_dev
91
92 # === hard 4k physical / 4k logical
93 (
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
103 _put_scsi_debug_dev
104
105 status=0
106 exit