generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 328
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 328
6 #
7 # Ensure that we can't go over the hard block limit when CoWing a file.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1    # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -rf $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28 . ./common/quota
29
30 # real QA test starts here
31 _require_scratch_reflink
32 _require_cp_reflink
33 _require_xfs_io_command "fiemap"
34 _require_quota
35 _require_nobody
36 _require_odirect
37 _require_user
38
39 rm -f $seqres.full
40
41 echo "Format and mount"
42 _scratch_mkfs > $seqres.full 2>&1
43 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
44 _scratch_mount >> $seqres.full 2>&1
45 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
46 quotaon $SCRATCH_MNT 2> /dev/null
47
48 testdir=$SCRATCH_MNT/test-$seq
49 mkdir $testdir
50
51 sz=1048576
52 echo "Create the original files"
53 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
54 chown $qa_user $testdir/file1
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
57 _report_quota_blocks $SCRATCH_MNT
58 _scratch_cycle_mount
59 quotaon $SCRATCH_MNT 2> /dev/null
60
61 echo "Set hard quota to prevent rewrite"
62 setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
63 _report_quota_blocks $SCRATCH_MNT
64
65 echo "Try to dio write the whole file"
66 su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
67         _filter_xfs_io_error
68 _report_quota_blocks $SCRATCH_MNT
69
70 echo "Try to write the whole file"
71 su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
72         _filter_xfs_io_error
73 _report_quota_blocks $SCRATCH_MNT
74
75 echo "Set hard quota to allow rewrite"
76 setquota -u $qa_user 0 8192 0 0 $SCRATCH_MNT
77 _report_quota_blocks $SCRATCH_MNT
78
79 echo "Try to dio write the whole file"
80 _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full
81 sync
82 _report_quota_blocks $SCRATCH_MNT
83
84 echo "Try to write the whole file"
85 _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full
86 sync
87 _report_quota_blocks $SCRATCH_MNT
88
89 # success, all done
90 status=0
91 exit