2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we can't go over the hard block limit when CoWing a file.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
30 # real QA test starts here
32 _require_scratch_reflink
34 _require_xfs_io_command "fiemap"
42 echo "Format and mount"
43 _scratch_mkfs > $seqres.full 2>&1
44 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
45 _scratch_mount >> $seqres.full 2>&1
46 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
47 quotaon $SCRATCH_MNT 2> /dev/null
49 testdir=$SCRATCH_MNT/test-$seq
53 echo "Create the original files"
54 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
55 chown $qa_user $testdir/file1
56 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
57 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
58 _report_quota_blocks $SCRATCH_MNT
60 quotaon $SCRATCH_MNT 2> /dev/null
62 echo "Set hard quota to prevent rewrite"
63 setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT
64 _report_quota_blocks $SCRATCH_MNT
66 echo "Try to dio write the whole file"
67 su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
69 _report_quota_blocks $SCRATCH_MNT
71 echo "Try to write the whole file"
72 su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \
74 _report_quota_blocks $SCRATCH_MNT
76 echo "Set hard quota to allow rewrite"
77 setquota -u $qa_user 0 8192 0 0 $SCRATCH_MNT
78 _report_quota_blocks $SCRATCH_MNT
80 echo "Try to dio write the whole file"
81 _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full
83 _report_quota_blocks $SCRATCH_MNT
85 echo "Try to write the whole file"
86 _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full
88 _report_quota_blocks $SCRATCH_MNT