4 # Ensure that quota charges us for reflinking a file and that we're not
5 # charged for buffered copy on write.
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
45 # real QA test starts here
47 _require_scratch_reflink
56 echo "Format and mount"
57 _scratch_mkfs > $seqres.full 2>&1
58 export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
59 _scratch_mount >> $seqres.full 2>&1
60 quotacheck -u -g $SCRATCH_MNT 2> /dev/null
61 quotaon $SCRATCH_MNT 2> /dev/null
63 testdir=$SCRATCH_MNT/test-$seq
67 echo "Create the original files"
68 $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
69 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
70 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
72 chown nobody $testdir/urk
74 chown $qa_user $testdir/erk
75 _report_quota_blocks $SCRATCH_MNT
78 echo "Change file ownership"
79 chown $qa_user $testdir/file1
80 chown $qa_user $testdir/file2
81 chown $qa_user $testdir/file3
82 _report_quota_blocks $SCRATCH_MNT
84 echo "CoW one of the files"
85 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $((sz/2)) 0 $((sz/2))" -c "fsync" $testdir/file2 >> $seqres.full
86 _report_quota_blocks $SCRATCH_MNT
88 echo "Remount the FS to see if accounting changes"
90 _report_quota_blocks $SCRATCH_MNT
92 echo "Chown one of the files"
93 chown nobody $testdir/file3
94 _report_quota_blocks $SCRATCH_MNT