tests: remove udf/101
[xfstests-dev.git] / tests / generic / 351
1 #! /bin/bash
2 # FS QA Test No. 351
3 #
4 # Test the unsupported fallocate flags on a block device.  No collapse
5 # or insert range, no regular fallocate, no forgetting keep-space on
6 # zero range, no punching past EOD, no requests that aren't aligned
7 # with the logicalsector size, and make sure the fallbacks work for
8 # devices that don't support write_same or discard.
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #-----------------------------------------------------------------------
26 #
27
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 7 15
36
37 _cleanup()
38 {
39     cd /
40     rm -rf $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46 . ./common/scsi_debug
47
48 # real QA test starts here
49 _supported_os Linux
50 _require_scsi_debug
51 _require_xfs_io_command "falloc"
52 _require_xfs_io_command "finsert"
53 _require_xfs_io_command "fcollapse"
54 _require_xfs_io_command "fzero"
55 _require_xfs_io_command "fpunch"
56
57
58 echo "Create and format"
59 dev=$(_get_scsi_debug_dev 4096 4096 0 4 "lbpws=1 lbpws10=1")
60 _pwrite_byte 0x62 0 4m $dev >> $seqres.full
61 $XFS_IO_PROG -c "fsync" $dev
62
63 echo "Regular fallocate"
64 $XFS_IO_PROG -c "falloc 64k 64k" $dev
65
66 echo "Insert range"
67 $XFS_IO_PROG -c "finsert 128k 64k" $dev
68
69 echo "Collapse range"
70 $XFS_IO_PROG -c "fcollapse 256k 64k" $dev
71
72 echo "Unaligned zero range"
73 $XFS_IO_PROG -c "fzero -k 512 512" $dev
74
75 echo "Unaligned punch"
76 $XFS_IO_PROG -c "fpunch 512 512" $dev
77
78 echo "Zero range past MAX_LFS_FILESIZE keep size"
79 # zod = MAX_LFS_FILESIZE
80 case "$(getconf LONG_BIT)" in
81 "32")
82         zod=$(( ($(getconf PAGE_SIZE) << ($(getconf LONG_BIT) - 1) ) - 1))
83         ;;
84 "64")
85         zod=9223372036854775807
86         ;;
87 *)
88         _fail "sizeof(long) == $(getconf LONG_BIT)?"
89         ;;
90 esac
91 $XFS_IO_PROG -c "fzero -k 512k $zod" $dev
92
93 echo "Zero range past MAX_LFS_FILESIZE"
94 $XFS_IO_PROG -c "fzero 512k $zod" $dev
95
96 echo "Zero range to MAX_LFS_FILESIZE fail w/o keepsize"
97 $XFS_IO_PROG -c "fzero 0 $zod" $dev
98
99 echo "Zero range starts past EOD"
100 $XFS_IO_PROG -c "fzero -k 900m 1m" $dev
101
102 echo "Punch starts past EOD"
103 $XFS_IO_PROG -c "fpunch 900m 1m" $dev
104
105 echo "Check contents"
106 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
107
108 echo "Destroy device"
109 _put_scsi_debug_dev
110
111 echo "Create w/o unmap or writesame and format"
112 dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=0 lbpws10=0 lbpu=0 write_same_length=0 unmap_max_blocks=0")
113 _pwrite_byte 0x62 0 4m $dev >> $seqres.full
114 $XFS_IO_PROG -c "fsync" $dev
115
116 echo "Zero punch, no fallback available"
117 $XFS_IO_PROG -c "fpunch 512k 512k" $dev
118
119 echo "Zero range, write fallback"
120 $XFS_IO_PROG -c "fzero -k 1536k 512k" $dev
121
122 echo "Check contents"
123 md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"
124
125 echo "Destroy device"
126 _put_scsi_debug_dev
127
128 # success, all done
129 status=0
130 exit