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
31 _require_scratch_reflink
33 _require_xfs_io_command "fiemap"
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
48 testdir=$SCRATCH_MNT/test-$seq
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
59 quotaon $SCRATCH_MNT 2> /dev/null
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
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 | \
68 _report_quota_blocks $SCRATCH_MNT
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 | \
73 _report_quota_blocks $SCRATCH_MNT
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
79 echo "Try to dio write the whole file"
80 _pwrite_byte 0x62 0 $sz $testdir/file1 -d >> $seqres.full
82 _report_quota_blocks $SCRATCH_MNT
84 echo "Try to write the whole file"
85 _pwrite_byte 0x62 0 $sz $testdir/file3 >> $seqres.full
87 _report_quota_blocks $SCRATCH_MNT