generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 416
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 416
6 #
7 # Test fs behavior when large write request can't be met by one single extent
8 #
9 # Inspired by a bug in a btrfs fix, which doesn't get exposed by current test
10 # cases
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs generic
38 _require_scratch
39
40 fs_size=$((128 * 1024 * 1024))
41 page_size=$(get_page_size)
42
43 # We will never reach this number though
44 nr_files=$(($fs_size / $page_size))
45
46 # Use small fs to make the fill more faster
47 _scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
48
49 _scratch_mount
50
51 fill_fs()
52 {
53         dir=$1
54         for i in $(seq -w $nr_files); do
55                 # xfs_io can't return correct value when it hit ENOSPC, use
56                 # dd here to detect ENOSPC
57                 dd if=/dev/zero of=$SCRATCH_MNT/$i bs=$page_size count=1 \
58                         &> /dev/null
59                 if [ $? -ne 0 ]; then
60                         break
61                 fi
62         done
63 }
64
65 fill_fs $SCRATCH_MNT
66
67 # remount to sync every thing into fs, and drop all cache
68 _scratch_remount
69
70 # remove all files with odd file names, which should free near half
71 # of the space
72 rm $SCRATCH_MNT/*[13579]
73 sync
74
75 # We should be able to write at least 1/8 of the whole fs size
76 # The number 1/8 is for btrfs, which only has about 47M for data.
77 # And half of the 47M is already taken up, so only 1/8 is safe here
78 $XFS_IO_PROG -f -c "pwrite 0 $(($fs_size / 8))" $SCRATCH_MNT/large_file | \
79         _filter_xfs_io
80
81 # success, all done
82 status=0
83 exit